A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cran.rstudio.com/web/packages/uwot/../rmarkdown/../HomomorphicEncryption/vignettes/CKKS.html below:

CKKS

CKKS

Load libraries that will be used.

library(polynom)
library(HomomorphicEncryption)

Set some parameters.

d  =   4
n  =   2^d
p  =   (n/2)-1
q  = 874
pm = GenPolyMod(n)

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.

pk0 = GenPubKey0(a, s, e, pm, q)
pk1 = GenPubKey1(a)

Create a polynomial message

# create a message
m = polynomial( coef=c(500, 600, 100) )

Create polynomials for the encryption

# polynomials for encryption
e1 = GenError(n)
e2 = GenError(n)
u  = GenU(n)

Generate the ciphertext

ct0 = CoefMod((pk0*u + e1 + m) %% pm, q)
ct1 = EncryptPoly1(pk1, u, e2, pm, q)

Decrypt

decrypt = (ct1 * s) + ct0
decrypt = decrypt %% pm
decrypt = CoefMod(decrypt, q)
print(decrypt[1:length(coef(m))])
#> [1] 523 619 103

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4