google / heir

A compiler for homomorphic encryption
https://heir.dev/
Apache License 2.0
348 stars 49 forks source link

LWE: add evaluation key type and technique #1067

Open ZenithalHourlyRate opened 1 month ago

ZenithalHourlyRate commented 1 month ago

Related to #1057.

I roughly prototyped it from openfhe/pke/keyswitch (BGV/CKKS), yet I do not know if this is accurate for binfhe schemes (CGGI).

Example:

#generator = #polynomial.int_polynomial<1 + x**1024>
#ring = #polynomial.ring<coefficientType = i32, coefficientModulus = 65537 : i32, polynomialModulus=#generator>

#key = #lwe.key<id = "s", size = 1>
#key_mult = #lwe.key<id = "s", size = 1, basis = 2>
#key_rotate = #lwe.key<id = "s", size = 1, rotate = 2>

#keyswitch_bv_base = #lwe.bv_keyswitch_technique<base = 65536, dnum = 0>
#keyswitch_bv = #lwe.bv_keyswitch_technique<base = 0, dnum = 3>
#keyswitch_ghs = #lwe.ghs_keyswitch_technique<extra_modulus=<elements = <65537 : i32>, current = 0>>

!evaluation_key_mult = !lwe.new_lwe_evaluation_key<from_key=#key_mult, to_key=#key, ring=#ring, keyswitch_techniques= #keyswitch_bv, #keyswitch_ghs>
!evaluation_key_rotate = !lwe.new_lwe_evaluation_key<from_key=#key_rotate, to_key=#key, ring=#ring, keyswitch_techniques= #keyswitch_bv_base>
asraa commented 3 weeks ago

Hey! Sorry for the delay - I'm finally back online for development now.