Some verification working
This commit is contained in:
@ -164,7 +164,7 @@ document.addEventListener("PROOF", async (ev) => {
|
||||
// find the relevant entity
|
||||
let region = Region.getRegion(data.region);
|
||||
|
||||
region.prove(data.plainText, data.noise());
|
||||
region.verify(BigInt(data.plainText), BigInt(data.a));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { socket } from "./main.js";
|
||||
import { Packet } from "./packet.js";
|
||||
|
||||
const REGIONS = {};
|
||||
@ -39,9 +40,12 @@ class Strength {
|
||||
const data = ev.detail;
|
||||
|
||||
if (data.region === region && data.stage === "CHALLENGE") {
|
||||
let z = proofSessionProver.prove(data.challenge);
|
||||
let z = proofSessionProver.prove(BigInt(data.challenge));
|
||||
|
||||
socket.emit("message", Packet.createProof(region, z));
|
||||
socket.emit(
|
||||
"message",
|
||||
Packet.createProof(region, "0x" + z.toString(16))
|
||||
);
|
||||
controller.abort();
|
||||
}
|
||||
},
|
||||
@ -52,8 +56,8 @@ class Strength {
|
||||
"message",
|
||||
Packet.createProofConjecture(
|
||||
region,
|
||||
this.cipherText.plainText,
|
||||
proofSessionProver.a
|
||||
"0x" + this.cipherText.plainText.toString(),
|
||||
"0x" + proofSessionProver.a.toString(16)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -72,7 +76,7 @@ class Strength {
|
||||
const data = ev.detail;
|
||||
|
||||
if (data.region === region && data.stage === "PROOF") {
|
||||
if (proofSessionVerifier.verify(data.z)) {
|
||||
if (proofSessionVerifier.verify(BigInt(data.z))) {
|
||||
console.log("verified");
|
||||
this.assumedStrength = plainText;
|
||||
controller.abort();
|
||||
@ -86,7 +90,10 @@ class Strength {
|
||||
|
||||
socket.emit(
|
||||
"message",
|
||||
Packet.createProofChallenge(region, proofSessionVerifier.challenge)
|
||||
Packet.createProofChallenge(
|
||||
region,
|
||||
"0x" + proofSessionVerifier.challenge.toString(16)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -147,7 +154,9 @@ export class Region {
|
||||
}
|
||||
}
|
||||
|
||||
prove() {}
|
||||
prove() {
|
||||
this.strength.prove(this.name);
|
||||
}
|
||||
|
||||
verify(plainText, a) {
|
||||
this.strength.verify(this.name, plainText, a);
|
||||
|
@ -154,6 +154,11 @@ export class Player {
|
||||
|
||||
this.totalStrength += 1;
|
||||
|
||||
// send proofs
|
||||
for (let region of this.getRegions()) {
|
||||
region.prove();
|
||||
}
|
||||
|
||||
this.endTurn();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user