feat: makes mimcsponge contract act like the circuit version

This commit is contained in:
Kobi Gurkan 2019-07-08 10:52:23 +03:00
parent 324b8bf8cc
commit 1483abaa2f
2 changed files with 9 additions and 5 deletions

4
package-lock.json generated

@ -8632,7 +8632,7 @@
}, },
"os-tmpdir": { "os-tmpdir": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
}, },
"p-cancelable": { "p-cancelable": {
@ -9248,7 +9248,7 @@
}, },
"sprintf-js": { "sprintf-js": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "http://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
}, },
"sshpk": { "sshpk": {

@ -50,7 +50,11 @@ function createCode(seed, n) {
C.addmod(); // e=t^5+xR xL k q (for next round: xL xR k q) C.addmod(); // e=t^5+xR xL k q (for next round: xL xR k q)
for (let i=0; i<n-1; i++) { for (let i=0; i<n-1; i++) {
if (i < n-2) {
ci = Web3Utils.keccak256(ci); ci = Web3Utils.keccak256(ci);
} else {
ci = "0x00";
}
C.swap(1); // xR xL k q C.swap(1); // xR xL k q
C.dup(3); // q xR xL k q C.dup(3); // q xR xL k q
C.dup(3); // k q xR xL k q C.dup(3); // k q xR xL k q
@ -74,9 +78,9 @@ function createCode(seed, n) {
C.addmod(); // e=t^5+xR xL k q (for next round: xL xR k q) C.addmod(); // e=t^5+xR xL k q (for next round: xL xR k q)
} }
C.push("0x00");
C.mstore(); // Save it to pos 0;
C.push("0x20"); C.push("0x20");
C.mstore(); // Save it to pos 0;
C.push("0x00");
C.mstore(); // Save it to pos 1; C.mstore(); // Save it to pos 1;
C.push("0x40"); C.push("0x40");
C.push("0x00"); C.push("0x00");