Browse Source

Wip update test vectors smt and mimc

feature/synctests
krlosMata 5 years ago
parent
commit
d7f7243239
2 changed files with 7 additions and 6 deletions
  1. +4
    -4
      test/mimctestvectors.js
  2. +3
    -2
      test/smttestvectors.js

+ 4
- 4
test/mimctestvectors.js

@ -29,23 +29,23 @@ describe("[mimc hash] Javascript test", function () {
const entries = [bigInt(12)]; const entries = [bigInt(12)];
const hash = mimcjs.multiHash(entries); const hash = mimcjs.multiHash(entries);
const hashHex = bytesToHex(bigIntToBuffer(hash)); const hashHex = bytesToHex(bigIntToBuffer(hash));
expect(hashHex).to.be.equal("0x04252a243a23848a29fa5783336905f6394585fb38d0d89f16d36084c53cb73c");
expect(hashHex).to.be.equal("0x237c92644dbddb86d8a259e0e923aaab65a93f1ec5758b8799988894ac0958fd");
}); });
it("Mimc7 hash with 2 entries", () => { it("Mimc7 hash with 2 entries", () => {
const entries = [bigInt(12), bigInt(45), bigInt(78), bigInt(41)]; const entries = [bigInt(12), bigInt(45), bigInt(78), bigInt(41)];
const hi = mimcjs.multiHash(entries.slice(2)); const hi = mimcjs.multiHash(entries.slice(2));
const hiHex = bytesToHex(bigIntToBuffer(hi)); const hiHex = bytesToHex(bigIntToBuffer(hi));
expect(hiHex).to.be.equal("0x1fd4bc970a697084ec1f83ecf81936d4a047e27c654752ddbc89f9ed1728e0ab");
expect(hiHex).to.be.equal("0x067f3202335ea256ae6e6aadcd2d5f7f4b06a00b2d1e0de903980d5ab552dc70");
const hv = mimcjs.multiHash(entries.slice(0, 2)); const hv = mimcjs.multiHash(entries.slice(0, 2));
const hvHex = bytesToHex(bigIntToBuffer(hv)); const hvHex = bytesToHex(bigIntToBuffer(hv));
expect(hvHex).to.be.equal("0x263924eb9ae730cea9ce31bb9ada695ec3525536b4c058813552b074db36ba9a");
expect(hvHex).to.be.equal("0x15ff7fe9793346a17c3150804bcb36d161c8662b110c50f55ccb7113948d8879");
}); });
it("Mimc7 hash with 4 entries", () => { it("Mimc7 hash with 4 entries", () => {
const entries = [bigInt(12), bigInt(45), bigInt(78), bigInt(41)]; const entries = [bigInt(12), bigInt(45), bigInt(78), bigInt(41)];
const hash = mimcjs.multiHash(entries); const hash = mimcjs.multiHash(entries);
const hashHex = bytesToHex(bigIntToBuffer(hash)); const hashHex = bytesToHex(bigIntToBuffer(hash));
expect(hashHex).to.be.equal("0x10e02cc6c8fc40cda121602903df911f6398d65f84ff1f27c680d0b7d85b7418");
expect(hashHex).to.be.equal("0x284bc1f34f335933a23a433b6ff3ee179d682cd5e5e2fcdd2d964afa85104beb");
}); });
}); });

+ 3
- 2
test/smttestvectors.js

@ -46,9 +46,9 @@ describe("[sparse-merkle-tree] Javascript test", function () {
await tree.insert(key1,value1); await tree.insert(key1,value1);
const root = tree.root; const root = tree.root;
const rootBuff = bigIntToBuffer(root); const rootBuff = bigIntToBuffer(root);
expect(bytesToHex(rootBuff)).to.be.equal("0x112bae1c89a7a51a9a09e88c2f095bfe8a7d94d7c0cf5ba017a491c3e0b95c8f");
expect(bytesToHex(rootBuff)).to.be.equal("0x2bf39430aa2482fc1e2f170179c8cab126b0f55f71edc8d333f4c80cb4e798f5");
}); });
/*
it("Add two claims", async () => { it("Add two claims", async () => {
const firstClaim = [bigInt(12), bigInt(45), bigInt(78), bigInt(41)]; const firstClaim = [bigInt(12), bigInt(45), bigInt(78), bigInt(41)];
const firstEntries = newEntry(firstClaim); const firstEntries = newEntry(firstClaim);
@ -140,4 +140,5 @@ describe("[sparse-merkle-tree] Javascript test", function () {
expect(bytesToHex(root1)).to.be.equal("0x27990ef22656f49f010b2b48b2418c46f2bc93e4afb2e3377a1eb09f129e9802"); expect(bytesToHex(root1)).to.be.equal("0x27990ef22656f49f010b2b48b2418c46f2bc93e4afb2e3377a1eb09f129e9802");
}); });
*/
}); });

Loading…
Cancel
Save