...
This commit is contained in:
@ -70,6 +70,10 @@ class Ciphertext {
|
||||
return "0x" + this.cipherText.toString(16);
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return "0x" + this.cipherText.toString(16);
|
||||
}
|
||||
|
||||
prove() {
|
||||
return new ValueProofSessionProver(this);
|
||||
}
|
||||
|
@ -23,12 +23,14 @@ function cryptoShuffle(l) {
|
||||
|
||||
window.cryptoShuffle = cryptoShuffle;
|
||||
|
||||
const ROUNDS = 24;
|
||||
|
||||
function proveRegions(regions) {
|
||||
// Construct prover coins
|
||||
let coins = [];
|
||||
|
||||
let regionNames = Object.keys(regions);
|
||||
for (let x = 0; x < 40; x++) {
|
||||
for (let x = 0; x < ROUNDS; x++) {
|
||||
let psi = cryptoShuffle(structuredClone(regionNames)).join("");
|
||||
let newRegions = structuredClone(regions);
|
||||
// rearrange keys
|
||||
@ -36,7 +38,7 @@ function proveRegions(regions) {
|
||||
let c = regions[psi[index]].clone();
|
||||
// re-blind
|
||||
c.update(c.pubKey.encrypt(0n));
|
||||
newRegions[regionNames[index]] = c.toString();
|
||||
newRegions[regionNames[index]] = c;
|
||||
}
|
||||
coins.push(newRegions);
|
||||
}
|
||||
@ -44,10 +46,25 @@ function proveRegions(regions) {
|
||||
// Construct verifier coins
|
||||
let hasher = new jsSHA("SHA3-256", "TEXT");
|
||||
hasher.update(JSON.stringify(coins));
|
||||
let hash = hasher.getHash("UINT8ARRAY");
|
||||
|
||||
console.log(hasher.getHash("UINT8ARRAY"));
|
||||
let verifierCoins = [];
|
||||
for (let i = 0; i < ROUNDS / 8; i++) {
|
||||
let v = hash[i];
|
||||
for (let j = 0; j < 8; j++) {
|
||||
verifierCoins.push(v & 1);
|
||||
v >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Construct prover proofs
|
||||
for (let coin of verifierCoins) {
|
||||
if (coin === 1) {
|
||||
// Reveal bijection and proof for zero
|
||||
} else {
|
||||
// Reveal proof for plaintext
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.proveRegions = proveRegions;
|
||||
|
Reference in New Issue
Block a user