Browse Source

feat: makes mimcsponge contract act like the circuit version

feature/pr-19
Kobi Gurkan 5 years ago
parent
commit
1483abaa2f
2 changed files with 9 additions and 5 deletions
  1. +2
    -2
      package-lock.json
  2. +7
    -3
      src/mimcsponge_gencontract.js

+ 2
- 2
package-lock.json

@ -8632,7 +8632,7 @@
},
"os-tmpdir": {
"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="
},
"p-cancelable": {
@ -9248,7 +9248,7 @@
},
"sprintf-js": {
"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="
},
"sshpk": {

+ 7
- 3
src/mimcsponge_gencontract.js

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

Loading…
Cancel
Save