Browse Source

Update to 17 (16) MerkleTree levels

pull/2/head
arnaucube 4 years ago
parent
commit
4648850e0c
10 changed files with 32 additions and 28 deletions
  1. +1
    -1
      circuits/deposit.circom
  2. +1
    -1
      circuits/withdraw.circom
  3. +11
    -11
      contracts/deposit-verifier.sol
  4. +10
    -10
      contracts/withdraw-verifier.sol
  5. +1
    -1
      dist/miksi-browser.js
  6. +1
    -1
      src/miksi.ts
  7. +1
    -1
      test/circuits/deposit.test.ts
  8. +1
    -1
      test/circuits/withdraw.test.ts
  9. +2
    -1
      test/contracts/miksi.test.ts
  10. +3
    -0
      truffle-config.js

+ 1
- 1
circuits/deposit.circom

@ -103,4 +103,4 @@ template Deposit(nLevels) {
smtNew.value <== hash.out; smtNew.value <== hash.out;
} }
component main = Deposit(5);
component main = Deposit(17); // 16 real levels (due circom leaf protection)

+ 1
- 1
circuits/withdraw.circom

@ -62,4 +62,4 @@ template Withdraw(nLevels) {
smtV.value <== hash.out; smtV.value <== hash.out;
} }
component main = Withdraw(5);
component main = Withdraw(17); // 16 real levels (due circom leaf protection)

+ 11
- 11
contracts/deposit-verifier.sol

@ -174,18 +174,18 @@ contract DepositVerifier {
DepositPairing.G1Point C; DepositPairing.G1Point C;
} }
function verifyingKey() internal pure returns (VerifyingKey memory vk) { function verifyingKey() internal pure returns (VerifyingKey memory vk) {
vk.alfa1 = DepositPairing.G1Point(21506687545368058004343406580116567034147526000842816840128545276973742545184,6329182718686089171038341156980474851697706805700950494904106219620407014616);
vk.beta2 = DepositPairing.G2Point([4879555627245165409149871538075733938105048434319249232400453218142465451413,21138288820909669606998883110984027323337220382339792251110701043897894551957], [5169549521058601698487664174209719268567349497614886596752309135835832995494,7084989950156422335683471222873313175020040191471459248919344470661092421274]);
vk.gamma2 = DepositPairing.G2Point([987570836872361556778610365355843744529291372758555698218824999637155094052,12489208558759092424522966223520504564058471700691215920684299633681110938103], [8467175820494965874716563164629440451461359739737577595086242330541705449335,4885103742312078925552682301933241836611982659444780110903504720342522343037]);
vk.delta2 = DepositPairing.G2Point([1857697941034599597747007249362130217164697733324024108343089531632013115631,10720701369897961653174284201368857135933412671924295535932129219862613390723], [3456560663695994496422971399272199473998827789414669302047065719981784522344,1622122815068542292622030743771214576916556859911974349852742741130896660940]);
vk.alfa1 = DepositPairing.G1Point(6252279943948821612875254485822400771880244748647402468559313390659426369211,14613992641366395519215313033197052494675205790791681942712524672663717445198);
vk.beta2 = DepositPairing.G2Point([8815707221276583891078115500662413295646422001003116635595393183791263464666,2419345326742699182992664780905159492965802671871300884928909939820530848387], [13802188444049362002223101887345226877142883308911663519491915021252904802728,8432022027118506252472861389475505702286644933376629310815925957781079388244]);
vk.gamma2 = DepositPairing.G2Point([406780534454176465129277539913777571896656479994247886563898597395429608191,8553686745430855428347818111461857703407929988498137065162278041029533501400], [10853405844969955843420851706686864381784815223125536658953775544597422525149,16970177376889915166884914612008041178398555620271753364587667807183773056978]);
vk.delta2 = DepositPairing.G2Point([17774593393920734301044375457515456063884202391938358455667100316292620932619,652992445536380252856758894184970383216921565250275732529612554514615486705], [8565671556084260686055251361834646248751758478811415108547802639098436142689,13627472961242110255971086079899697279073175536722168875617347642947908794476]);
vk.IC = new DepositPairing.G1Point[](7); vk.IC = new DepositPairing.G1Point[](7);
vk.IC[0] = DepositPairing.G1Point(16782605380489280136898329894217631086273767090288708977044630687962383399712,19132176629326023148588718510027189847689206839350227494924742864011882964482);
vk.IC[1] = DepositPairing.G1Point(3051091979340713905520740174087317073820219138899260014965710828520032438205,4332666002233816480303663354446417095506446455639166349896162400246016243480);
vk.IC[2] = DepositPairing.G1Point(12656063712220015559994158114785100625064437916231441092291990522785048600025,15745941453121551808566905778505507754535684292109324766460425242566417993596);
vk.IC[3] = DepositPairing.G1Point(5192851164182139068345289463860618976483494058569778412988156347204586590803,17230228592888907987066512201562762280889171374277031059677665774054871796127);
vk.IC[4] = DepositPairing.G1Point(7773180646914901165561893028300805679120219758626526142234656359602783611229,8935008527712617619507470500760356832205500310299935052166857469092046352698);
vk.IC[5] = DepositPairing.G1Point(7210880767140890921368045698924224491106328322805109472078454065459805978912,6053299184323673547596765506355707108280820282595136943043253651567389299444);
vk.IC[6] = DepositPairing.G1Point(21754268299863456424252376593834862050583590653215284929555194788021295259186,12083666975153603989088504016147935022099865881580414349021892390012905182351);
vk.IC[0] = DepositPairing.G1Point(10428563448506003955350846849697024823467951195979510170085385051366494122630,2001368486752884718033076277913854180721154412880313561543985388032034832578);
vk.IC[1] = DepositPairing.G1Point(4128122503032922060195529775123411053757718861576733396781404734329175129810,10674578892367272724467858279423956771312053469141701790449967683133025637132);
vk.IC[2] = DepositPairing.G1Point(19773281464520362843244450371118225183481659515807020952674214520191343536792,15379009728817649289524197508360737263801583612474597112384517352187225280313);
vk.IC[3] = DepositPairing.G1Point(14445852532044159873734129156753952133803550608446385223251919704854960384859,7077329911841232859880292933329532486425877098134111290548060164729473197615);
vk.IC[4] = DepositPairing.G1Point(21203069170036177324269770159791288324714871209409930031741364108474535151841,8265986849104087053031541158247678629561167271267822543600920475259735501627);
vk.IC[5] = DepositPairing.G1Point(7815738803719288008965544439519375118301374923131249465167234012095974108078,14621864468590078300113893865387457049678236814266039911309734278145027746551);
vk.IC[6] = DepositPairing.G1Point(8935039868766995891455796224784160256067346799724853938828138135035767086643,904657175184727805046626884361174202421281696337758135233214084380356026332);
} }
function verify(uint[] memory input, Proof memory proof) internal view returns (uint) { function verify(uint[] memory input, Proof memory proof) internal view returns (uint) {

+ 10
- 10
contracts/withdraw-verifier.sol

@ -174,17 +174,17 @@ contract WithdrawVerifier {
WithdrawPairing.G1Point C; WithdrawPairing.G1Point C;
} }
function verifyingKey() internal pure returns (VerifyingKey memory vk) { function verifyingKey() internal pure returns (VerifyingKey memory vk) {
vk.alfa1 = WithdrawPairing.G1Point(874296415152454038750111518730470879864847245636249526293593300594438647581,15979235715490357992573109925613820121720532161887711772414315742162472693961);
vk.beta2 = WithdrawPairing.G2Point([17043604282232946966399061941585971138345826736102379721717756958713107433897,15739027123271752611162178177135326511391151981940395160917465318719156805260], [3797971088163506422438134077758774338860443481081804739683404850553535832631,11560493991173197757389709527218456316687051272555605576254618799815814174226]);
vk.gamma2 = WithdrawPairing.G2Point([17826994063187647086679376784040057161879626779038650092762231847780898531776,18092067198016441468600742390990617191442116024456978927775457907701935268807], [11771714389579485819532519820481239857850082055113064296833342938919982562234,15977659339405680483276286512116930515882070791767375618781057809414065924592]);
vk.delta2 = WithdrawPairing.G2Point([8316967811382932519290972950815011964118763330443715990991973982358468530714,20282320703294371986168006296736850087894825561296648183335987810568951184038], [4390214017634715402404973653992226200446436790731904993045142032170903216442,20614105846821441247731050963033514068886285671236074407843861970591776791732]);
vk.alfa1 = WithdrawPairing.G1Point(4297056733213219859343595902911474212531679066691174515518566289296862448444,4118210981440029225166132201111655761091977199270131833660894679466015902790);
vk.beta2 = WithdrawPairing.G2Point([8432401178610715017522187095017141452256968060720655001943681144704681203162,20225339942421781890739814367503015805021408029816534384568975989447323618511], [4834758580575986670881233088235906918937658419326998231175019058718340643738,18563021167708801438919497910470781384291873402945244720127030262991586019354]);
vk.gamma2 = WithdrawPairing.G2Point([12216917316860064359319225214672707506982145717785585352407055318045791852406,16166539837790779483464664514892121904759368139188876537264973277846536919241], [20490357584101774634267615913836176478875767727346317112419586614764063234950,16010134726469276935755880346958799379053190723590701758427883606793091122235]);
vk.delta2 = WithdrawPairing.G2Point([10474213958708183921155086977680302183767751804928195354437737122452000530775,9773108273173417325339709698942421365637766622753869523317186054233667618378], [16147854964572048164082375837809824945742203950104688071859656285754596010250,11100262415558015426093541731679959772584136240842322421838884270434696620945]);
vk.IC = new WithdrawPairing.G1Point[](6); vk.IC = new WithdrawPairing.G1Point[](6);
vk.IC[0] = WithdrawPairing.G1Point(13777782598212752214101396110325452758793144049135952238731843149667577906327,4132216218051093008941097133571051570042249600748384515361794787456764239092);
vk.IC[1] = WithdrawPairing.G1Point(17254199157693987913680620942799267824403099972298931061193408436988805067681,19057785517215912158374323893423053169340392654197182370251952786046987847963);
vk.IC[2] = WithdrawPairing.G1Point(8032094434010017453782060852621148533457745849951676783550169997600897729098,15045016397922053432955997034980933218190966160759511753107700075264725510316);
vk.IC[3] = WithdrawPairing.G1Point(3953079931945811174339813429753777379629051828184971373530491496432459946952,780250318777868518858794360887477045831517282538268598326752819631280248846);
vk.IC[4] = WithdrawPairing.G1Point(20517190556962451782120140740433370379116788517421027435302993714333043326655,5773767396303058684703853462481882087599016685713319675046801468157326786448);
vk.IC[5] = WithdrawPairing.G1Point(17849110086081855828525443762387620026554365314604676962267495442430735164166,15493148936562638050925319502669308466550647404470708924503648186012089148515);
vk.IC[0] = WithdrawPairing.G1Point(12549035287950018826389227128124648821309642448046081194740867551414746445936,16568684014919445974100333544046090587350141595344577637675040655062709518493);
vk.IC[1] = WithdrawPairing.G1Point(12115083684378263354532293492903135977611827458752142958704830075120237564442,20870100634266963726587012268331775772515090702290901068079447765002759133309);
vk.IC[2] = WithdrawPairing.G1Point(5812745461009917344575852755312885578454227891300545343869244275304038771554,20292323840549344370214519296853977558551052789143029493431728787305104927396);
vk.IC[3] = WithdrawPairing.G1Point(4547260115459198012764009325266310410529115043680958732580932197784570644367,10715056277994978617773043139980635251314875156509544440091005842529235092175);
vk.IC[4] = WithdrawPairing.G1Point(1917397956416751861666133718730009968886977460807568824355482458793905843210,3701368891299580862131264739399266552453491844311287913354184906669407062679);
vk.IC[5] = WithdrawPairing.G1Point(9794226343300072560298373762652188441793658526495383382310165666486106285885,13609131229374196873721534431966454573967113169445854598703174909986898964199);
} }
function verify(uint[] memory input, Proof memory proof) internal view returns (uint) { function verify(uint[] memory input, Proof memory proof) internal view returns (uint) {

+ 1
- 1
dist/miksi-browser.js

@ -76295,7 +76295,7 @@ const Web3 = require("web3");
// const buildBn128 = require("wasmsnark").buildBn128; // const buildBn128 = require("wasmsnark").buildBn128;
const nLevels = 5;
const nLevels = 17;
const coinCode = "0"; // refearing to ETH const coinCode = "0"; // refearing to ETH
const ethAmount = '1'; const ethAmount = '1';
const amount = Web3.utils.toWei(ethAmount, 'ether'); const amount = Web3.utils.toWei(ethAmount, 'ether');

+ 1
- 1
src/miksi.ts

@ -10,7 +10,7 @@ const Web3 = require("web3");
// const buildBn128 = require("wasmsnark").buildBn128; // const buildBn128 = require("wasmsnark").buildBn128;
const nLevels = 5;
const nLevels = 17;
const coinCode = "0"; // refearing to ETH const coinCode = "0"; // refearing to ETH
const ethAmount = '1'; const ethAmount = '1';
const amount = Web3.utils.toWei(ethAmount, 'ether'); const amount = Web3.utils.toWei(ethAmount, 'ether');

+ 1
- 1
test/circuits/deposit.test.ts

@ -17,7 +17,7 @@ describe("deposit test", function () {
{reduceConstraints: false} {reduceConstraints: false}
); );
const nLevels = 5;
const nLevels = 17;
const secret = "1234567890"; const secret = "1234567890";
const coinCode = "0"; const coinCode = "0";

+ 1
- 1
test/circuits/withdraw.test.ts

@ -17,7 +17,7 @@ describe("withdraw test", function () {
{reduceConstraints: false} {reduceConstraints: false}
); );
const nLevels = 5;
const nLevels = 17;
const secret = "1234567890"; const secret = "1234567890";
const coinCode = "0"; const coinCode = "0";

+ 2
- 1
test/contracts/miksi.test.ts

@ -16,7 +16,7 @@ const smt = require("circomlib").smt;
let insVerifier; let insVerifier;
let insMiksi; let insMiksi;
const nLevels = 5;
const nLevels = 17;
const secret = ["1234567890", "987654321", "123"]; const secret = ["1234567890", "987654321", "123"];
const coinCode = "0"; // refearing to ETH const coinCode = "0"; // refearing to ETH
@ -105,6 +105,7 @@ contract("miksi", (accounts) => {
}); });
it("Calculate witness and generate the zkProof", async () => { it("Calculate witness and generate the zkProof", async () => {
this.timeout(10000000);
await genZKProof(0, addr2, "1"); await genZKProof(0, addr2, "1");
await genZKProof(1, addr4, "2"); await genZKProof(1, addr4, "2");
await genZKProof(2, addr4, "3"); await genZKProof(2, addr4, "3");

+ 3
- 0
truffle-config.js

@ -15,6 +15,9 @@
module.exports = { module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration> // See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration! // to customize your Truffle configuration!
enableTimeouts: false,
before_timeout: 1000000000,
test_timeout: 1000000000,
compilers: { compilers: {
solc: { solc: {
version: "0.6.0" version: "0.6.0"

Loading…
Cancel
Save