add crypto shuffle
This commit is contained in:
parent
1647615595
commit
2700cb2792
@ -1,13 +1,30 @@
|
|||||||
|
// Fisher-Yates shuffle
|
||||||
function cryptoShuffle(l) {
|
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;
|
window.cryptoShuffle = cryptoShuffle;
|
||||||
|
|
||||||
function proveRegions(regions) {
|
function proveRegions(regions) {
|
||||||
// Construct prover coins
|
// Construct prover coins
|
||||||
|
let coins = [];
|
||||||
|
|
||||||
let regionNames = Object.keys(regions.keys());
|
let regionNames = Object.keys(regions.keys());
|
||||||
let psi = [regionNames];
|
for (let x = 0; x < 20; x++) {
|
||||||
|
let psi = cryptoShuffle(regionNames).join("");
|
||||||
|
}
|
||||||
|
|
||||||
// Construct verifier coins
|
// Construct verifier coins
|
||||||
let hasher = new jsSHA("SHA3-256", "TEXT");
|
let hasher = new jsSHA("SHA3-256", "TEXT");
|
||||||
|
Loading…
Reference in New Issue
Block a user