diff --git a/static/js/modules/interface/proofs.js b/static/js/modules/interface/proofs.js index 9868111..ada55cd 100644 --- a/static/js/modules/interface/proofs.js +++ b/static/js/modules/interface/proofs.js @@ -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");