add crypto shuffle

This commit is contained in:
jude 2023-04-10 22:23:06 +01:00
parent 1647615595
commit 2700cb2792

View File

@ -1,13 +1,30 @@
// Fisher-Yates shuffle
function cryptoShuffle(l) {
for (let i = 0; i < l.length - 1; i++) {}
for (let i = l.length - 1; i > 0; i--) {
let value = new Uint8Array([0]);
crypto.getRandomValues(value);
while (value[0] > i) {
crypto.getRandomValues(value);
}
let temp = l[i];
l[i] = l[value[0]];
l[value[0]] = temp;
}
return l;
}
window.cryptoShuffle = cryptoShuffle;
function proveRegions(regions) {
// Construct prover coins
let coins = [];
let regionNames = Object.keys(regions.keys());
let psi = [regionNames];
for (let x = 0; x < 20; x++) {
let psi = cryptoShuffle(regionNames).join("");
}
// Construct verifier coins
let hasher = new jsSHA("SHA3-256", "TEXT");