This commit is contained in:
2023-04-06 20:42:24 +01:00
parent f645c234ce
commit eccf482192
6 changed files with 50 additions and 33 deletions

View File

@ -15,8 +15,14 @@ class Cyphertext {
// Compute g^m by binomial theorem.
let gm = (1n + key.n * plainText) % key.n ** 2n;
// Compute g^m r^n from crt
// Compute g^m r^n from crt.
this.cyphertext = (gm * mod_exp(r, key.n, key.n ** 2n)) % key.n ** 2n;
// Force into range.
while (this.cyphertext < 0n) {
this.cyphertext += key.n ** 2n;
}
this.r = r;
this.pubKey = key;
this.plainText = plainText;