This commit is contained in:
jude
2023-04-13 16:33:32 +01:00
parent 0e30ee5334
commit d3e309c1e3
2 changed files with 42 additions and 9 deletions

View File

@ -5,7 +5,16 @@ const PAILLIER = 0;
const JURIK = 1;
class Ciphertext {
constructor(key, plainText, r) {
constructor(key, plainText, r, set) {
if (set !== undefined) {
this.pubKey = key;
this.plainText = plainText;
this.readOnly = false;
return;
}
if (r === undefined) {
// Use the optimised form using Jacobi classes
r = cryptoRandom();
@ -107,6 +116,15 @@ class Ciphertext {
asReadOnlyCiphertext() {
return new ReadOnlyCiphertext(this.pubKey, this.cipherText);
}
clone() {
let c = new Ciphertext(this.pubKey, this.plainText, 0, true);
c.cipherText = this.cipherText;
c.r = this.r;
c.mode = this.mode;
return c;
}
}
class ValueProofSessionProver {