The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Set some parameters.
Set a working seed for random numbers
Create the secret key and the polynomials a and e, which will go into the public key
# generate a secret key
s = GenSecretKey(n)
# generate a
a = GenA(n, q)
# generate the error
e = GenError(n)
Generate the public key.
Create a polynomial message
Create polynomials for the encryption
Generate the ciphertext
m1_ct0 = pk0*u + p*e1 + m1
m1_ct0 = m1_ct0 %% pm
m1_ct0 = CoefMod(m1_ct0, q)
m1_ct1 = pk1*u + p*e2
m1_ct1 = m1_ct1 %% pm
m1_ct1 = CoefMod(m1_ct1, q)
m2_ct0 = pk0*u + p*e1 + m2
m2_ct0 = m2_ct0 %% pm
m2_ct0 = CoefMod(m2_ct0, q)
m2_ct1 = pk1*u + p*e2
m2_ct1 = m2_ct1 %% pm
m2_ct1 = CoefMod(m2_ct1, q)
EvalMult
multi_ct0 = m1_ct0 * m2_ct0
multi_ct0 = multi_ct0 %% pm
multi_ct0 = CoefMod(multi_ct0, q)
multi_ct0 = round(multi_ct0)
multi_ct1 = (m1_ct0 * m2_ct1 + m1_ct1 * m2_ct0)
multi_ct1 = multi_ct1 %% pm
multi_ct1 = CoefMod(multi_ct1, q)
multi_ct1 = round(multi_ct1)
multi_ct2 = (m1_ct1 * m2_ct1)
multi_ct2 = multi_ct2 %% pm
multi_ct2 = CoefMod(multi_ct2, q)
multi_ct2 = round(multi_ct2)
Decrypt
decrypt = (multi_ct2 * s^2) + (multi_ct1 * s) + multi_ct0
decrypt = decrypt %% pm
decrypt = CoefMod(decrypt, q)
decrypt = CoefMod(round(decrypt), p)
print(decrypt)
#> x + x^2 + x^3
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.