...
This commit is contained in:
parent
8e149fad42
commit
7f6ceb1968
@ -85,10 +85,11 @@ export class Packet {
|
||||
});
|
||||
}
|
||||
|
||||
static createReinforce(regionCipherTexts) {
|
||||
static createReinforce(regionCipherTexts, verification) {
|
||||
return this._sign({
|
||||
...this._createBase("ACT"),
|
||||
regions: regionCipherTexts,
|
||||
verification: verification,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { RsaPubKey } from "../crypto/rsa.js";
|
||||
import { PaillierPubKey, ReadOnlyCiphertext } from "../crypto/paillier.js";
|
||||
import { Region } from "./map.js";
|
||||
import { showDefenseDom } from "./dom.js";
|
||||
import { proveRegions, verifyRegions } from "./proofs.js";
|
||||
|
||||
// Timeout to consider a player disconnected
|
||||
const TIMEOUT = 30_000;
|
||||
@ -107,6 +108,11 @@ export class Player {
|
||||
* @param data Data received via socket.
|
||||
*/
|
||||
reinforce(data) {
|
||||
if (!verifyRegions(data.verification, this.paillierPubKey)) {
|
||||
console.log("Failed to verify Protocol 4.5!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (let regionName of Object.keys(data.regions)) {
|
||||
let region = Region.getRegion(regionName);
|
||||
|
||||
@ -153,11 +159,13 @@ export class Player {
|
||||
cipherText = this.paillierPubKey.encrypt(1n);
|
||||
}
|
||||
|
||||
regions[ourRegion.name] = cipherText.toString();
|
||||
regions[ourRegion.name] = cipherText;
|
||||
ourRegion.reinforce(cipherText);
|
||||
}
|
||||
|
||||
socket.emit("message", Packet.createReinforce(regions));
|
||||
let verification = proveRegions(regions);
|
||||
|
||||
socket.emit("message", Packet.createReinforce(regions, verification));
|
||||
|
||||
this.totalStrength += 1;
|
||||
|
||||
|
@ -43,7 +43,7 @@ function getCoins(text) {
|
||||
|
||||
window.cryptoShuffle = cryptoShuffle;
|
||||
|
||||
function proveRegions(regions) {
|
||||
export function proveRegions(regions) {
|
||||
// Construct prover coins
|
||||
let proofs = [];
|
||||
let privateInputs = [];
|
||||
|
Loading…
Reference in New Issue
Block a user