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.
Load libraries that will be used.
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 polynomials for the encryption
Now create to messages to add.
Encrypt the messages.
m1_ct0 = EncryptPoly0(m1, pk0, u, e1, p, pm, q)
m1_ct1 = EncryptPoly1( pk1, u, e2, pm, q)
m2_ct0 = EncryptPoly0(m2, pk0, u, e1, p, pm, q)
m2_ct1 = EncryptPoly1( pk1, u, e2, pm, q)
Sum the encrypted messages.
sum_ct0 = m1_ct0 + m2_ct0
sum_ct1 = m1_ct1 + m2_ct1
sum_ct0 = sum_ct0 %% pm
sum_ct0 = CoefMod(sum_ct0, q)
sum_ct1 = sum_ct1 %% pm
sum_ct1 = CoefMod(sum_ct1, q)
Decrypt the sum
decrypt = (sum_ct1 * s) + sum_ct0
decrypt = decrypt %% pm
decrypt = CoefMod(decrypt, q)
# rescale
decrypt = decrypt * p/q
# round then mod p
decrypt = CoefMod(round(decrypt), p)
print(decrypt)
#> 1 + 2*x + x^2
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.