Fix a lot of stuff

This commit is contained in:
2023-04-10 11:19:11 +01:00
parent 848c56ff84
commit 0991c6bff9
8 changed files with 64 additions and 25 deletions

View File

@ -1,7 +1,7 @@
import { cryptoRandom, generate_prime } from "./random_primes.js";
import { mod_exp } from "./math.js";
class Cyphertext {
class Ciphertext {
constructor(key, plainText, r) {
if (r === undefined) {
r = cryptoRandom(4096);
@ -46,15 +46,15 @@ class Cyphertext {
}
prove() {
return new ProofSessionProver(this);
return new ZeroProofSessionProver(this);
}
asReadOnlyCyphertext() {
return new ReadOnlyCyphertext(this.pubKey, this.cyphertext);
return new ReadOnlyCiphertext(this.pubKey, this.cyphertext);
}
}
class ProofSessionProver {
class ZeroProofSessionProver {
constructor(cipherText) {
this.cipherText = cipherText;
@ -87,9 +87,9 @@ class ProofSessionProver {
}
}
window.Cyphertext = Cyphertext;
window.Cyphertext = Ciphertext;
export class ReadOnlyCyphertext {
export class ReadOnlyCiphertext {
constructor(key, cyphertext) {
this.cyphertext = cyphertext;
this.pubKey = key;
@ -107,15 +107,15 @@ export class ReadOnlyCyphertext {
}
prove(plainText, a) {
return new ProofSessionVerifier(this, plainText, a);
return new ZeroProofSessionVerifier(this, plainText, a);
}
clone() {
return new ReadOnlyCyphertext(this.pubKey, this.cyphertext);
return new ReadOnlyCiphertext(this.pubKey, this.cyphertext);
}
}
class ProofSessionVerifier {
class ZeroProofSessionVerifier {
constructor(cipherText, plainText, a) {
// Clone, otherwise the update below will mutate the original value
this.cipherText = cipherText.clone();
@ -147,7 +147,7 @@ class ProofSessionVerifier {
}
}
window.ReadOnlyCyphertext = ReadOnlyCyphertext;
window.ReadOnlyCyphertext = ReadOnlyCiphertext;
export class PaillierPubKey {
constructor(n) {
@ -157,7 +157,7 @@ export class PaillierPubKey {
}
encrypt(m, r) {
return new Cyphertext(this, m, r);
return new Ciphertext(this, m, r);
}
toJSON() {