diff --git a/.github/workflows/test-contracts.yml b/.github/workflows/test-contracts.yml deleted file mode 100644 index 1df30ffaa..000000000 --- a/.github/workflows/test-contracts.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Build and test contracts - -on: - push: - paths: - - 'contracts/**' - -env: - NODE_VERSION: 12.x - -jobs: - test-contracts: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - - name: Install - run: yarn - - name: Run tests - run: yarn test:contracts - diff --git a/.gitignore b/.gitignore index 6b2d38407..0d2261a26 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ vue-app/.env vue-app/gundata/ vetur.config.js # Local Netlify folder -.netlify +.netlify \ No newline at end of file diff --git a/README.md b/README.md index 4e835db25..2ed33f01b 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,9 @@ In a future version, we plan to address this by routing ETH and token contributi - [Running clr.fund instance](docs/admin.md) - [Providing matching funds](docs/funding-source.md) -- [How to tally votes and verify results](docs/tally-verify.md) +- [How to tally votes](docs/coordinator.md) +- [How to verify results](docs/trusted-setup.md) - [Running the subgraph](docs/subgraph.md) -- [Sitemap](docs/sitemap.md) -- [Website theme and customization](docs/theme.md) - [Deployment](docs/deployment.md) ## Development diff --git a/contracts/.env.example b/contracts/.env.example index 8d6b37a9c..c3d5100d8 100644 --- a/contracts/.env.example +++ b/contracts/.env.example @@ -1,5 +1,5 @@ # Recipient registry type for local deployment: simple, optimistic -RECIPIENT_REGISTRY_TYPE=optimistic +RECIPIENT_REGISTRY_TYPE=simple # Supported values: simple, brightid USER_REGISTRY_TYPE=simple @@ -9,7 +9,7 @@ BRIGHTID_CONTEXT=clr.fund BRIGHTID_VERIFIER_ADDR=0xb1d71F62bEe34E9Fc349234C201090c33BCdF6DB # JSON-RPC endpoint to the selected network -JSONRPC_HTTP_URL=https://eth-goerli.alchemyapi.io/v2/ADD_API_KEY +JSONRPC_HTTP_URL=https://eth-rinkeby.alchemyapi.io/v2/ADD_API_KEY # One of the two options WALLET_MNEMONIC= @@ -22,4 +22,4 @@ NATIVE_TOKEN_ADDRESS= FACTORY_ADDRESS= ROUND_ADDRESS= COORDINATOR_PK= -COORDINATOR_ETH_PK= +COORDINATOR_ETH_PK= \ No newline at end of file diff --git a/contracts/contracts/FundingRoundFactory.sol b/contracts/contracts/FundingRoundFactory.sol index f2a9042d5..1cb27e1a3 100644 --- a/contracts/contracts/FundingRoundFactory.sol +++ b/contracts/contracts/FundingRoundFactory.sol @@ -32,7 +32,7 @@ contract FundingRoundFactory is Ownable, MACISharedObjs { PubKey public coordinatorPubKey; EnumerableSet.AddressSet private fundingSources; - FundingRound[] public rounds; + FundingRound[] private rounds; // Events event FundingSourceAdded(address _source); diff --git a/contracts/contracts/recipientRegistry/OptimisticRecipientRegistry.sol b/contracts/contracts/recipientRegistry/OptimisticRecipientRegistry.sol index 9b479ebf3..e0a620483 100644 --- a/contracts/contracts/recipientRegistry/OptimisticRecipientRegistry.sol +++ b/contracts/contracts/recipientRegistry/OptimisticRecipientRegistry.sol @@ -177,16 +177,11 @@ contract OptimisticRecipientRegistry is Ownable, BaseRecipientRegistry { */ function executeRequest(bytes32 _recipientId) external + onlyOwner returns (bool) { Request memory request = requests[_recipientId]; require(request.submissionTime != 0, 'RecipientRegistry: Request does not exist'); - if (msg.sender != owner()) { - require( - block.timestamp - request.submissionTime >= challengePeriodDuration, - 'RecipientRegistry: Challenge period is not over' - ); - } uint256 recipientIndex = 0; if (request.requestType == RequestType.Removal) { _removeRecipient(_recipientId); diff --git a/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifier32Batch16.sol b/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifier32Batch16.sol new file mode 100644 index 000000000..7450710a4 --- /dev/null +++ b/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifier32Batch16.sol @@ -0,0 +1,270 @@ +// SPDX-License-Identifier: MIT + +// Copyright 2017 Christian Reitwiessner +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +// 2019 OKIMS + +pragma solidity ^0.6.12; + +library Pairing { + + uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + + struct G1Point { + uint256 X; + uint256 Y; + } + + // Encoding of field elements is: X[0] * z + X[1] + struct G2Point { + uint256[2] X; + uint256[2] Y; + } + + /* + * @return The negation of p, i.e. p.plus(p.negate()) should be zero. + */ + function negate(G1Point memory p) internal pure returns (G1Point memory) { + + // The prime q in the base field F_q for G1 + if (p.X == 0 && p.Y == 0) { + return G1Point(0, 0); + } else { + return G1Point(p.X, PRIME_Q - (p.Y % PRIME_Q)); + } + } + + /* + * @return The sum of two points of G1 + */ + function plus( + G1Point memory p1, + G1Point memory p2 + ) internal view returns (G1Point memory r) { + + uint256[4] memory input; + input[0] = p1.X; + input[1] = p1.Y; + input[2] = p2.X; + input[3] = p2.Y; + bool success; + + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + + require(success,"pairing-add-failed"); + } + + /* + * @return The product of a point on G1 and a scalar, i.e. + * p == p.scalar_mul(1) and p.plus(p) == p.scalar_mul(2) for all + * points p. + */ + function scalar_mul(G1Point memory p, uint256 s) internal view returns (G1Point memory r) { + + uint256[3] memory input; + input[0] = p.X; + input[1] = p.Y; + input[2] = s; + bool success; + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + require (success,"pairing-mul-failed"); + } + + /* @return The result of computing the pairing check + * e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 + * For example, + * pairing([P1(), P1().negate()], [P2(), P2()]) should return true. + */ + function pairing( + G1Point memory a1, + G2Point memory a2, + G1Point memory b1, + G2Point memory b2, + G1Point memory c1, + G2Point memory c2, + G1Point memory d1, + G2Point memory d2 + ) internal view returns (bool) { + + G1Point[4] memory p1 = [a1, b1, c1, d1]; + G2Point[4] memory p2 = [a2, b2, c2, d2]; + + uint256 inputSize = 24; + uint256[] memory input = new uint256[](inputSize); + + for (uint256 i = 0; i < 4; i++) { + uint256 j = i * 6; + input[j + 0] = p1[i].X; + input[j + 1] = p1[i].Y; + input[j + 2] = p2[i].X[0]; + input[j + 3] = p2[i].X[1]; + input[j + 4] = p2[i].Y[0]; + input[j + 5] = p2[i].Y[1]; + } + + uint256[1] memory out; + bool success; + + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + + require(success,"pairing-opcode-failed"); + + return out[0] != 0; + } +} + +contract BatchUpdateStateTreeVerifier32Batch16 { + + using Pairing for *; + + uint256 constant SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617; + uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + + struct VerifyingKey { + Pairing.G1Point alpha1; + Pairing.G2Point beta2; + Pairing.G2Point gamma2; + Pairing.G2Point delta2; + Pairing.G1Point[41] IC; + } + + struct Proof { + Pairing.G1Point A; + Pairing.G2Point B; + Pairing.G1Point C; + } + + function verifyingKey() internal pure returns (VerifyingKey memory vk) { + vk.alpha1 = Pairing.G1Point(uint256(17564466972987208178905070198019717960990774560424996549632340406571921270135),uint256(6212564911154525198736769572109918484573926992228075175561121911305420747892)); + vk.beta2 = Pairing.G2Point([uint256(19862806046850266517918019458699375042492414007810580051130360096409146797114),uint256(18968182867766566527308258731979440721408347503223170931357675093063900018998)], [uint256(15869963506744343382954688098759615756353669448820636651988694593208220260541),uint256(17415631041899920918759548249552784090262638044632769170520738845364398275366)]); + vk.gamma2 = Pairing.G2Point([uint256(11257253160245273080869306676658832074325489738113181602057846648381137371076),uint256(397473356291690562654977459050659929392435262209846402221339197403868900174)], [uint256(15964627439216663086041856051177544908720747472786343019771626700991693030486),uint256(6022076246583820501204467975945998225634462297953032723555607903078152261782)]); + vk.delta2 = Pairing.G2Point([uint256(8960304480954470322423292821010723559000712087743155784344677845709031842356),uint256(4733214216315583653992596764777849980658452927149554703439675897776902590030)], [uint256(5883145061333084001583838147325844327393273269643138829803996465957380959561),uint256(6556416943678009124760019244975816690522642072024061675141905579498114037881)]); + vk.IC[0] = Pairing.G1Point(uint256(20573688474783321846811030145444435978946625455817040976400110171429717762313),uint256(14219795410675122323711179893760742300342532333476317858787056167262160908937)); + vk.IC[1] = Pairing.G1Point(uint256(16042051692957428703650515029444172293895511179110788253133560310150814316357),uint256(17413331071024005080031335036071091790041478145914042688818908877361537279793)); + vk.IC[2] = Pairing.G1Point(uint256(4469309738798192251990686173604159186219995479238540395764540658446930749145),uint256(11574488575927551819587207552625323277821402181373682396813667332531657122576)); + vk.IC[3] = Pairing.G1Point(uint256(13663215469207902744973802514353956563905823199937005483772920223690579405487),uint256(14871215385058895610722549990927147904343728800816746147041918066710584226713)); + vk.IC[4] = Pairing.G1Point(uint256(3489292745098913386172335587317749246980343597777688754173176571645664598569),uint256(16900666770697929965250780969454193347188841711403509395696012994572983674828)); + vk.IC[5] = Pairing.G1Point(uint256(2945290910588501179672392707111211440991551718469541150674976815500282424963),uint256(14598879565524130705374188049646292346600280808118113951050422637050501514200)); + vk.IC[6] = Pairing.G1Point(uint256(1743907228984471502641556290643648078257956018892523942117108222472161514139),uint256(13546457107687734244831126558572113644917121420356142865411127965095244393366)); + vk.IC[7] = Pairing.G1Point(uint256(16239926623460462478853653011219290924924349984217262572113572728526722183948),uint256(6389572798636712055906110008459033979858910590912048163453532204275624832591)); + vk.IC[8] = Pairing.G1Point(uint256(4530655587139374397780646343900207609123290875354646335164468398273552121272),uint256(14128028354444670871720348761393076419788117867224991521747385291768930733900)); + vk.IC[9] = Pairing.G1Point(uint256(2084130186412291868004808742213302933245412886080440295285131766970403857381),uint256(13804644315777078738867680048258647864123013819623348345307968440653417669189)); + vk.IC[10] = Pairing.G1Point(uint256(18709486436861021941485824601602744556543964540298118932107637038300041246452),uint256(6227388549172304522473912467840752177496736905518667301640567961284075418436)); + vk.IC[11] = Pairing.G1Point(uint256(19122006749333320301608897562376816558619150023714623953742504350126075003788),uint256(1363782165044296870545293244929009318232323707960615856401281654383175898692)); + vk.IC[12] = Pairing.G1Point(uint256(5364413641687847338151532060627376981772485264434472923538886778626702553325),uint256(15629906454889243991306438607174696870420819153196924767318221349043732920137)); + vk.IC[13] = Pairing.G1Point(uint256(359121925809342098662374393566383044710271325511783297443508988005252057893),uint256(10811152193314929697376755563378270957694626213124806939092423550685049711334)); + vk.IC[14] = Pairing.G1Point(uint256(17981051144466785906880479913215952997275376146299543204378412051670626574122),uint256(9186797238560565226322431760068041435141486516483393586811312602762508934600)); + vk.IC[15] = Pairing.G1Point(uint256(6365374263154884818000869700803640946567044106549610402459455159852388744718),uint256(11797546156554134645751011447880999714231910885220716843380510034965755651040)); + vk.IC[16] = Pairing.G1Point(uint256(10032451025857463031715146956483534885580387223837889532345041361533387806339),uint256(3387493870558732227389076524589538808644245211636504330892809177455235677785)); + vk.IC[17] = Pairing.G1Point(uint256(2410612158467426620067995137390208949985066150538147153449069937898731808572),uint256(18521287304374984854388998234185412497698792859563570797864631992955274102818)); + vk.IC[18] = Pairing.G1Point(uint256(1813841176463493988104135613769097659002362073379920872551589566744485729425),uint256(6358940015006101246169889831008910886341927609866160536081376191976735620689)); + vk.IC[19] = Pairing.G1Point(uint256(19847081327301917802071509303149389020431564544248328496360668988278832485136),uint256(5211553418968503163058788485400452950515983724722138311061753467468280712633)); + vk.IC[20] = Pairing.G1Point(uint256(3426067802106052552538239688068111098552336356878690064196584551340276343362),uint256(16164134703700162701548772292563817322744059513730556911486018167068452826168)); + vk.IC[21] = Pairing.G1Point(uint256(8668312818069908501493412489204108759565349640063306306478085197244829974013),uint256(13810982784687518301385299461854703917878448472895644674481777667257255651320)); + vk.IC[22] = Pairing.G1Point(uint256(981077468077602291838374553840063429865380290334026656328300299263444718358),uint256(9119368190311983873098621061906337470424090352798797307268722991397740756160)); + vk.IC[23] = Pairing.G1Point(uint256(12527168323265871598354886691498363541846438222537709625367385945449773211746),uint256(2917118573022600221023372381853434922615408196327449576428539574935065403243)); + vk.IC[24] = Pairing.G1Point(uint256(10930278986094694298133371790221234279985134460531943692403668317610232742941),uint256(5862695788973409172672967320590899199162083486531717036727412479032235988065)); + vk.IC[25] = Pairing.G1Point(uint256(19143840440293111384177720404724681785293925298123626495518125552351038037165),uint256(7856520125014358900158196027676468930009418746941329024543565879388665656381)); + vk.IC[26] = Pairing.G1Point(uint256(6775239578044551661567862976069748513078619995670391427056172891956633265071),uint256(9284560981899345091778250628921565052467457991819815198504467006412459015751)); + vk.IC[27] = Pairing.G1Point(uint256(5437988353950279901669028370215493448328043979559724253975191086761262229143),uint256(8176067762582906031719418628593932629618591280530549530843556225763407224284)); + vk.IC[28] = Pairing.G1Point(uint256(14419631426965159557658781212186643724248390035688706768554749807493869120240),uint256(20829049296989859000251091454357109695901711580992440150395839575453171214015)); + vk.IC[29] = Pairing.G1Point(uint256(19608141634472932940433918240261639952962553934341785939122543569039402409141),uint256(13202356373118919099990439264234752617330284072473003408798579312466654945225)); + vk.IC[30] = Pairing.G1Point(uint256(6721446556587383910935961059312054388432394977522853801119708229959202737436),uint256(18874416278004109801516351556023467746164986339155152231450545308976800785800)); + vk.IC[31] = Pairing.G1Point(uint256(1121297910398623972014321595193328729838277331998467353747864490201136608978),uint256(5479532420089283113354607976800616803141032716983446523858749471234109786252)); + vk.IC[32] = Pairing.G1Point(uint256(467086760777282035652878041333579903278580939332416688170241256808993547575),uint256(13756152367683309448429375410787943224591772034678008033485038211776826923105)); + vk.IC[33] = Pairing.G1Point(uint256(544588907891071733780736623354853251736286846455666159919529736335009172121),uint256(19814174389629121597516552220557392671724772880943104553900974211505364673700)); + vk.IC[34] = Pairing.G1Point(uint256(9718043170262637281912309305033913756397788551277481886761502969350964449209),uint256(9928286376606476192337438359582609228172024954515187888460390683064495863566)); + vk.IC[35] = Pairing.G1Point(uint256(8833241059924366760602716054754193491983227264165402284693696886993482375792),uint256(20217437076969561492960066126914621838511190476542843609181381577334240082262)); + vk.IC[36] = Pairing.G1Point(uint256(21691301249544308137330827386088690246733997944828733953042133363071032775561),uint256(8416731669909969552797133391600423980357220150298256151928192993549593014572)); + vk.IC[37] = Pairing.G1Point(uint256(18591239855619987960480421772799014085639022706413599497355173036346631326229),uint256(19557170727169515145077122571593152129100237734331890620470088472162864118761)); + vk.IC[38] = Pairing.G1Point(uint256(3862906872967117807500943404548237031139970973065025611287515004824373974308),uint256(14763824391416574387650349848092354763656539119581187921054485482268328744531)); + vk.IC[39] = Pairing.G1Point(uint256(4581382328791187996308811405974001991040756459205750759173122039179987836596),uint256(14577738635095065315453864617647694757772478953718921634232796382928686688380)); + vk.IC[40] = Pairing.G1Point(uint256(17187231740479352852864198251137151477227537702159385928600612471898233918627),uint256(835160958364646681144544132626099284400020971025799680904837349622297335830)); + + } + + /* + * @returns Whether the proof is valid given the hardcoded verifying key + * above and the public inputs + */ + function verifyProof( + uint256[2] memory a, + uint256[2][2] memory b, + uint256[2] memory c, + uint256[] memory input + ) public view returns (bool) { + + Proof memory proof; + proof.A = Pairing.G1Point(a[0], a[1]); + proof.B = Pairing.G2Point([b[0][0], b[0][1]], [b[1][0], b[1][1]]); + proof.C = Pairing.G1Point(c[0], c[1]); + + VerifyingKey memory vk = verifyingKey(); + + // Compute the linear combination vk_x + Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); + + // Make sure that proof.A, B, and C are each less than the prime q + require(proof.A.X < PRIME_Q, "verifier-aX-gte-prime-q"); + require(proof.A.Y < PRIME_Q, "verifier-aY-gte-prime-q"); + + require(proof.B.X[0] < PRIME_Q, "verifier-bX0-gte-prime-q"); + require(proof.B.Y[0] < PRIME_Q, "verifier-bY0-gte-prime-q"); + + require(proof.B.X[1] < PRIME_Q, "verifier-bX1-gte-prime-q"); + require(proof.B.Y[1] < PRIME_Q, "verifier-bY1-gte-prime-q"); + + require(proof.C.X < PRIME_Q, "verifier-cX-gte-prime-q"); + require(proof.C.Y < PRIME_Q, "verifier-cY-gte-prime-q"); + + // Make sure that every input is less than the snark scalar field + //for (uint256 i = 0; i < input.length; i++) { + for (uint256 i = 0; i < 40; i++) { + require(input[i] < SNARK_SCALAR_FIELD,"verifier-gte-snark-scalar-field"); + vk_x = Pairing.plus(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i])); + } + + vk_x = Pairing.plus(vk_x, vk.IC[0]); + + return Pairing.pairing( + Pairing.negate(proof.A), + proof.B, + vk.alpha1, + vk.beta2, + vk_x, + vk.gamma2, + proof.C, + vk.delta2 + ); + } +} diff --git a/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifierBatch64.sol b/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifierBatch64.sol deleted file mode 100644 index a6d6f798a..000000000 --- a/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifierBatch64.sol +++ /dev/null @@ -1,366 +0,0 @@ -// SPDX-License-Identifier: MIT - -// Copyright 2017 Christian Reitwiessner -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. - -// 2019 OKIMS - -pragma solidity ^0.6.12; - -library Pairing { - - uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; - - struct G1Point { - uint256 X; - uint256 Y; - } - - // Encoding of field elements is: X[0] * z + X[1] - struct G2Point { - uint256[2] X; - uint256[2] Y; - } - - /* - * @return The negation of p, i.e. p.plus(p.negate()) should be zero. - */ - function negate(G1Point memory p) internal pure returns (G1Point memory) { - - // The prime q in the base field F_q for G1 - if (p.X == 0 && p.Y == 0) { - return G1Point(0, 0); - } else { - return G1Point(p.X, PRIME_Q - (p.Y % PRIME_Q)); - } - } - - /* - * @return The sum of two points of G1 - */ - function plus( - G1Point memory p1, - G1Point memory p2 - ) internal view returns (G1Point memory r) { - - uint256[4] memory input; - input[0] = p1.X; - input[1] = p1.Y; - input[2] = p2.X; - input[3] = p2.Y; - bool success; - - // solium-disable-next-line security/no-inline-assembly - assembly { - success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60) - // Use "invalid" to make gas estimation work - switch success case 0 { invalid() } - } - - require(success,"pairing-add-failed"); - } - - /* - * @return The product of a point on G1 and a scalar, i.e. - * p == p.scalar_mul(1) and p.plus(p) == p.scalar_mul(2) for all - * points p. - */ - function scalar_mul(G1Point memory p, uint256 s) internal view returns (G1Point memory r) { - - uint256[3] memory input; - input[0] = p.X; - input[1] = p.Y; - input[2] = s; - bool success; - // solium-disable-next-line security/no-inline-assembly - assembly { - success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60) - // Use "invalid" to make gas estimation work - switch success case 0 { invalid() } - } - require (success,"pairing-mul-failed"); - } - - /* @return The result of computing the pairing check - * e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 - * For example, - * pairing([P1(), P1().negate()], [P2(), P2()]) should return true. - */ - function pairing( - G1Point memory a1, - G2Point memory a2, - G1Point memory b1, - G2Point memory b2, - G1Point memory c1, - G2Point memory c2, - G1Point memory d1, - G2Point memory d2 - ) internal view returns (bool) { - - G1Point[4] memory p1 = [a1, b1, c1, d1]; - G2Point[4] memory p2 = [a2, b2, c2, d2]; - - uint256 inputSize = 24; - uint256[] memory input = new uint256[](inputSize); - - for (uint256 i = 0; i < 4; i++) { - uint256 j = i * 6; - input[j + 0] = p1[i].X; - input[j + 1] = p1[i].Y; - input[j + 2] = p2[i].X[0]; - input[j + 3] = p2[i].X[1]; - input[j + 4] = p2[i].Y[0]; - input[j + 5] = p2[i].Y[1]; - } - - uint256[1] memory out; - bool success; - - // solium-disable-next-line security/no-inline-assembly - assembly { - success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) - // Use "invalid" to make gas estimation work - switch success case 0 { invalid() } - } - - require(success,"pairing-opcode-failed"); - - return out[0] != 0; - } -} - -contract BatchUpdateStateTreeVerifierBatch64 { - - using Pairing for *; - - uint256 constant SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617; - uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; - - struct VerifyingKey { - Pairing.G1Point alpha1; - Pairing.G2Point beta2; - Pairing.G2Point gamma2; - Pairing.G2Point delta2; - Pairing.G1Point[137] IC; - } - - struct Proof { - Pairing.G1Point A; - Pairing.G2Point B; - Pairing.G1Point C; - } - - function verifyingKey() internal pure returns (VerifyingKey memory vk) { - vk.alpha1 = Pairing.G1Point(uint256(20111080972059956339770330822842174014028834762406291931369219466654304651947),uint256(12617701555281079140502645308327272670695003907823882015559302949283468652265)); - vk.beta2 = Pairing.G2Point([uint256(13542344348353495181403994427087825307359707135045861990032896341194354804027),uint256(21495413117026630692390948489284050783642854854611941789985830749278288076019)], [uint256(14506113082745454888160012508724679162141302039154827891210912565820929074277),uint256(3350288264585300535086052300399402169962936857002440578169769772249674537321)]); - vk.gamma2 = Pairing.G2Point([uint256(1405893342850909592901993047116357102257777845904120854072918797353322262004),uint256(19039671411780007398709575658966632348032959209903650830372041924458096901884)], [uint256(10246278299067469558430169227798852211761712958408139619453971385803508820401),uint256(15610397642216218497160132307603098145221061848302396069439857040941724165478)]); - vk.delta2 = Pairing.G2Point([uint256(218449558449230811211684913120166693986265997555702745202050296498830988537),uint256(5407412409774150903042787049136199519480710038481547450708858944052764255898)], [uint256(11041661707049238194800418097140585648833245776885036685698406508603026023618),uint256(133760400102501241432017477738575766306011192481736590344059611691663304908)]); - vk.IC[0] = Pairing.G1Point(uint256(21154028465075083712658841897667003802526258215567114307761064418376815086215),uint256(1508603373580985357750185712435454283342822243681375102146040323901851882861)); - vk.IC[1] = Pairing.G1Point(uint256(17138670918452087442204333646184278115264761559617238017915185098227172982811),uint256(5611082957038412360589088211229082874946611618574538759210306439661299176945)); - vk.IC[2] = Pairing.G1Point(uint256(15390062030817469858239962767688560984963862923150691651695470714836749513537),uint256(2326278356592104332893498078974085120183205776960952327317801670322144268312)); - vk.IC[3] = Pairing.G1Point(uint256(670502483544788577495533106037306685680302193138027386568284657638217305162),uint256(13899932709234250089113138746199887493989716128773617251114173979406178685854)); - vk.IC[4] = Pairing.G1Point(uint256(1668858581160068229751170422086552283069112892923284875458714097455940271060),uint256(10963928549779385078551207286148560603493064860855479456777796037752746438821)); - vk.IC[5] = Pairing.G1Point(uint256(14443949715331357106440648501127551284419877012742935773796450280993895557950),uint256(7327092816369746696069608426307677295251675492358792703722654814347910670799)); - vk.IC[6] = Pairing.G1Point(uint256(5195131423503819493553434036524142715087086191307960034902232416510656885185),uint256(12954097701521836361385154063939800867915572539231767504727206187028067060316)); - vk.IC[7] = Pairing.G1Point(uint256(5014496811794396976665624820671057271105624005885691507118903143762222055653),uint256(2439861537398184499213246384674917439703377312852628599682703382994166713105)); - vk.IC[8] = Pairing.G1Point(uint256(4283779997045552072886989647120873562506891397517893101552024394063778228179),uint256(6797444259192627688173655690751340206418239290444353902720624326561114110758)); - vk.IC[9] = Pairing.G1Point(uint256(1764526698812192069022588686170356509360022164888258513593936487059961066941),uint256(17009662947771196235743594446075866146647869480629555603040823675969643779051)); - vk.IC[10] = Pairing.G1Point(uint256(4634044914106045971667518785339036534014121178220843446289537005542492308535),uint256(15546587576688521479105738976327958863746365837253142983784091540880955579980)); - vk.IC[11] = Pairing.G1Point(uint256(2715687604695872089734177102456674874291540185351660893793943298723076162023),uint256(8175293297644947591266018188895500373877148851930870966940114884237467841513)); - vk.IC[12] = Pairing.G1Point(uint256(20121655344011849412536946281011930004933787724346969597015929984774157832582),uint256(21105616102575587428032100019159228354467439290237984300855255375809452861700)); - vk.IC[13] = Pairing.G1Point(uint256(12196403456413067372907894607228547021168026355185769152640581456011640908115),uint256(21407951242918884928699901097047515520528209072349143202832003101963003432617)); - vk.IC[14] = Pairing.G1Point(uint256(5310579898763467707257750843874466287781776312027753089568037427631501300785),uint256(13656390395313566507812604343352575249308212454341840895399980715808616168680)); - vk.IC[15] = Pairing.G1Point(uint256(5228663941897766588851959590652190955458180715181587426615826411725401946424),uint256(17071465706070749339990865138715666296514424588111537608363813692692990940366)); - vk.IC[16] = Pairing.G1Point(uint256(21392686683745202445405791550348258910214506132555422218147448100798518012624),uint256(19973818140995305279304988251723192392522267302457604906450941473549909206005)); - vk.IC[17] = Pairing.G1Point(uint256(15195347567926738961665396600441664048946386695266635762683008484732412196206),uint256(5443504796488635873491333526101509884793241238220915769454608984351813705352)); - vk.IC[18] = Pairing.G1Point(uint256(507648814511001940181794192328810194158207104111469073500188579284369879392),uint256(19878164414562305196590521861798978690302638328953743153865298948302940844681)); - vk.IC[19] = Pairing.G1Point(uint256(7804204219955298169106734572698710394497148749473703625951731300392649704154),uint256(20749617701130874929367317738562309195716127925605185086004583710327959048427)); - vk.IC[20] = Pairing.G1Point(uint256(4136423452244920542789285713474930233560780284858790342002681682013099183779),uint256(9973148020780206454495393084156055095162709960047565170525379600003193810062)); - vk.IC[21] = Pairing.G1Point(uint256(7431606657645725193952573841697636390810591901046924605499097775346387992290),uint256(5564038490812252127842883537078377994942518033402640280384493207800949173851)); - vk.IC[22] = Pairing.G1Point(uint256(15626975527875622140792987711825573705920791436147184958617981173929107303657),uint256(14502833020345145695691362402464485762891674236180321493138116694907998011)); - vk.IC[23] = Pairing.G1Point(uint256(12878936960170927766371526382844902588843389976321318914661478214677770790248),uint256(5876460520718282533702520524897969113039507901531034929557462309166868606822)); - vk.IC[24] = Pairing.G1Point(uint256(16206306303565793121727450649844616805570868789440368125097120703656428468197),uint256(21466131705360086522427463180380688685767570787253803257228497277582175527492)); - vk.IC[25] = Pairing.G1Point(uint256(21415591897257783503862369405185488044149515290857177493989651919054569685198),uint256(19111807106136759041568303560519102945559357726442697071460970763574722828826)); - vk.IC[26] = Pairing.G1Point(uint256(18597076716458443423413289916997990176080742981245463826800606445425301059259),uint256(7848662551744864770963244474671513926512950753742401298459761273493739794876)); - vk.IC[27] = Pairing.G1Point(uint256(13478058920612073343883464152893321390311200483920696440656727524055057501695),uint256(1141484237022293981977393567736173116561183466681305710973251196757434813744)); - vk.IC[28] = Pairing.G1Point(uint256(15769077441619055970381886505780732308249815547683508143977406021029452872552),uint256(11041176207552285494760896858611142356090292881145533908058442986708927140068)); - vk.IC[29] = Pairing.G1Point(uint256(6317204961991307505110367333461546493002130407088713977697365919648289809555),uint256(16485259080552904056112526579040492506588962838309100629831761305228011180668)); - vk.IC[30] = Pairing.G1Point(uint256(4257110455950153652298535845399920474497037031925464616890886837426603419588),uint256(11872545793699592767799719701047416357370472440569693263077615092286272478514)); - vk.IC[31] = Pairing.G1Point(uint256(6961807017167071724371454268303022052413314092826667739692730740465087447637),uint256(3548416379898170774979179836877281134673281973630993406136692598268193428615)); - vk.IC[32] = Pairing.G1Point(uint256(21126159292924936794341610841149549910479950100575700253425887185534804026911),uint256(9665356991799845435109808741455357929036550119689810467582994476043039656375)); - vk.IC[33] = Pairing.G1Point(uint256(4126555849352009875773383333602810568818670985786945593706220065006276506699),uint256(13389907085387505200515368697127009874021544752954888239558364644026308267105)); - vk.IC[34] = Pairing.G1Point(uint256(9237247460110549033997472057018612356175421663903706416565822025921474348482),uint256(12479126715944469540020905209065301961586449718316255995034034427944451434840)); - vk.IC[35] = Pairing.G1Point(uint256(141999452778411753111875715249603444123023422502137319587911822280155648959),uint256(1953125230366380735124086773077985745995946475601777124731379373291524377234)); - vk.IC[36] = Pairing.G1Point(uint256(11781645780818495939618015750292991736294631437879209396450605477900247000129),uint256(10427776284156614685231665682387604681177186710015159262013630828614428971274)); - vk.IC[37] = Pairing.G1Point(uint256(7320842327404510671561729460506495430535413853828849843449519029765075554813),uint256(21672549045605752785173249488145571339262757812277123222081715504950345316114)); - vk.IC[38] = Pairing.G1Point(uint256(15843737739485817496811128063605940139111457287880259830761212263801078571298),uint256(18242013210254730973873870903453729710621046943883887111042684248588571061847)); - vk.IC[39] = Pairing.G1Point(uint256(20016595100062158316451938534243252321996797777010650604387061069048405385417),uint256(20993637865430287538984233040285431558951614830256982679897124168312952630939)); - vk.IC[40] = Pairing.G1Point(uint256(15334716930997133577306970429209161911742529260933017908277231237452607330821),uint256(685388011722901396424928778072393449123264587481808881182825804771090518383)); - vk.IC[41] = Pairing.G1Point(uint256(1303572165860930120284335343212677918045902191683549658721438126058571397640),uint256(13905311908068188694433787916547614635591226084525428070472134336893399093746)); - vk.IC[42] = Pairing.G1Point(uint256(14221300826968969082380487511562669771162038931016459790783016554828539071028),uint256(3793753201377522263643616048114341014139606587430774642745359231545618520074)); - vk.IC[43] = Pairing.G1Point(uint256(11832772449848274783470280628809411265387468482258558389852767954678108547210),uint256(14834860013882731405618722640186796344077421236283342428469907998531860454177)); - vk.IC[44] = Pairing.G1Point(uint256(17639041462588987659575385363021668478220589429834850328037158110389078883040),uint256(8704969675351836770098849680526710356004509474160008874237661643718531775648)); - vk.IC[45] = Pairing.G1Point(uint256(5300669047095411489879499682325147800890453538028385356237349525690882478918),uint256(15807078216435200960341268208073744792548344803921008654764854111918279022000)); - vk.IC[46] = Pairing.G1Point(uint256(16759701479370137632714483158195271493447455620368412483284976632032643763769),uint256(12119578575407359446677894550708029309579098640507319654992119663517978340030)); - vk.IC[47] = Pairing.G1Point(uint256(3546618055876451624271770844642081662395644632532568159350978635181892288450),uint256(7899711169092095967606908624829171809878683672403689963659422259393482150720)); - vk.IC[48] = Pairing.G1Point(uint256(12510986215555297660829149639903728729881090196649895701627872388148718275015),uint256(17938310289008954981347264094252860622099244536932534849229515962756808374025)); - vk.IC[49] = Pairing.G1Point(uint256(10409103229107940165748369566396677252139728324786456864640963494010260668235),uint256(12208504036723332249430584763478241147278778517031072962335060653268740832434)); - vk.IC[50] = Pairing.G1Point(uint256(19078937359506343330527168061276270611841567433397448629987841881566543425430),uint256(11481500418047012282975132773342910097993984928448563097150924565336610666536)); - vk.IC[51] = Pairing.G1Point(uint256(5668164983048179781866248655288808464925703406969538833351186308137830654277),uint256(2036685125881168735638155303624535536249217225379298881837967911494254746186)); - vk.IC[52] = Pairing.G1Point(uint256(10582885345920107024694752542268339630454841905176111334219464927407148285571),uint256(5302511072101913226528212309612354576738191518686848766232770054248911296133)); - vk.IC[53] = Pairing.G1Point(uint256(10763456976681834643711799449282626018019885337204621884611514607700042818803),uint256(2301609750924291463999855717400419535128299260641718628700547785424597102453)); - vk.IC[54] = Pairing.G1Point(uint256(14090175978138869104232840539484119022774252145335173930783246809099832962316),uint256(6221349702045432514870976695635674962728125885258176729129488888732828800410)); - vk.IC[55] = Pairing.G1Point(uint256(12979553571150817138420948789020393806894793915531144444421859462533374052099),uint256(19200617597505760330609395924204780472385656815449526965159307707620566764859)); - vk.IC[56] = Pairing.G1Point(uint256(17463292323109723850032883884721435618399847208181626612913544509828940781241),uint256(4640330488095610287297321719298782385410932546586616186092407400139615590090)); - vk.IC[57] = Pairing.G1Point(uint256(5026751021136652956884280623386725977584562160860216981445937597176863849153),uint256(3726806205455462506192306538007629772202324302040678177248736103409118613785)); - vk.IC[58] = Pairing.G1Point(uint256(10401634702025754926410545975890506063988215551615820658203094591849811159631),uint256(18749829455441645964781375179927225016584277575687706948231860700748733027052)); - vk.IC[59] = Pairing.G1Point(uint256(8900544578516002654755404382821090990852948336443604263092346279560463093021),uint256(18006601535750985461327662670949981534033907644968069359180602924268163004324)); - vk.IC[60] = Pairing.G1Point(uint256(4923009907077112126720542234146116224672392899835836662687070218433373705722),uint256(18423757328042105778787925090173086548101110659746089450844654256764118325601)); - vk.IC[61] = Pairing.G1Point(uint256(8496765642282856203983699155346261739858072134636611403990649857712160055778),uint256(4388334225743601326859195830073286369325699325286991437221049420432654092953)); - vk.IC[62] = Pairing.G1Point(uint256(6814778709224790817106591651987195100179673979164667477931063958497939427212),uint256(202848748206250811388580708835503713707654793206461021686825244651622264039)); - vk.IC[63] = Pairing.G1Point(uint256(9712073020664581454703761893278579101940468173428050353979543473165772895683),uint256(16040831046435892825035903107855958297938152758905062284792692747629553256707)); - vk.IC[64] = Pairing.G1Point(uint256(464285856079964863337668128884110751354784252445460337726538919141766442307),uint256(18298744009556568810538541912213974993321803850681854903651969678496784694111)); - vk.IC[65] = Pairing.G1Point(uint256(1095197435643971555064350556393021336605395355065960270057589173461184696337),uint256(2371995713846161841708775649454592609278907116185770018881555739791203555532)); - vk.IC[66] = Pairing.G1Point(uint256(21496449855100960838766768514830510452996823088263015662455987171227339154387),uint256(579596441272302995884967634501598678761512973483058268484496798383540310589)); - vk.IC[67] = Pairing.G1Point(uint256(18887705942025081976221623747494259379053007766953067407121210914692251976307),uint256(19263616461960262551559783019847173689300250342438900318562000334791634717184)); - vk.IC[68] = Pairing.G1Point(uint256(14716293115883307245092089544318348512298862035942865682986124416102553587746),uint256(13407174783655301681566217843988935740396704279597545147247198530403440438542)); - vk.IC[69] = Pairing.G1Point(uint256(8900997157012117172770905271175132729552960821748024149989068731273061894060),uint256(18274585601658156662940484885212221657515118604751892338041379436414857450227)); - vk.IC[70] = Pairing.G1Point(uint256(12167440767111275300984212539995067770335699142323631256234615040761402805822),uint256(9075299166921376582555856072820251116892867974126953073350366964708808984910)); - vk.IC[71] = Pairing.G1Point(uint256(2059815164798909576203732646672210899587142768137518599550435283468704025507),uint256(2608153945501014126591908624616527620011162747374867493421981432572216497882)); - vk.IC[72] = Pairing.G1Point(uint256(10599096542036501024265560487895513859113363423568037524937840260694705766171),uint256(9279326687807953384658592766685984239789127905534993112158348724015076837698)); - vk.IC[73] = Pairing.G1Point(uint256(18572463152745003849804098342368124919247700243449857746217649935067065850150),uint256(4271302815739774362417719364521319242832592843797563758771516686536354433825)); - vk.IC[74] = Pairing.G1Point(uint256(20588410275488673850673340736265898273778034663881535267761168002085081885071),uint256(14214623554987678047849743210352845290635958141580656013834998776699751159828)); - vk.IC[75] = Pairing.G1Point(uint256(2163722300592233786295471708199826265491705308195110455734978794412240252082),uint256(8267508554119920340725744568125044648312324782432899548133021564673192786292)); - vk.IC[76] = Pairing.G1Point(uint256(7197484269598779655985151220872592322066489414844363451684046156382303125419),uint256(21616596691508874538973614495991415514486861395908301007359214048159264706847)); - vk.IC[77] = Pairing.G1Point(uint256(9317296188908243633506496117686166305859402226985134506599967925055807406239),uint256(9246662625993721575939009540092858167693567801636177886999030975109306100431)); - vk.IC[78] = Pairing.G1Point(uint256(13130291969164442309654135261527037484695214343744471907179891767339554237812),uint256(19439420900777819255222132111763290888110851303845997171070229099783225604353)); - vk.IC[79] = Pairing.G1Point(uint256(8341274125831103087891955418526024155350981135186426107382130311966075308341),uint256(4004611672363485155286210618830799765020486401448881276116498234644093532588)); - vk.IC[80] = Pairing.G1Point(uint256(18169731422481037799505983555963375952636041638492364150413818994301923394922),uint256(6920580573279503695945721875233103879114044960770671707600918652213055872299)); - vk.IC[81] = Pairing.G1Point(uint256(14650110447931945378950543791319356392503885786645882445700101669286085199593),uint256(2672236893363303197228993949960317801525904563326503330829870235354157424455)); - vk.IC[82] = Pairing.G1Point(uint256(2528986115564995166900493334973939997264055530799688307116832245865032633252),uint256(16154503512380645952650117479127814018462759770354166106071852796538589151508)); - vk.IC[83] = Pairing.G1Point(uint256(19481294150685092990791924103805501678815906468656811961335770799971334206204),uint256(3363598330662226286855183671247665794560445868227630426048283517520728381115)); - vk.IC[84] = Pairing.G1Point(uint256(18978808201339133091409700185663114595291545168713536752334377601075245117564),uint256(1213612765235708464178869186669487814311448260124908714497814085098588994320)); - vk.IC[85] = Pairing.G1Point(uint256(14418075925290525696668747676082112105539395074953365477412301469559858950260),uint256(4594154586437226394452076127560734363696966763267974496550853723612732151304)); - vk.IC[86] = Pairing.G1Point(uint256(15244532626961782816328729554676239130116573352299399696442635297143065136722),uint256(16264067400808255284629914138151864703503231517377905402475157542088372521552)); - vk.IC[87] = Pairing.G1Point(uint256(13412404072841706439721760404171528212883832785394223681641514970735279943894),uint256(18772972421520087602416100777493366840700406847871247779866356020537964956696)); - vk.IC[88] = Pairing.G1Point(uint256(7278518834098053866811197734898595965893448864016564932459779237303281761639),uint256(9543037822177179166761432005315104657257283894479997218038173048112648103966)); - vk.IC[89] = Pairing.G1Point(uint256(1709222636826423108574086973126513957814331116981895535842631406293849262297),uint256(4171313661071748327281373689968909626610309456777530265707325990329480802799)); - vk.IC[90] = Pairing.G1Point(uint256(15179786172976985895438656664754965437591541176657924883571685176235651293728),uint256(11638096950777001048523602013267712327098521271732859050058176904585051580899)); - vk.IC[91] = Pairing.G1Point(uint256(2407781716437481630793286485722773331260575264950391514382377514019101702961),uint256(14458695686781772302449747288128751866667294558156464499992469536004627829083)); - vk.IC[92] = Pairing.G1Point(uint256(16468694895252699887555280460041688687239148427728528952752209086050643766774),uint256(20788646394947004095604345011150936219737186787061030407112092179878706057219)); - vk.IC[93] = Pairing.G1Point(uint256(3991089774358787341484887719129638059357053872667707502370199075852626851388),uint256(3902510497519799402123711531126476360243139127161818082359557470600621147465)); - vk.IC[94] = Pairing.G1Point(uint256(1466886815147365122710697057812173142241409916115347202712031841666728491371),uint256(11081437349185659268515559439118507187272381051158242403039829784368439096334)); - vk.IC[95] = Pairing.G1Point(uint256(15675367948639125929148213270961949441292490055618970357828231434598551590204),uint256(2778909164426958617541800819922952546319291205058583128114764331756307890038)); - vk.IC[96] = Pairing.G1Point(uint256(9493824125881071996157942648835347397579068134315426656519530306969327486571),uint256(13569015783770899535131482373694228204303101581888049300595964306574568460864)); - vk.IC[97] = Pairing.G1Point(uint256(9242602532194001182855914032689535056578184961713113993929815181120862231207),uint256(6484901250930427127830138798552069220619407988056810332966942878581890583162)); - vk.IC[98] = Pairing.G1Point(uint256(1523872847727869237456921431552857964814153573520494518692099453140090587506),uint256(17418695360532982046447994094582201363152685411867522147722234353839392352963)); - vk.IC[99] = Pairing.G1Point(uint256(11399742549177078929798714912076333760007468805044120388679382257106867494165),uint256(10670133949401240696006942337972465426990736934932061421488627959980739421528)); - vk.IC[100] = Pairing.G1Point(uint256(14433470718644592947375658909140593220622114396056063069015450435001476096193),uint256(3402331349906821334617732939054219019484982686825450914946814521361485434979)); - vk.IC[101] = Pairing.G1Point(uint256(21833676945846828172148864519474394581737351469412892197765854727950456147819),uint256(7462335039361807122731055524290203689391395125357934825602744430038141690911)); - vk.IC[102] = Pairing.G1Point(uint256(210066286602533018799742236569265965239665480635234801768634128214921900378),uint256(16977879956906814285553478771463215856313874372007024525393213937911956567308)); - vk.IC[103] = Pairing.G1Point(uint256(19485406473781142572266866513249570342833693458809793171812114197067555622413),uint256(14983003204010254445281945758732583005538659082097191657565536755860705984136)); - vk.IC[104] = Pairing.G1Point(uint256(1643409554143106462161536815350340794659353923663214739221709734566068746896),uint256(11288237047349511313733592916022399013051134309999893750401178613798551720496)); - vk.IC[105] = Pairing.G1Point(uint256(5660270548866243505458641580735922840522326056308552445940776615197111838792),uint256(16533532851632707812388601246498492787400003143775487523391826146411027105771)); - vk.IC[106] = Pairing.G1Point(uint256(18747657054895962286964950383285730210515655024520661768552618132579955125115),uint256(19027238642993917589693815893442453793582302233540587165226862529468750526603)); - vk.IC[107] = Pairing.G1Point(uint256(2650826258757381691643075897762790582637910639050159702541438068052629614054),uint256(3774731589623370538734392851462470712657730891426324115255281048189285372436)); - vk.IC[108] = Pairing.G1Point(uint256(4662400107144032873395173618484459148565405388335329460947219312803233640865),uint256(8073252455973744240359587336736369228115457758316383143255777663748671850386)); - vk.IC[109] = Pairing.G1Point(uint256(13244815569763137509027845541821848396881898000645766685064481010466764272952),uint256(15522973493542306202906347506987443126632067507488219275739902568044982305697)); - vk.IC[110] = Pairing.G1Point(uint256(19749116273014997405254210700055584858311566706740802020066495391263747011588),uint256(11738555759350126374410652439691111485806802038437627641262728151255748920647)); - vk.IC[111] = Pairing.G1Point(uint256(11455436321789801029959926621468100831387257112637033043144729421294765064839),uint256(10277663761094508810186911322351958424104244917715020422247125949835571149267)); - vk.IC[112] = Pairing.G1Point(uint256(12732537264035416277851608224506324531375270159226936067760069141822919044048),uint256(16416240630658544393597970037593706089294118301617257468224946372126948974082)); - vk.IC[113] = Pairing.G1Point(uint256(10516115624793536684758243788374015086509817039690631741147324866729714618420),uint256(7281097342761181523840666064202614730291420363390735832776326394623945061814)); - vk.IC[114] = Pairing.G1Point(uint256(1902373706865446835156364162955903136789061174445568661057522144610650427069),uint256(5452659003657947834438667736032309272469975574808215759517389777040039530319)); - vk.IC[115] = Pairing.G1Point(uint256(11891140194810316547361992199254053502185941207721636377627299695075892638278),uint256(16130283882098494590042359320753560234548959693114287821736368875186436623966)); - vk.IC[116] = Pairing.G1Point(uint256(14522514398752668329215638117210177464868398724634637927944188255719495719791),uint256(3403517244273478901791556803769637205898834452903997586511432370635451167411)); - vk.IC[117] = Pairing.G1Point(uint256(5734575700530357400562096763439606095780205077210360017987438644395685957016),uint256(14336954586773900618591010892691057715838366325074462859243020677418854888386)); - vk.IC[118] = Pairing.G1Point(uint256(12945113475405829440179988254017674878359904858305320385471664828323468960215),uint256(9331695673206621682725776908309057304745443130609501436382308569434664050737)); - vk.IC[119] = Pairing.G1Point(uint256(12805183903263949727947933481510994462075090289151015632646584549911707672114),uint256(15054758166003413547242371494822609546352775865411590496523538807337930162163)); - vk.IC[120] = Pairing.G1Point(uint256(1461650666181324607934715397719669697167766930891294777923440461927270052477),uint256(19979989352259333167426847501212112161778188563489085835157314671288124368343)); - vk.IC[121] = Pairing.G1Point(uint256(11200654822846841133725824364839307380833213205471277971844423265332774024060),uint256(10238782818030344762170615817154386114792703189345414964959003512861602156265)); - vk.IC[122] = Pairing.G1Point(uint256(18744324171982470808688651814809297411690580944649636605549308210994185657270),uint256(1328654417237017417010783392800592190819703116836024667917667110819463217203)); - vk.IC[123] = Pairing.G1Point(uint256(612266599210749035013745392268833690974426686975573120141391354476146241027),uint256(7903077119396400694450206637930278212614063414142131659931620450565889229384)); - vk.IC[124] = Pairing.G1Point(uint256(12798298805836523370442542016556603769932526767799169681647656847075273744276),uint256(2999423457284549668595714800652056858584184770644989181648205538604660031710)); - vk.IC[125] = Pairing.G1Point(uint256(15562951103048198246058544397019105032195165943285808912291386560600736792878),uint256(17254303321388628569857907786894515305009188117276406287966816967851392077824)); - vk.IC[126] = Pairing.G1Point(uint256(7857905771896587186044136087414656474604671307343998508011003584850698242314),uint256(965966572394044230411443545922398510058722123750783128100264132456694748186)); - vk.IC[127] = Pairing.G1Point(uint256(6826563322944870206262950323378042094930942787115856237220092687812916923338),uint256(16997356694684541445466543668304270868828514937784717244056774581901581744501)); - vk.IC[128] = Pairing.G1Point(uint256(6916461496370818557272906066818414648287924724221672605801357595072816551227),uint256(18709969507672604061817338077692474555037780314646588254854697996453602915421)); - vk.IC[129] = Pairing.G1Point(uint256(13953856422146529357914602862431925106403810477983604430514681346184534247396),uint256(5852214220014262914689217151035149197684391482947611614040822660076949017339)); - vk.IC[130] = Pairing.G1Point(uint256(883027530876177460300657468207253106021065999640005620485264456323124773674),uint256(9645521061995659521432534479570562814747093346092082788327789703319317765640)); - vk.IC[131] = Pairing.G1Point(uint256(7682396289453340034942765191901335113671659387001278538463716593824450777179),uint256(11159553141771355181354519876188974719165136270626670989121305930207064649429)); - vk.IC[132] = Pairing.G1Point(uint256(7834352299743738961211888560865104800760657368650393621357707010227902129305),uint256(5256303466095737975531528989934871846609654422399758301358728690752178996964)); - vk.IC[133] = Pairing.G1Point(uint256(5115977327746256824998071788278199443411955778535105982357034789442747671146),uint256(5868891348240646803024539375568175374772325608896242181635723021982168546519)); - vk.IC[134] = Pairing.G1Point(uint256(18828553669800119068476997516015930097243571498795866530032170278543012797891),uint256(1286300698474334950849038692739675849219302930241092756607360829287530426744)); - vk.IC[135] = Pairing.G1Point(uint256(18655018460061098164066901184027734560881886408801867234084210199953746031888),uint256(16134600889715752130216186812644915735718850558240252492338479115835565582540)); - vk.IC[136] = Pairing.G1Point(uint256(4485659543400195319589657606363653034690372730120772385411739404388056406598),uint256(12596043386375142555047260357771861294052774830451299708187886980188757722437)); - - } - - /* - * @returns Whether the proof is valid given the hardcoded verifying key - * above and the public inputs - */ - function verifyProof( - uint256[2] memory a, - uint256[2][2] memory b, - uint256[2] memory c, - uint256[] memory input - ) public view returns (bool) { - - Proof memory proof; - proof.A = Pairing.G1Point(a[0], a[1]); - proof.B = Pairing.G2Point([b[0][0], b[0][1]], [b[1][0], b[1][1]]); - proof.C = Pairing.G1Point(c[0], c[1]); - - VerifyingKey memory vk = verifyingKey(); - - // Compute the linear combination vk_x - Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); - - // Make sure that proof.A, B, and C are each less than the prime q - require(proof.A.X < PRIME_Q, "verifier-aX-gte-prime-q"); - require(proof.A.Y < PRIME_Q, "verifier-aY-gte-prime-q"); - - require(proof.B.X[0] < PRIME_Q, "verifier-bX0-gte-prime-q"); - require(proof.B.Y[0] < PRIME_Q, "verifier-bY0-gte-prime-q"); - - require(proof.B.X[1] < PRIME_Q, "verifier-bX1-gte-prime-q"); - require(proof.B.Y[1] < PRIME_Q, "verifier-bY1-gte-prime-q"); - - require(proof.C.X < PRIME_Q, "verifier-cX-gte-prime-q"); - require(proof.C.Y < PRIME_Q, "verifier-cY-gte-prime-q"); - - // Make sure that every input is less than the snark scalar field - //for (uint256 i = 0; i < input.length; i++) { - for (uint256 i = 0; i < 136; i++) { - require(input[i] < SNARK_SCALAR_FIELD,"verifier-gte-snark-scalar-field"); - vk_x = Pairing.plus(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i])); - } - - vk_x = Pairing.plus(vk_x, vk.IC[0]); - - return Pairing.pairing( - Pairing.negate(proof.A), - proof.B, - vk.alpha1, - vk.beta2, - vk_x, - vk.gamma2, - proof.C, - vk.delta2 - ); - } -} diff --git a/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifierCustom.sol b/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifierCustom.sol new file mode 100644 index 000000000..48ce34bcd --- /dev/null +++ b/contracts/contracts/snarkVerifiers/BatchUpdateStateTreeVerifierCustom.sol @@ -0,0 +1,366 @@ +// SPDX-License-Identifier: MIT + +// Copyright 2017 Christian Reitwiessner +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +// 2019 OKIMS + +pragma solidity ^0.6.12; + +library Pairing { + + uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + + struct G1Point { + uint256 X; + uint256 Y; + } + + // Encoding of field elements is: X[0] * z + X[1] + struct G2Point { + uint256[2] X; + uint256[2] Y; + } + + /* + * @return The negation of p, i.e. p.plus(p.negate()) should be zero. + */ + function negate(G1Point memory p) internal pure returns (G1Point memory) { + + // The prime q in the base field F_q for G1 + if (p.X == 0 && p.Y == 0) { + return G1Point(0, 0); + } else { + return G1Point(p.X, PRIME_Q - (p.Y % PRIME_Q)); + } + } + + /* + * @return The sum of two points of G1 + */ + function plus( + G1Point memory p1, + G1Point memory p2 + ) internal view returns (G1Point memory r) { + + uint256[4] memory input; + input[0] = p1.X; + input[1] = p1.Y; + input[2] = p2.X; + input[3] = p2.Y; + bool success; + + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + + require(success,"pairing-add-failed"); + } + + /* + * @return The product of a point on G1 and a scalar, i.e. + * p == p.scalar_mul(1) and p.plus(p) == p.scalar_mul(2) for all + * points p. + */ + function scalar_mul(G1Point memory p, uint256 s) internal view returns (G1Point memory r) { + + uint256[3] memory input; + input[0] = p.X; + input[1] = p.Y; + input[2] = s; + bool success; + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + require (success,"pairing-mul-failed"); + } + + /* @return The result of computing the pairing check + * e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 + * For example, + * pairing([P1(), P1().negate()], [P2(), P2()]) should return true. + */ + function pairing( + G1Point memory a1, + G2Point memory a2, + G1Point memory b1, + G2Point memory b2, + G1Point memory c1, + G2Point memory c2, + G1Point memory d1, + G2Point memory d2 + ) internal view returns (bool) { + + G1Point[4] memory p1 = [a1, b1, c1, d1]; + G2Point[4] memory p2 = [a2, b2, c2, d2]; + + uint256 inputSize = 24; + uint256[] memory input = new uint256[](inputSize); + + for (uint256 i = 0; i < 4; i++) { + uint256 j = i * 6; + input[j + 0] = p1[i].X; + input[j + 1] = p1[i].Y; + input[j + 2] = p2[i].X[0]; + input[j + 3] = p2[i].X[1]; + input[j + 4] = p2[i].Y[0]; + input[j + 5] = p2[i].Y[1]; + } + + uint256[1] memory out; + bool success; + + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + + require(success,"pairing-opcode-failed"); + + return out[0] != 0; + } +} + +contract BatchUpdateStateTreeVerifierCustom { + + using Pairing for *; + + uint256 constant SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617; + uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + + struct VerifyingKey { + Pairing.G1Point alpha1; + Pairing.G2Point beta2; + Pairing.G2Point gamma2; + Pairing.G2Point delta2; + Pairing.G1Point[137] IC; + } + + struct Proof { + Pairing.G1Point A; + Pairing.G2Point B; + Pairing.G1Point C; + } + + function verifyingKey() internal pure returns (VerifyingKey memory vk) { + vk.alpha1 = Pairing.G1Point(uint256(20087353828077202850794044320950857268374503478528972609823484324215331801636),uint256(11476883565453070321867378546975856970885584116909418759035533502511538352926)); + vk.beta2 = Pairing.G2Point([uint256(21661869609286011667004284886876061748883471906320898511156819152590982503460),uint256(1411267331255101216687187759308799712318293061108820897500456502826062760161)], [uint256(242338193632610253406780460721162660970322868717712034766855444702801043068),uint256(11205102304711535815941921385002492265801636744630227197506747841473030702040)]); + vk.gamma2 = Pairing.G2Point([uint256(10703132643546140356186378204895065022814221219458116741589121895614548783664),uint256(8728787808915888886518516188706571827044921488715782720858292899421614548992)], [uint256(21855932176432612007184523640521010134533271824713890942038051024979667517411),uint256(14463000202053145707614344130583620641279820564069360237424059003065520412766)]); + vk.delta2 = Pairing.G2Point([uint256(15511409780586937596469386375448730565918438087848214063975685304482412679403),uint256(2871962587045834446520485474136952467328346328772359835190464961287391630197)], [uint256(15098923887127735110115098383257212634964365431441844211165982132092604642119),uint256(19716506293446006761611333969798166840619850480902019859898831749671195591534)]); + vk.IC[0] = Pairing.G1Point(uint256(13449409323553982807626717659206995893486616914721488975771211075709370315026),uint256(19819167563363500342420294247298414043779583800301883591559879913778994928970)); + vk.IC[1] = Pairing.G1Point(uint256(18288751040873995405829352561880517511670216090222253370470629005274973230224),uint256(3340939551764112714060652679366038538227707806197811714382712640842923887338)); + vk.IC[2] = Pairing.G1Point(uint256(9034324435110195600984520035015153412337260951213866638651602731777208517827),uint256(14546595006162979541631014330847388063705106451104883570324018472333580218369)); + vk.IC[3] = Pairing.G1Point(uint256(18959526910556928462007511646743694022357186454775805231806268761848703787052),uint256(21548913956199741505617644115252315331247918262133746388493422156797029529793)); + vk.IC[4] = Pairing.G1Point(uint256(14667130442384977541051000098091277853515714184455121995211368752877562919286),uint256(1571213305279482731892557325220575745236783105648521604666877211311213326751)); + vk.IC[5] = Pairing.G1Point(uint256(19913405290485444662222555136914754224161963225418121384899196830085445637499),uint256(9353516643529373068293908681832909830620075327436046394651358446880200530845)); + vk.IC[6] = Pairing.G1Point(uint256(4392121493858814884850445257811530682565304094158379534072964024456308711140),uint256(14425403533600244626342298100875789752762767255327078376159416785560008923705)); + vk.IC[7] = Pairing.G1Point(uint256(15817729744441652723145528920073644919288747927823346517846772502038661326087),uint256(6339493756631971029867733380652623802663224827384426871973039193434998926674)); + vk.IC[8] = Pairing.G1Point(uint256(480637294199047307667161992553993337214654072373808050110284394523079810339),uint256(8832148377128939012209474718545762695603645681727887570297879424473451535544)); + vk.IC[9] = Pairing.G1Point(uint256(18744271653088608732764725475608044605973633651736355180626060057128665597247),uint256(10029431604036329130096548676181936710270515833881358240468741367688995476231)); + vk.IC[10] = Pairing.G1Point(uint256(2887974560189403494889743306897414514537070863016749530233722584820661287284),uint256(19531090389757911465455371999342290893522171780307155242713966624430836080666)); + vk.IC[11] = Pairing.G1Point(uint256(14831622056182946369342012331708153541419644376854897007623505162522515905155),uint256(17207180946963880497939168446060614092109855520510825916157704836216098405189)); + vk.IC[12] = Pairing.G1Point(uint256(15506398342704908970868595954855105998758099219541375937953499095105173507550),uint256(1509358924009691430397237655658579260967617755952022251213522582773276442679)); + vk.IC[13] = Pairing.G1Point(uint256(13081356290354186063074749971306070814496882977524291959736906760563684568695),uint256(9884406427032162441347033456153235609148950546399906330857509941718552620268)); + vk.IC[14] = Pairing.G1Point(uint256(719373316591795302151839273680068838979384878504494828773494046765201947280),uint256(4285574473052728017508050004433562406388738477725957133910140811836712357969)); + vk.IC[15] = Pairing.G1Point(uint256(1161961279887123633351369246418294359429428925248242696699854294267840126266),uint256(2753838659155669461065600495917012924384518686391121187033697795542200403972)); + vk.IC[16] = Pairing.G1Point(uint256(13682879487790288634920243025369860399504234851888478701512257545221680936810),uint256(2153246008085528874532592135250171671811203616520867548078143863278493007749)); + vk.IC[17] = Pairing.G1Point(uint256(3516369807590261163059894146447014910302140628998802112065686961872586702551),uint256(5370787160830393410214210351964623688718912410066120987032733452259286528086)); + vk.IC[18] = Pairing.G1Point(uint256(1988524361751778706932724684329605660441921048206095037586339797069472862182),uint256(21114285963513640070787641747881253082556602533623795027313886115253996080647)); + vk.IC[19] = Pairing.G1Point(uint256(2485955165890974183236816009331112192305108639988665043518792297482584311923),uint256(11880640146304852444592379682415385509408598783155502899174478577569880083056)); + vk.IC[20] = Pairing.G1Point(uint256(10219331172860533280779041276433310836289975824303193871202179089572278703569),uint256(7370861950873412157131303975669615391088774540400276783484707074149416805294)); + vk.IC[21] = Pairing.G1Point(uint256(14167728148516477840256196286607935101668320057446161671806500834090072725785),uint256(14874328203966708937121090833723158080118646495824532613915964279405802897922)); + vk.IC[22] = Pairing.G1Point(uint256(6889309751089080036157423235545680142690650792398279314062387575899228869494),uint256(17678911668088463543175270505444996571219698085940587035964935219043301776169)); + vk.IC[23] = Pairing.G1Point(uint256(9673323848791621411824117667951494409448803912571572035911987567276800873692),uint256(8010318233717184439361450385728075741524318837946509278121601177634948395076)); + vk.IC[24] = Pairing.G1Point(uint256(19001216591939800685596329025823328559725214996604900719736845720656499624867),uint256(16800790914194952657872094131443784987321340590188967934648441664397455856225)); + vk.IC[25] = Pairing.G1Point(uint256(14229772670511491842377063841403695319183750623861101302835638264008211544676),uint256(16700086453597824634366081416911323903395382119942186242938984470600767077018)); + vk.IC[26] = Pairing.G1Point(uint256(6190110473128199039318674139275953731627477080237305570664048170694216558607),uint256(9156069687286703875886126396409243836856376303654173871625378309678962742301)); + vk.IC[27] = Pairing.G1Point(uint256(19041950742766772503703484046141610117011636465603587128037213418839536735126),uint256(1741521843922631538075137437516945946494447419662725791349055244115174732397)); + vk.IC[28] = Pairing.G1Point(uint256(20572595967381616358855167208674217372017018727251574275804447670907816537950),uint256(15530155742998922859635289650887433052284249839254842342598193039162339193385)); + vk.IC[29] = Pairing.G1Point(uint256(18894959902692739855443380454453511822218459028123989847552010175424931175589),uint256(21720555445949680264216624728183544115705279456243597689157013642155036265415)); + vk.IC[30] = Pairing.G1Point(uint256(11420223426220804446523491080946075698396582996335464285431689162267487484067),uint256(3181697461117579761185097953588782487765626082815159306282849737563745424506)); + vk.IC[31] = Pairing.G1Point(uint256(2921370814594030903899051421374417440461203550081209203567416200073023145049),uint256(5347812108419343983369408836373704300702310310540619421686782928991729409164)); + vk.IC[32] = Pairing.G1Point(uint256(16741476685225855934358725975984964877988445638736565287964542186206107152293),uint256(4729669602346204655607884191853032759553867998868447356742304646390812496415)); + vk.IC[33] = Pairing.G1Point(uint256(9756675234809793791892705465682087248632694984652554680972716007491924825951),uint256(5988354804897075683722895724359335032053854461455265017672782021744588344814)); + vk.IC[34] = Pairing.G1Point(uint256(19814683865678732851894888194537462976081202780523678223106719506629549258897),uint256(6080471180403505923559123931327801567873683689169241241662583679341260897736)); + vk.IC[35] = Pairing.G1Point(uint256(1438239620527399948189462788892238398578982906275271867592155948061939566626),uint256(2199055174486710563451423451952849431624087101967400585017518019108165853190)); + vk.IC[36] = Pairing.G1Point(uint256(967676148418361677737873476276863318059309477609707671643977589336859176127),uint256(15797276132011461989185803015523111093330042939894033038100054846133562563324)); + vk.IC[37] = Pairing.G1Point(uint256(20201801978563503818789599624676158315679823610998322710056742798817954976063),uint256(11598358783925779109653102359075130468763033066887386333859407419035615301007)); + vk.IC[38] = Pairing.G1Point(uint256(7747526982755731888665585361416626948929515076673700820729567631840982182127),uint256(8266477541281971795125742686488473665271470129792619047143237743745554013710)); + vk.IC[39] = Pairing.G1Point(uint256(19630347857068381357762752321517383973545380130254869958667818061574406509936),uint256(15186347777687718013099982394931225548070830348604080143466772297210051562836)); + vk.IC[40] = Pairing.G1Point(uint256(7557975808969352606285335263414157381982093159126770512582919553699648350483),uint256(6331359472500035804643208799188536087855091113155475777082984912192250759374)); + vk.IC[41] = Pairing.G1Point(uint256(14845008071231916162530646819506161170789752619959011105785671398905933762955),uint256(17510852870482242342381039816675219266744505657530214435696082802116282488658)); + vk.IC[42] = Pairing.G1Point(uint256(13028483425255096939536859978320334835707092501368542039049983266498742408332),uint256(9680955997542002092545710879095660094124123676658363044411252537219803810269)); + vk.IC[43] = Pairing.G1Point(uint256(18570485684385256456511558721236129814674664211827057233856298536476007823563),uint256(6786587425550032533190651930990699335249545132866171624112725170443784236607)); + vk.IC[44] = Pairing.G1Point(uint256(6229010105044576579707704062880618330142301356182755458537022491776084974500),uint256(2958446025628338713087051414787827196521720086407187883901740977668009458474)); + vk.IC[45] = Pairing.G1Point(uint256(19711064707259131885284329850510953278564434575422258680339661582446519996893),uint256(6447334502627514228819588471839200327796435951160054171955070846382297766993)); + vk.IC[46] = Pairing.G1Point(uint256(13654512333629104147605163426403071872951885435411994083936410963051621892949),uint256(17650265592485694925363566185316073499680014776202819473217500634597804211217)); + vk.IC[47] = Pairing.G1Point(uint256(5632109105332974207832397468511779966406880188637740594191372151186045229561),uint256(13651675148237626614923296165038029228539866352571194577844266938252974170084)); + vk.IC[48] = Pairing.G1Point(uint256(8527345386665720309165783434253008921795266063983738469923301602966779024366),uint256(16149187991861855926722833165905235574832072162827813978624809869628415187689)); + vk.IC[49] = Pairing.G1Point(uint256(6646163805935695669626521901182643404621755887577997925506901386112844229851),uint256(11361301962986100960081361654544753510182204509642964951112554856701961156187)); + vk.IC[50] = Pairing.G1Point(uint256(10921559406917075466554221464922756249180248754762588574619694367252428227945),uint256(15987818311916597433092891016570609774371036003985987971567882858356951694123)); + vk.IC[51] = Pairing.G1Point(uint256(19319321803549704705343605501384818081154665651565507251713174153621472515462),uint256(2737644346677906343234185972413750255380030320584877572350390603749165517091)); + vk.IC[52] = Pairing.G1Point(uint256(14097924791420990626067662965994354649057100100900878471771528723878979063670),uint256(3446659685548421144804125954538853863956916787759744530684127569073823331713)); + vk.IC[53] = Pairing.G1Point(uint256(9983862632251067005815597520616536972155239828533016448370610241448628423219),uint256(9425718421842054710526654962601883705369930663657776686776262667638786657422)); + vk.IC[54] = Pairing.G1Point(uint256(2688984403049401342903683721913746062136910340901612180883159738614628664638),uint256(6537385568788079956897582609732708399792014147299594434121004163987996923797)); + vk.IC[55] = Pairing.G1Point(uint256(18265540920707633157018592793425156625083767097873832410185928416315911651112),uint256(614830982358373399190790570742951602645537091079871616861069500149456469620)); + vk.IC[56] = Pairing.G1Point(uint256(12125321699285743073611607029813382470546481051048160495748291470225531864512),uint256(3716293670309368968675908852623314593073639774424731454150351335135845445749)); + vk.IC[57] = Pairing.G1Point(uint256(7853056802721517963036421484032072942693765378562098368306104805678418585162),uint256(6424789894907881712069802715529228349918886636331654615971484908566086243872)); + vk.IC[58] = Pairing.G1Point(uint256(19115005503431091096721184080895329804587690694447705536547788962171345376377),uint256(21684667845604031973485165382669985845242661934129735060595710490022281580308)); + vk.IC[59] = Pairing.G1Point(uint256(5934951296346946320689083498211342144043216739159202457194772865605223848817),uint256(16531730612519172995954542776277328233589925446255179981248179286637232098743)); + vk.IC[60] = Pairing.G1Point(uint256(548179290994039790062273715118266322711869818074110355798782872494554119127),uint256(21277541640969431282210948877991685569792198011788537435034440443744017806814)); + vk.IC[61] = Pairing.G1Point(uint256(5698932685323749446566832552112536072262214364822836541442194088625134869756),uint256(18173025416893411048966167980710924405089325259853820754338009550096212580109)); + vk.IC[62] = Pairing.G1Point(uint256(5407139961162687782789268353002587250953566955217132246179178517076765432715),uint256(15088228606773832436431560223153028924260952727854826128522128552157315934324)); + vk.IC[63] = Pairing.G1Point(uint256(3297833865321076345999149557999739794735986140950154026339694076355675796967),uint256(3411471118249712872884387591128740913549716748840876207700900440280171428377)); + vk.IC[64] = Pairing.G1Point(uint256(7842388686335992312801332510612951894847538866301083390230994724615251547549),uint256(9506065469948872795705994936031211750874514789756601843559917376763183093918)); + vk.IC[65] = Pairing.G1Point(uint256(4095852829188395404575969005812446864304840367703021566476256455754460675693),uint256(8491316200241330102237645830695567828271170242496389953775586915469855840662)); + vk.IC[66] = Pairing.G1Point(uint256(13025537576077929051149126228765064213045713215302857727492279859380396356016),uint256(2692834756506679874200086947427348829159380570066044209560542269051062640881)); + vk.IC[67] = Pairing.G1Point(uint256(8213689088249141668841132843593219869582692686267381807826045996178718589976),uint256(5934750740375389011242980889807579582140412795439731691760487737537146384870)); + vk.IC[68] = Pairing.G1Point(uint256(5064286005858996906539521173567342723294768227186533518332524072316626813796),uint256(18194357467986683563844190921029033308662124754563987268423540451940150494386)); + vk.IC[69] = Pairing.G1Point(uint256(513524361877395586890580626735501312175734658618400473937221160065153077430),uint256(21066430682077818283600250344847770187662959287016517114730950504105800523459)); + vk.IC[70] = Pairing.G1Point(uint256(16131973789317585551032586924024478720306017209112230164516773197156811660827),uint256(2629437023298887657704157265354419011007844685935531259234622748649925287960)); + vk.IC[71] = Pairing.G1Point(uint256(14333443795131676087362902053591471457648753635869483711366294938960766965855),uint256(12375065056354337574541874851953853772434526791527859885521192098306924954605)); + vk.IC[72] = Pairing.G1Point(uint256(8650965935327444683681899304659642514103760946243255832533343127837713901260),uint256(17350766954455027422821468769776856954427397105499750970125107357315321891443)); + vk.IC[73] = Pairing.G1Point(uint256(19127940891316463106484748416155199078020628471209896451231437541817085077431),uint256(9663583369451454043509657828849429547454302647650088620902697913423546564526)); + vk.IC[74] = Pairing.G1Point(uint256(4024045629953114025834675015518977207041945104823465323803797652513143739853),uint256(7099031579319409562306045437060668113626384467426238808017971940237526720957)); + vk.IC[75] = Pairing.G1Point(uint256(19777520349508781241579877240909708384019577017734082523373047015766886330187),uint256(20543687412232979508991763895812193752676648814819172150316512715838932781811)); + vk.IC[76] = Pairing.G1Point(uint256(13381716905414454291256465188057975528662534279036129120834023444787120778828),uint256(83068903289307625321440883120020242942419200390426643332494275740989439527)); + vk.IC[77] = Pairing.G1Point(uint256(7761960949208896426802556459429974793308266350208241353184947107970422491129),uint256(2089026195731535072085584097366292321990391592844991889095562893901021029045)); + vk.IC[78] = Pairing.G1Point(uint256(5197970819517869977641836587074894393807023630746693731371708152450489969498),uint256(15030173127846951102748719502126507555120149267996232824889459685032460633760)); + vk.IC[79] = Pairing.G1Point(uint256(10738029463630555541033436864764967361429379579447728903906800161601920881914),uint256(8890051727148365024606043733688100310356137564792142189316987818514656702210)); + vk.IC[80] = Pairing.G1Point(uint256(12792936448350863485798336539770498877619679941787502943063936842797879294217),uint256(14379669594142278338427457116016736020516627571642516277280265863257375782458)); + vk.IC[81] = Pairing.G1Point(uint256(13559434756703389257582627200705563231522482733893623255451993723994545049976),uint256(14892650996406162560002958956428094083109122401519142177808416014717662579626)); + vk.IC[82] = Pairing.G1Point(uint256(14252276184535708042709518130518888874496340661124769270302165933313034236450),uint256(15273924344508848264258477250341486434993268879902111993744999413719610729096)); + vk.IC[83] = Pairing.G1Point(uint256(9809205799202468521806578646546780450146808562401906118296006228293627684369),uint256(11307415536498866034675798915908732740209657309834816970198638577514763250721)); + vk.IC[84] = Pairing.G1Point(uint256(21705327260612726721607027572593333828131899563073285225389452443571564581741),uint256(21018596752445529907566552196456728940837044358621700846827205193330981345608)); + vk.IC[85] = Pairing.G1Point(uint256(8726253405089330847191862720082852744524984989277533298149093584335630612059),uint256(18486186530998050985018181700908491808421033831981323727450435858762932718129)); + vk.IC[86] = Pairing.G1Point(uint256(6503536483724878233870656193473281418950363845795000055683485451008630495010),uint256(20373536533546802032215725505482963077326337719927421078346183177571358001238)); + vk.IC[87] = Pairing.G1Point(uint256(21362345493034032487313388146136193327479786529066051395403594100453963769111),uint256(5659302265151057957108067254997946560345397781011169944959956043052574665674)); + vk.IC[88] = Pairing.G1Point(uint256(7449550964742803340675630812325796218565644913828914465913881384357756681548),uint256(17292064125777099006635793940096466365126227952794001913174478930939581123256)); + vk.IC[89] = Pairing.G1Point(uint256(6125497125689284067831318181472617987031052184276342829492439288589510595502),uint256(12585026108513932953515017993201613768584424358528209508664951085853306523754)); + vk.IC[90] = Pairing.G1Point(uint256(12762245270309389117737641685449675404740403315746754385981092875802564011552),uint256(4776105253784521029665216303967098003880083781647370925393247521792397407888)); + vk.IC[91] = Pairing.G1Point(uint256(13807938458651671227739057402325558662935793724423758150238166950827759630565),uint256(8407443299360885769442648551918604539455371547608849811398829544820103779159)); + vk.IC[92] = Pairing.G1Point(uint256(19354271469665911556037183311554687370650863636736009934227267454117678598867),uint256(2889581474166896849215445080012200130279831332202980472677608450870018824419)); + vk.IC[93] = Pairing.G1Point(uint256(6226227238242660704404188961830279826158507659691896952725574118929530402933),uint256(16450115825870066758814214991430148198082508764837404422948743285414888884178)); + vk.IC[94] = Pairing.G1Point(uint256(4780964847774203341666353527075414079062026230513049950866837627817139518944),uint256(16859068361144747142625578004213384508540191114869687793312011678232224372225)); + vk.IC[95] = Pairing.G1Point(uint256(8062525302997605008090891400414607999817592945480209521332494130391040549486),uint256(10042482661997039621263546535097387401245876819894143240347776832509613454998)); + vk.IC[96] = Pairing.G1Point(uint256(4156112324011039404668548707912082198272430690748058804543223692230235584010),uint256(6467835632275616211076158221632969554420082266873705242098900605173284788072)); + vk.IC[97] = Pairing.G1Point(uint256(16978493603420177201284890469513822737364101412764684161147950679395900370490),uint256(4804013104215913645504042647931299604664370881965529654982744609336873815572)); + vk.IC[98] = Pairing.G1Point(uint256(20063224436134296487145192369456053667043930173386619477170690006672425660230),uint256(8018762550302361989416661307519944480135763273042015031096306898128032672769)); + vk.IC[99] = Pairing.G1Point(uint256(9381136972738249930310747728613628512869836321932371408132641447585727108675),uint256(13792274675162440241090306118979937533255670775110959353619238438903042099483)); + vk.IC[100] = Pairing.G1Point(uint256(17249799750153971053356997293380265081163205379000759347308627353711859528438),uint256(11860582928346589952937516820758334143823517059789983241580798089780599031873)); + vk.IC[101] = Pairing.G1Point(uint256(2209125375494676829996593878418698944200062459109379104033878964709019186550),uint256(9044941556620400719209087348338656682667735114334848800591128202753917262364)); + vk.IC[102] = Pairing.G1Point(uint256(7905831048152572475855614559007206580981737455003199081628859335938538130184),uint256(3219362210026178835574532431902129534204421524894508591333411433674437426662)); + vk.IC[103] = Pairing.G1Point(uint256(10034645824488683370676189228201474691737684065016222057492787707541855843562),uint256(10962875262870711754286714288576688333775621455833092480063924261333137338082)); + vk.IC[104] = Pairing.G1Point(uint256(16681217492767809220626946625462893148742282263278770454356009745085326859036),uint256(8609765386746653380889813599059419164123726125803365736957612935297948115084)); + vk.IC[105] = Pairing.G1Point(uint256(10409861984682249634638249483107543711654774759190644297788218352203797832971),uint256(10963947759662935212884888830847146879486435953717902604694788526569408050896)); + vk.IC[106] = Pairing.G1Point(uint256(19610116640561738573121735873270623412842636275783845690930764829525483185517),uint256(19999697268734757669286329323254853862322933620601846163862344221876819142639)); + vk.IC[107] = Pairing.G1Point(uint256(20796538276246959844610503898053705465834091935725306697900595861453314277534),uint256(8463040972818515190474433150965544533570162872588257416128796378472361625254)); + vk.IC[108] = Pairing.G1Point(uint256(16242734927529699680977092850391685525876857116431871118405705879284460279923),uint256(233800030226637912442083358100093812963916941762884764432747765761205593722)); + vk.IC[109] = Pairing.G1Point(uint256(575299231355200429649645736454601450683561619418476466277518167882449241582),uint256(16441392148980496339439815763952122005106502317757024622981193995288053243753)); + vk.IC[110] = Pairing.G1Point(uint256(1603299324276303191667584100848645563589905602358091967172803717926108919833),uint256(2923207606433658024984614511442599369631740064463368057365647551116862475865)); + vk.IC[111] = Pairing.G1Point(uint256(15612397606496480900845188862617925195166889100242281072974188587056786460685),uint256(6067268371068187386960150210701543773298636595460683602669641801140055222693)); + vk.IC[112] = Pairing.G1Point(uint256(11716278844761725707707926991887023640732693999845301976833122906763630000470),uint256(4785089586353316211662706302146360930361614633336109347707536468281339428146)); + vk.IC[113] = Pairing.G1Point(uint256(13583970090332558444106411973400436007441644550158519399118705791407995280322),uint256(19644166569147988073283886636967542007943692023233562457318835255034799889940)); + vk.IC[114] = Pairing.G1Point(uint256(1686045902562150190863786039249272152595323263993869676824656256416347524970),uint256(17748495582430458497854085558648682169890368554794356546738567734485590533503)); + vk.IC[115] = Pairing.G1Point(uint256(14018407513023200909083059584310902264885930292989350049846251819450636644515),uint256(15282365300853626656506664284946919761222329988945904085162429142333058688432)); + vk.IC[116] = Pairing.G1Point(uint256(16724562362615523120167011908918353532981098883153390523539421723425152477307),uint256(843622462409191805919999628441033590397683131077427864110140693629784330140)); + vk.IC[117] = Pairing.G1Point(uint256(9317229908502429358451115076979763649356526034355777152382574378803867793407),uint256(2617787134893809524818335754594505537496659392456978184732584754140270601161)); + vk.IC[118] = Pairing.G1Point(uint256(12643564839060300175073382088429811648928756114554035624702422497673075822811),uint256(15646981702412923801232315502751915516527154519138252804608886597168220251051)); + vk.IC[119] = Pairing.G1Point(uint256(16136179725000153445080279536165216574525067823359334408100828869622561025204),uint256(710304109108463984900640046876452138580862272055110902990476351162646910693)); + vk.IC[120] = Pairing.G1Point(uint256(692942860249784705898329710403028922082659734627553976311078555856071631087),uint256(11843201175511394674224882314719744090005823775711198123908970674468441340626)); + vk.IC[121] = Pairing.G1Point(uint256(11779866285886477058233262617181102875810432515236086165301634888647796468285),uint256(20304904017079364293528985902914652711056094838577523831107251186430000376103)); + vk.IC[122] = Pairing.G1Point(uint256(16741048327094051449850380442322997638089566456733427175028993526920079216552),uint256(469168782820627354614016869964037684089616570710843167108196420227532543358)); + vk.IC[123] = Pairing.G1Point(uint256(8192970453232272547440654687523742209402660277066973787541850715511374651622),uint256(15378234133052651769174717524827877745034818735188283718621316832075692924406)); + vk.IC[124] = Pairing.G1Point(uint256(10874114257144317851900054481205527956050976138359009857985393174723062892676),uint256(12717308684825512964345073222442623220963599686472628674634895201106020201890)); + vk.IC[125] = Pairing.G1Point(uint256(5267065588819698865144857558764204428263327949346016006240918993613635535317),uint256(9504308288810723489809880319665125296646318783448726885811570230750183852840)); + vk.IC[126] = Pairing.G1Point(uint256(19589750306950764739097899155765349671907282871881276201801496319992047650746),uint256(19355465427953889761240746637309186677085883165092990254569077723585487580684)); + vk.IC[127] = Pairing.G1Point(uint256(17157506086704891040661746569169794341719382632415432679454534292409879487085),uint256(19897635624356405012232528284119658467695828553967677022062327424627204803193)); + vk.IC[128] = Pairing.G1Point(uint256(20238858483410373364817397805629956894825450075652394120977179046203337104373),uint256(6874509773395989359964200584287462074246787158135629964693169157409514901534)); + vk.IC[129] = Pairing.G1Point(uint256(12042579617996728748165735987255778752470955736200812791100866788721737191632),uint256(11956625767696871244461941300661106065113240619864391737851713805635374157021)); + vk.IC[130] = Pairing.G1Point(uint256(16548366919176947814040435329595118023993324878565761882418197223671907573357),uint256(10620821967136310262692802689974809502198526374547943939269158284384653114350)); + vk.IC[131] = Pairing.G1Point(uint256(8175466437668934308709975762665321770552084750706095349920295311638284090340),uint256(17425364680901154207661740679315488758276320872402168607111940050845887976471)); + vk.IC[132] = Pairing.G1Point(uint256(9198147470468043329255739956904344209746369324919711050881466969196801966276),uint256(20298732777222909816627151550361882672333769232236128952325518941075042836010)); + vk.IC[133] = Pairing.G1Point(uint256(15904946907253788347044186320302300871858274132480685493537494288950980594193),uint256(15409483562413553293784442699758192278775213388937158234684578475424442082364)); + vk.IC[134] = Pairing.G1Point(uint256(14220065024533152210243662627649996829439850016253669280094507063796589016407),uint256(2782695826772336437168593281979032224437557674189704274938530289022757554551)); + vk.IC[135] = Pairing.G1Point(uint256(3439664554786124907619188183455389534759238310861135614302099160907607051269),uint256(20990451399839802618416331354962424116625631351552047454336086879944775872991)); + vk.IC[136] = Pairing.G1Point(uint256(17322663660000121892857220907135345561983364271033777284327298998169328112152),uint256(8518935329747198938862986634975284512581273824227035851902576752634386127933)); + + } + + /* + * @returns Whether the proof is valid given the hardcoded verifying key + * above and the public inputs + */ + function verifyProof( + uint256[2] memory a, + uint256[2][2] memory b, + uint256[2] memory c, + uint256[] memory input + ) public view returns (bool) { + + Proof memory proof; + proof.A = Pairing.G1Point(a[0], a[1]); + proof.B = Pairing.G2Point([b[0][0], b[0][1]], [b[1][0], b[1][1]]); + proof.C = Pairing.G1Point(c[0], c[1]); + + VerifyingKey memory vk = verifyingKey(); + + // Compute the linear combination vk_x + Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); + + // Make sure that proof.A, B, and C are each less than the prime q + require(proof.A.X < PRIME_Q, "verifier-aX-gte-prime-q"); + require(proof.A.Y < PRIME_Q, "verifier-aY-gte-prime-q"); + + require(proof.B.X[0] < PRIME_Q, "verifier-bX0-gte-prime-q"); + require(proof.B.Y[0] < PRIME_Q, "verifier-bY0-gte-prime-q"); + + require(proof.B.X[1] < PRIME_Q, "verifier-bX1-gte-prime-q"); + require(proof.B.Y[1] < PRIME_Q, "verifier-bY1-gte-prime-q"); + + require(proof.C.X < PRIME_Q, "verifier-cX-gte-prime-q"); + require(proof.C.Y < PRIME_Q, "verifier-cY-gte-prime-q"); + + // Make sure that every input is less than the snark scalar field + //for (uint256 i = 0; i < input.length; i++) { + for (uint256 i = 0; i < 136; i++) { + require(input[i] < SNARK_SCALAR_FIELD,"verifier-gte-snark-scalar-field"); + vk_x = Pairing.plus(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i])); + } + + vk_x = Pairing.plus(vk_x, vk.IC[0]); + + return Pairing.pairing( + Pairing.negate(proof.A), + proof.B, + vk.alpha1, + vk.beta2, + vk_x, + vk.gamma2, + proof.C, + vk.delta2 + ); + } +} diff --git a/contracts/contracts/snarkVerifiers/QuadVoteTallyVerifier32Batch16.sol b/contracts/contracts/snarkVerifiers/QuadVoteTallyVerifier32Batch16.sol new file mode 100644 index 000000000..4c0cb2f1f --- /dev/null +++ b/contracts/contracts/snarkVerifiers/QuadVoteTallyVerifier32Batch16.sol @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: MIT + +// Copyright 2017 Christian Reitwiessner +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +// 2019 OKIMS + +pragma solidity ^0.6.12; + +library Pairing { + + uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + + struct G1Point { + uint256 X; + uint256 Y; + } + + // Encoding of field elements is: X[0] * z + X[1] + struct G2Point { + uint256[2] X; + uint256[2] Y; + } + + /* + * @return The negation of p, i.e. p.plus(p.negate()) should be zero. + */ + function negate(G1Point memory p) internal pure returns (G1Point memory) { + + // The prime q in the base field F_q for G1 + if (p.X == 0 && p.Y == 0) { + return G1Point(0, 0); + } else { + return G1Point(p.X, PRIME_Q - (p.Y % PRIME_Q)); + } + } + + /* + * @return The sum of two points of G1 + */ + function plus( + G1Point memory p1, + G1Point memory p2 + ) internal view returns (G1Point memory r) { + + uint256[4] memory input; + input[0] = p1.X; + input[1] = p1.Y; + input[2] = p2.X; + input[3] = p2.Y; + bool success; + + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 6, input, 0xc0, r, 0x60) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + + require(success,"pairing-add-failed"); + } + + /* + * @return The product of a point on G1 and a scalar, i.e. + * p == p.scalar_mul(1) and p.plus(p) == p.scalar_mul(2) for all + * points p. + */ + function scalar_mul(G1Point memory p, uint256 s) internal view returns (G1Point memory r) { + + uint256[3] memory input; + input[0] = p.X; + input[1] = p.Y; + input[2] = s; + bool success; + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + require (success,"pairing-mul-failed"); + } + + /* @return The result of computing the pairing check + * e(p1[0], p2[0]) * .... * e(p1[n], p2[n]) == 1 + * For example, + * pairing([P1(), P1().negate()], [P2(), P2()]) should return true. + */ + function pairing( + G1Point memory a1, + G2Point memory a2, + G1Point memory b1, + G2Point memory b2, + G1Point memory c1, + G2Point memory c2, + G1Point memory d1, + G2Point memory d2 + ) internal view returns (bool) { + + G1Point[4] memory p1 = [a1, b1, c1, d1]; + G2Point[4] memory p2 = [a2, b2, c2, d2]; + + uint256 inputSize = 24; + uint256[] memory input = new uint256[](inputSize); + + for (uint256 i = 0; i < 4; i++) { + uint256 j = i * 6; + input[j + 0] = p1[i].X; + input[j + 1] = p1[i].Y; + input[j + 2] = p2[i].X[0]; + input[j + 3] = p2[i].X[1]; + input[j + 4] = p2[i].Y[0]; + input[j + 5] = p2[i].Y[1]; + } + + uint256[1] memory out; + bool success; + + // solium-disable-next-line security/no-inline-assembly + assembly { + success := staticcall(sub(gas(), 2000), 8, add(input, 0x20), mul(inputSize, 0x20), out, 0x20) + // Use "invalid" to make gas estimation work + switch success case 0 { invalid() } + } + + require(success,"pairing-opcode-failed"); + + return out[0] != 0; + } +} + +contract QuadVoteTallyVerifier32Batch16 { + + using Pairing for *; + + uint256 constant SNARK_SCALAR_FIELD = 21888242871839275222246405745257275088548364400416034343698204186575808495617; + uint256 constant PRIME_Q = 21888242871839275222246405745257275088696311157297823662689037894645226208583; + + struct VerifyingKey { + Pairing.G1Point alpha1; + Pairing.G2Point beta2; + Pairing.G2Point gamma2; + Pairing.G2Point delta2; + Pairing.G1Point[11] IC; + } + + struct Proof { + Pairing.G1Point A; + Pairing.G2Point B; + Pairing.G1Point C; + } + + function verifyingKey() internal pure returns (VerifyingKey memory vk) { + vk.alpha1 = Pairing.G1Point(uint256(3931802286032916768722587566330261370902955393767942929056531203487688137529),uint256(10293105233586296031473050653492052327805448683376110761534611791713915549265)); + vk.beta2 = Pairing.G2Point([uint256(21113959492300078886023582393043413128535975125428858805958839308822991748856),uint256(12222282698476210310273536080661281164688722800089362655366747391082242682958)], [uint256(20739573447354048976161197946493569928714465565589532971602923073536082697608),uint256(12941541312444627642958656716514029404685754754869818026526533196090365546374)]); + vk.gamma2 = Pairing.G2Point([uint256(14670836137271604202540255380769830849745744579684969689183516705496317922507),uint256(12178657156513808651243577987886528335149661869282225179912079606061386989744)], [uint256(1125902728883689137508324551765647737011904363437526425591650949891310723812),uint256(15919834918458423371681379777897287057084498811382451098590568497815773165692)]); + vk.delta2 = Pairing.G2Point([uint256(2231852960373618563799433391860999041123211180191070579878255252716013298732),uint256(14291274065364399133654336098495355501982202302398283580502954673818060696633)], [uint256(3168628806727684542778047539988455291220201924183716864807010176642260685841),uint256(12606002808572759608577415926932586006638023328815450374325080704700677189688)]); + vk.IC[0] = Pairing.G1Point(uint256(12848020380718535565089853534681145843006092696634142199856299025847321502371),uint256(6468756580219346512614969481554956146762400832923090074339557565951026058536)); + vk.IC[1] = Pairing.G1Point(uint256(789092430114940371944840041796419370450123967868354406244601329700742570445),uint256(11703230415288173665088837798624967250284180660322246777462631600764972864812)); + vk.IC[2] = Pairing.G1Point(uint256(16252197430844492890521435281772316410665185290137018091020232186750112907512),uint256(20861485175504002710376158881527553699531789728793309486150649246737774028347)); + vk.IC[3] = Pairing.G1Point(uint256(16969171625806775801891191965047460974818115969312194891897374689668597542196),uint256(14389419046525510722177847778450425484834864589330386321604392542455541983572)); + vk.IC[4] = Pairing.G1Point(uint256(13928883789499754049998767198742842124977905594692254232979837689918838899511),uint256(6757216204221511030872544186493375503384465407204524181513380457112801460878)); + vk.IC[5] = Pairing.G1Point(uint256(12615105472464956174046705416720445236758313003314061110048664932376957788951),uint256(1115476865907623432334995719744390855110066393577587591466560011685797098103)); + vk.IC[6] = Pairing.G1Point(uint256(12126180897004602060892141406139130628195608764592739755066384985876875328223),uint256(837414672224275155302376389224725114262382901229023048656048324984574980028)); + vk.IC[7] = Pairing.G1Point(uint256(721442001352764820041409242091349606527760014067614573870735409795650532250),uint256(5871690341119940542207233131936464616602051666920986699510353544932455895913)); + vk.IC[8] = Pairing.G1Point(uint256(11936590707137322489603100954274435093115715779097755089203405884503252799861),uint256(5832382048375298946996376174464817616061448358844675910441699738844607159400)); + vk.IC[9] = Pairing.G1Point(uint256(1150487096467611973629613424410317323826245588905051816727229632029031650443),uint256(19621934380117246037511579161242972091034040331100068879508644849318614270487)); + vk.IC[10] = Pairing.G1Point(uint256(14447725242028063610944438927433683612461991907837633029384208510392253681728),uint256(15642702797143402072429225245488363130997179355079100914641555016655302069615)); + + } + + /* + * @returns Whether the proof is valid given the hardcoded verifying key + * above and the public inputs + */ + function verifyProof( + uint256[2] memory a, + uint256[2][2] memory b, + uint256[2] memory c, + uint256[] memory input + ) public view returns (bool) { + + Proof memory proof; + proof.A = Pairing.G1Point(a[0], a[1]); + proof.B = Pairing.G2Point([b[0][0], b[0][1]], [b[1][0], b[1][1]]); + proof.C = Pairing.G1Point(c[0], c[1]); + + VerifyingKey memory vk = verifyingKey(); + + // Compute the linear combination vk_x + Pairing.G1Point memory vk_x = Pairing.G1Point(0, 0); + + // Make sure that proof.A, B, and C are each less than the prime q + require(proof.A.X < PRIME_Q, "verifier-aX-gte-prime-q"); + require(proof.A.Y < PRIME_Q, "verifier-aY-gte-prime-q"); + + require(proof.B.X[0] < PRIME_Q, "verifier-bX0-gte-prime-q"); + require(proof.B.Y[0] < PRIME_Q, "verifier-bY0-gte-prime-q"); + + require(proof.B.X[1] < PRIME_Q, "verifier-bX1-gte-prime-q"); + require(proof.B.Y[1] < PRIME_Q, "verifier-bY1-gte-prime-q"); + + require(proof.C.X < PRIME_Q, "verifier-cX-gte-prime-q"); + require(proof.C.Y < PRIME_Q, "verifier-cY-gte-prime-q"); + + // Make sure that every input is less than the snark scalar field + //for (uint256 i = 0; i < input.length; i++) { + for (uint256 i = 0; i < 10; i++) { + require(input[i] < SNARK_SCALAR_FIELD,"verifier-gte-snark-scalar-field"); + vk_x = Pairing.plus(vk_x, Pairing.scalar_mul(vk.IC[i + 1], input[i])); + } + + vk_x = Pairing.plus(vk_x, vk.IC[0]); + + return Pairing.pairing( + Pairing.negate(proof.A), + proof.B, + vk.alpha1, + vk.beta2, + vk_x, + vk.gamma2, + proof.C, + vk.delta2 + ); + } +} diff --git a/contracts/contracts/snarkVerifiers/QuadVoteTallyVerifierBatch64.sol b/contracts/contracts/snarkVerifiers/QuadVoteTallyVerifierCustom.sol similarity index 66% rename from contracts/contracts/snarkVerifiers/QuadVoteTallyVerifierBatch64.sol rename to contracts/contracts/snarkVerifiers/QuadVoteTallyVerifierCustom.sol index 7f5d8befd..a6a396654 100644 --- a/contracts/contracts/snarkVerifiers/QuadVoteTallyVerifierBatch64.sol +++ b/contracts/contracts/snarkVerifiers/QuadVoteTallyVerifierCustom.sol @@ -143,7 +143,7 @@ library Pairing { } } -contract QuadVoteTallyVerifierBatch64 { +contract QuadVoteTallyVerifierCustom { using Pairing for *; @@ -165,21 +165,21 @@ contract QuadVoteTallyVerifierBatch64 { } function verifyingKey() internal pure returns (VerifyingKey memory vk) { - vk.alpha1 = Pairing.G1Point(uint256(8998677785356475976681729551581748241325038364445707399605311153715193285192),uint256(16532093260476468234284235622994996263894019866786993774689525941531486715280)); - vk.beta2 = Pairing.G2Point([uint256(14479696864247948470811129902981074107577880260267988466643697895429700862357),uint256(7673508468962275876822578116767566306007923040617408204893910425294482718359)], [uint256(3025794662125932744461510313664354244361345886188220954268088904152332320651),uint256(18992001603150737150609170655111529043323918325565233843250080825070227900741)]); - vk.gamma2 = Pairing.G2Point([uint256(4774442582759577548845273460482286945247270845418250880380173808037730007146),uint256(19632998816417277057191816929078931508219443286363999553420436712667847802509)], [uint256(8918484860111856084885536772945733139126131932286560515976472672010960012834),uint256(12728669449444166995903623839504592322409504301832398134300330772308607917073)]); - vk.delta2 = Pairing.G2Point([uint256(15785059851343798028684598751378759057245187772163751398827510094565061725238),uint256(21118128021055465323522140883656695832878555508305373434189121269701766235730)], [uint256(13568894355304319876421253464785911878212017214379681164608971423414503706203),uint256(13159583370455092481079763163823460297963250255523361267085961821806615709492)]); - vk.IC[0] = Pairing.G1Point(uint256(17565231262536262059880953057168652920760564268967484995833449932868505425453),uint256(12188686363387894404482877921579809555738089118150529762262500832547425324413)); - vk.IC[1] = Pairing.G1Point(uint256(11189327955398716455357578100208632792320136054341850974581633926389276968439),uint256(13346042944044822030526526592409317594222810159017045773876902868540767926789)); - vk.IC[2] = Pairing.G1Point(uint256(4841917664084834927763896883310585967014384374505892074230796208068284173617),uint256(18170939148620637269090232661132873974208089448822352559672713479981933524597)); - vk.IC[3] = Pairing.G1Point(uint256(18819966500293660402531086354419973912066562695742018658017872617474355110586),uint256(21777120900100859259925548526006244513934409052108418268054046593333988632979)); - vk.IC[4] = Pairing.G1Point(uint256(16090571137665417344860949919114298372447642825525030792688149453160603275973),uint256(11028345007100474884743109999990340096930987561377988366283061948118635256399)); - vk.IC[5] = Pairing.G1Point(uint256(8565376255290633678674898949265672764671797704000889552605773658404947597356),uint256(8134113217715388235372429381559636053722293848617705894690514518674228042182)); - vk.IC[6] = Pairing.G1Point(uint256(14563576887421649746847610551642066185997940451407657996153162281658269151338),uint256(3006545207325771542831873992663481302506804502922484994752738879448954888593)); - vk.IC[7] = Pairing.G1Point(uint256(2945281449524289396587806467221452974974132513125923527213072377993572783955),uint256(16114859942947305831498266256190478085152888824338102881853989411303260441326)); - vk.IC[8] = Pairing.G1Point(uint256(17535290294201239551318275539559369129483399986530054025564198618381997235450),uint256(4670423088334897050397605971773705631924741154427292154782933204365329751809)); - vk.IC[9] = Pairing.G1Point(uint256(17614334556994749443749549798035358239179553133825558482478045411777802484523),uint256(7094754689901925867819232494399619412173023860803836457804265404702369434376)); - vk.IC[10] = Pairing.G1Point(uint256(7390265632726797438431040125237407305009017950382543022039201491896546184823),uint256(17970645195573822913849013220214770354709981129727702271146338010115720135385)); + vk.alpha1 = Pairing.G1Point(uint256(16943336223702478034729513866374796851228809856161008919800913520856468181573),uint256(2995090004627639065569871279932395584911899798711981190091501417285102191177)); + vk.beta2 = Pairing.G2Point([uint256(16224714118819881643530609308327988952043965596591357129331660443749437880225),uint256(18713080770238836914085757668180363883442449561648958290173009680301883643312)], [uint256(22349732573235212308155999603848231077445494488349558443704557051018923559),uint256(10320633006958853808156951459730803259989331403375988741484169048853496829865)]); + vk.gamma2 = Pairing.G2Point([uint256(13754685977183525838201298718645487522999887715054765691404125733830578085397),uint256(6942074706854035824685190568710272703891322307475144729076362801105779834805)], [uint256(5140158617774088963306972183201877929593031398407933973109566549607124831751),uint256(13035987335313190818598467074385857301795834547346013393313010045759712554988)]); + vk.delta2 = Pairing.G2Point([uint256(8060558336832861646731122586124893496721636529597338211955002623228447877246),uint256(11266091873376325088415037049219024114103234301565804309675027383590258801637)], [uint256(14778268722321702691286210615443377029665021234872720602744008230960335632554),uint256(159950337696748857596651038995043496935979997396302102605500326482927324500)]); + vk.IC[0] = Pairing.G1Point(uint256(16066585270605647433163972725844364442561475974556889399601021622371369271144),uint256(12676191990324881131751023451007364920714885702228311161299501530006872841519)); + vk.IC[1] = Pairing.G1Point(uint256(8741724346703266580019385312120367474943720529314996811441101272835876516470),uint256(17031176066038457326863997348851727124563803542303563511325983859631762911934)); + vk.IC[2] = Pairing.G1Point(uint256(18066750137770170845946733820200480964706781331673770545419839050076884756612),uint256(9347679342275024796450198445411694201271359973979853238013376665002795681996)); + vk.IC[3] = Pairing.G1Point(uint256(12615311434592602984490157419406590901170885801626249228431749604898753676825),uint256(14923844847934190225877627597124089862553879390935260800034269416514426560258)); + vk.IC[4] = Pairing.G1Point(uint256(20169822918031976507682131782892646776809554001149512021190639599804349326690),uint256(16500262714506045360275229153359308289644927300370679736657829361303433615345)); + vk.IC[5] = Pairing.G1Point(uint256(17087302943942300743176792228086268327696285793900716344408973607382655072319),uint256(18235408216267296600740961289869198243767504308584360263468406970385003239783)); + vk.IC[6] = Pairing.G1Point(uint256(19545026119096666217656647361860838923223293971001406747125714826757828149809),uint256(6559080491999014353344865620771583944769725829299641810721028046777843584264)); + vk.IC[7] = Pairing.G1Point(uint256(19060100374012958103958897290158267767597513329256041185857758273030309802587),uint256(9555898096763236508022594162106408962958705890577795983031819651275877959038)); + vk.IC[8] = Pairing.G1Point(uint256(11259424594567992022915148822616114808210551795687973599385042152935186891352),uint256(8847372443318686693647511285032355230775674903720747383283857986227997292264)); + vk.IC[9] = Pairing.G1Point(uint256(20034938052071061170101345512267783478448487278351248710639589348238685776221),uint256(20456838147183647185441901749475039833247081714013147449136222686509036222717)); + vk.IC[10] = Pairing.G1Point(uint256(14726963331140212908790922462256415603139476517884646197732123280907881194129),uint256(19499071686152952417621806302814788689759796377680900572072370183655072718752)); } diff --git a/contracts/contracts/snarkVerifiers/README.md b/contracts/contracts/snarkVerifiers/README.md index 29d65dae2..9597c500a 100644 --- a/contracts/contracts/snarkVerifiers/README.md +++ b/contracts/contracts/snarkVerifiers/README.md @@ -1,51 +1,7 @@ # SNARK verifiers -## Trusted setup: +Trusted setup: - 'test' circuits: https://gateway.pinata.cloud/ipfs/Qmbi3nqjBwANPMk5BRyKjCJ4QSHK6WNp7v9NLLo4uwrG1f - 'medium' circuits: https://gateway.pinata.cloud/ipfs/QmRzp3vkFPNHPpXiu7iKpPqVnZB97wq7gyih2mp6pa5bmD -- 'x32' circuits: https://gateway.pinata.cloud/ipfs/QmWSxPBNYDtsK23KwYdMtcDaJg3gWS3LBsqMnENrVG6nmc -- 'batch64' circuits: https://gateway.pinata.cloud/ipfs/QmbVzVWqNTjEv5S3Vvyq7NkLVkpqWuA9DGMRibZYJXKJqy - - -## Generating circuits -Instead of downloading the above circuits from the ipfs, they can be generated using the MACI scripts. For example, to build the x32 circuits on linux Ubuntu 22.04 + Node v16.13.2: - -``` -# Clone the MACI repo and switch to version v0.10.1: -git clone https://github.com/privacy-scaling-explorations/maci.git -cd maci/ -git checkout v0.10.1 - -# install deps -sudo apt-get install build-essential libgmp-dev libsodium-dev nasm git - -# recompile binaries (takes time: ~5min to ~10min), the output files are in ./params folder -cd circuits -./scripts/buildSnarks32.sh - -``` - - -### Generating batch64 circuits -The batch64 circuits can be generated using the [buildCustomSnarks.sh](https://github.com/privacy-scaling-explorations/maci/blob/master/circuits/scripts/buildCustomSnarks.sh) as follow: - -``` -./scripts/buildCustomSnarks.sh -s 32 -m 32 -v 3 -i 6 -b 64 -``` - -After generating the files, set the c binaries with executable permission and rename files as follow so they can be used with the tally scripts as described [here](../../../docs/tally-verify.md) - -``` -mv batchUstCustom batchUst32 -mv batchUstCustom.r1cs batchUst32.r1cs -mv batchUstCustom.params batchUst32.params -mv batchUstCustom.dat batchUst32.dat -mv batchUstCustom.sym batchUst32.sym -mv qvtCustom qvt32 -mv qvtCircuitCustom.r1cs qvtCircuit32.r1cs -mv qvtCustom.params qvt32.params -mv qvtCustom.dat qvt32.dat -mv qvtCustom.sym qvt32.sym -chmod u+x batchUst32 qvt32 -``` +- 'x32' circuits: https://gateway.pinata.cloud/ipfs/QmWSxPBNYDtsK23KwYdMtcDaJg3gWS3LBsqMnENrVG6nmc \ No newline at end of file diff --git a/contracts/contracts/userRegistry/README.md b/contracts/contracts/userRegistry/README.md index b1b853a43..4974956ff 100644 --- a/contracts/contracts/userRegistry/README.md +++ b/contracts/contracts/userRegistry/README.md @@ -9,8 +9,6 @@ This contract consist of: ## Demonstration -> TODO: update the following with a goerli contract - [Demo contract on the Rinkeby](https://rinkeby.etherscan.io/address/0xf99e2173db1f341a947ce9bd7779af2245309f91) Sample of Registered Data: diff --git a/contracts/e2e/index.ts b/contracts/e2e/index.ts index f27cfaa63..eb65d5c0e 100644 --- a/contracts/e2e/index.ts +++ b/contracts/e2e/index.ts @@ -15,7 +15,6 @@ import { createMessage, getRecipientClaimData, } from '../utils/maci' -import { CIRCUITS } from '../utils/deployment' use(solidity) @@ -67,13 +66,15 @@ describe('End-to-end Tests', function () { // Deploy funding round factory const poseidonT3 = await deployContract(deployer, ':PoseidonT3') const poseidonT6 = await deployContract(deployer, ':PoseidonT6') - const circuit = 'prod' - const params = CIRCUITS[circuit] const batchUstVerifier = await deployContract( deployer, - params.batchUstVerifier + 'BatchUpdateStateTreeVerifier32Batch16' + ) + const qvtVerifier = await deployContract( + deployer, + 'QuadVoteTallyVerifier32Batch16' ) - const qvtVerifier = await deployContract(deployer, params.qvtVerifier) + const circuit = 'prod' const maciFactory = await deployMaciFactory(deployer, circuit, { poseidonT3, poseidonT6, @@ -278,6 +279,7 @@ describe('End-to-end Tests', function () { UNIT.mul(8).div(10), UNIT.mul(8).div(10), ]) + // Submit messages for (const contribution of contributions) { const contributor = contribution.signer diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 45513dad3..7db976b3b 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -38,7 +38,7 @@ const config: HardhatUserConfig = { url: 'http://127.0.0.1:8555', gasLimit: GAS_LIMIT, } as any, - goerli: { + rinkeby: { url: process.env.JSONRPC_HTTP_URL || 'http://127.0.0.1:8545', accounts, }, diff --git a/contracts/package.json b/contracts/package.json index 4591d9b33..93cb21fa4 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@clrfund/contracts", - "version": "0.7.0", + "version": "0.6.0", "license": "GPL-3.0", "scripts": { "hardhat": "hardhat", @@ -15,7 +15,7 @@ "finalize:local": "hardhat run --network localhost scripts/finalize.ts", "claim:local": "hardhat run --network localhost scripts/claim.ts", "test": "hardhat test", - "e2e": "NODE_OPTIONS=--max-old-space-size=4096 hardhat test --network localhost e2e/index.ts", + "e2e": "NODE_OPTIONS=--max-old-space-size=4096 hardhat test --network ganache e2e/index.ts", "lint:js": "eslint '{tests,e2e,scripts}/**/*.ts'", "lint:solidity": "solhint 'contracts/**/*.sol'", "lint": "yarn lint:solidity && yarn lint:js", diff --git a/contracts/scripts/deploy.ts b/contracts/scripts/deploy.ts index 512abc22e..c86f68acc 100644 --- a/contracts/scripts/deploy.ts +++ b/contracts/scripts/deploy.ts @@ -7,7 +7,6 @@ import { deployMaciFactory } from '../utils/deployment' async function main() { const [deployer] = await ethers.getSigners() console.log(`Deploying from address: ${deployer.address}`) - const circuit = 'prod' const maciFactory = await deployMaciFactory(deployer, circuit) await maciFactory.deployTransaction.wait() diff --git a/contracts/scripts/deployRound.ts b/contracts/scripts/deployRound.ts index 0402539d1..ad7589752 100644 --- a/contracts/scripts/deployRound.ts +++ b/contracts/scripts/deployRound.ts @@ -12,7 +12,6 @@ async function main() { console.log('*******************') const [deployer] = await ethers.getSigners() console.log('deployer.address: ', deployer.address) - const circuit = 'prod' let maciFactory = await deployMaciFactory(deployer, circuit) await maciFactory.deployTransaction.wait() diff --git a/contracts/tests/deployer.ts b/contracts/tests/deployer.ts index d4dd217c1..4e6ceffa6 100644 --- a/contracts/tests/deployer.ts +++ b/contracts/tests/deployer.ts @@ -1,7 +1,7 @@ import { ethers, waffle } from 'hardhat' import { use, expect } from 'chai' import { solidity } from 'ethereum-waffle' -import { Contract } from 'ethers' +import { Contract, ContractReceipt } from 'ethers' import { genRandomSalt } from 'maci-crypto' import { Keypair } from 'maci-domainobjs' diff --git a/contracts/tests/maciParameters.ts b/contracts/tests/maciParameters.ts deleted file mode 100644 index 058673465..000000000 --- a/contracts/tests/maciParameters.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { expect } from 'chai' -import { MaciParameters } from '../utils/maci' -import { ZERO_ADDRESS } from '../utils/constants' -import { CIRCUITS } from '../utils/deployment' - -describe('Maci Parameters', () => { - it('batch size 8', () => { - const params = CIRCUITS['test'] - const maci = new MaciParameters({ - batchUstVerifier: ZERO_ADDRESS, - qvtVerifier: ZERO_ADDRESS, - ...params.batchSizes, - }) - - const { tallyBatchSize, messageBatchSize } = maci - expect(tallyBatchSize).to.eq(8) - expect(messageBatchSize).to.eq(8) - }) - - it('batch size 64', () => { - const params = CIRCUITS['prod'] - const maci = new MaciParameters({ - batchUstVerifier: ZERO_ADDRESS, - qvtVerifier: ZERO_ADDRESS, - ...params.batchSizes, - }) - - const { tallyBatchSize, messageBatchSize } = params.batchSizes - expect(maci.tallyBatchSize).to.eq(tallyBatchSize) - expect(maci.messageBatchSize).to.eq(messageBatchSize) - }) -}) diff --git a/contracts/tests/recipientRegistry.ts b/contracts/tests/recipientRegistry.ts index 2b1b76c0b..9049b8977 100644 --- a/contracts/tests/recipientRegistry.ts +++ b/contracts/tests/recipientRegistry.ts @@ -834,9 +834,7 @@ describe('Optimistic recipient registry', () => { await provider.send('evm_increaseTime', [86400]) await registry.executeRequest(recipientId) - const requestSubmitted = await registry.removeRecipient(recipientId, { - value: baseDeposit, - }) + const requestSubmitted = await registry.removeRecipient(recipientId) const currentTime = await getCurrentTime() expect(requestSubmitted) .to.emit(registry, 'RequestSubmitted') @@ -849,20 +847,16 @@ describe('Optimistic recipient registry', () => { ) }) - it('allows only owner to execute removal request during challenge period', async () => { + it('allows only owner to submit removal request', async () => { await registry.addRecipient(recipientAddress, metadata, { value: baseDeposit, }) + await provider.send('evm_increaseTime', [86400]) await registry.executeRequest(recipientId) - const registryAsRequester = registry.connect(requester) - await registryAsRequester.removeRecipient(recipientId, { - value: baseDeposit, - }) - await expect( - registryAsRequester.executeRequest(recipientId) - ).to.be.revertedWith('RecipientRegistry: Challenge period is not over') + registry.connect(requester).removeRecipient(recipientId) + ).to.be.revertedWith('Ownable: caller is not the owner') }) it('should not accept removal request if recipient is not in registry', async () => { @@ -878,7 +872,7 @@ describe('Optimistic recipient registry', () => { await provider.send('evm_increaseTime', [86400]) await registry.executeRequest(recipientId) - await registry.removeRecipient(recipientId, { value: baseDeposit }) + await registry.removeRecipient(recipientId) await provider.send('evm_increaseTime', [86400]) await registry.connect(requester).executeRequest(recipientId) @@ -894,7 +888,7 @@ describe('Optimistic recipient registry', () => { await provider.send('evm_increaseTime', [86400]) await registry.executeRequest(recipientId) - await registry.removeRecipient(recipientId, { value: baseDeposit }) + await registry.removeRecipient(recipientId) await expect(registry.removeRecipient(recipientId)).to.be.revertedWith( 'RecipientRegistry: Request already submitted' ) @@ -907,7 +901,7 @@ describe('Optimistic recipient registry', () => { await provider.send('evm_increaseTime', [86400]) await registry.executeRequest(recipientId) - await registry.removeRecipient(recipientId, { value: baseDeposit }) + await registry.removeRecipient(recipientId) const requestRejected = await registry.challengeRequest( recipientId, requester.address @@ -934,7 +928,7 @@ describe('Optimistic recipient registry', () => { await provider.send('evm_increaseTime', [86400]) await registry.executeRequest(recipientId) - await registry.removeRecipient(recipientId, { value: baseDeposit }) + await registry.removeRecipient(recipientId) await provider.send('evm_increaseTime', [86400]) const requestExecuted = await registry diff --git a/contracts/utils/deployment.ts b/contracts/utils/deployment.ts index bc3f24eed..8dc252459 100644 --- a/contracts/utils/deployment.ts +++ b/contracts/utils/deployment.ts @@ -3,7 +3,7 @@ import { Libraries } from 'hardhat/types/runtime' import { Signer, Contract } from 'ethers' import { link } from 'ethereum-waffle' -import { MaciParameters } from './maci' +import { MaciParameters, ProdMaciParameters } from './maci' export function linkBytecode( bytecode: string, @@ -17,10 +17,7 @@ export function linkBytecode( return linkable.evm.bytecode.object } -// custom configuration for MACI parameters. -// If tally and message batch sizes are not configured here, -// they will take the default size of 8 -export const CIRCUITS: { [name: string]: any } = { +const CIRCUITS: { [name: string]: any } = { test: { batchUstVerifier: 'BatchUpdateStateTreeVerifier', qvtVerifier: 'QuadVoteTallyVerifier', @@ -58,19 +55,35 @@ export const CIRCUITS: { [name: string]: any } = { }, }, prod: { - batchUstVerifier: 'BatchUpdateStateTreeVerifierBatch64', - qvtVerifier: 'QuadVoteTallyVerifierBatch64', + batchUstVerifier: 'BatchUpdateStateTreeVerifierCustom', + qvtVerifier: 'QuadVoteTallyVerifierCustom', treeDepths: { stateTreeDepth: 32, messageTreeDepth: 32, voteOptionTreeDepth: 3, }, - batchSizes: { - tallyBatchSize: 64, - messageBatchSize: 64, - }, }, } +const PARAMS = ( + circuit: string, + batchUstVerifier: string, + qvtVerifier: string +) => { + switch (circuit) { + case 'prod': + return new ProdMaciParameters({ + batchUstVerifier, + qvtVerifier, + ...CIRCUITS[circuit].treeDepths, + }) + default: + return new MaciParameters({ + batchUstVerifier, + qvtVerifier, + ...CIRCUITS[circuit].treeDepths, + }) + } +} export async function deployContract( account: Signer, @@ -99,6 +112,7 @@ export async function deployMaciFactory( qvtVerifier, }: MaciFactoryDependencies = {} ): Promise { + let maciParameters: MaciParameters | ProdMaciParameters if (!poseidonT3) { const PoseidonT3 = await ethers.getContractFactory(':PoseidonT3', account) poseidonT3 = await PoseidonT3.deploy() @@ -131,12 +145,12 @@ export async function deployMaciFactory( signer: account, libraries: maciLibraries, }) - const maciParameters = new MaciParameters({ - batchUstVerifier: batchUstVerifier.address, - qvtVerifier: qvtVerifier.address, - ...CIRCUITS[circuit].treeDepths, - ...CIRCUITS[circuit].batchSizes, - }) + + maciParameters = PARAMS( + circuit, + batchUstVerifier.address, + qvtVerifier.address + ) const maciFactory = await MACIFactory.deploy(...maciParameters.values()) await maciFactory.deployTransaction.wait() diff --git a/contracts/utils/maci.ts b/contracts/utils/maci.ts index 475f3a8ff..f7fc97b00 100644 --- a/contracts/utils/maci.ts +++ b/contracts/utils/maci.ts @@ -60,6 +60,64 @@ export class MaciParameters { } } +export class ProdMaciParameters { + stateTreeDepth = 32 + messageTreeDepth = 32 + voteOptionTreeDepth = 3 + tallyBatchSize = 64 + messageBatchSize = 64 + batchUstVerifier!: string + qvtVerifier!: string + signUpDuration = 7 * 86400 + votingDuration = 7 * 86400 + + constructor(parameters: { [name: string]: any } = {}) { + this.update(parameters) + } + + update(parameters: { [name: string]: any }) { + for (const [name, value] of Object.entries(parameters)) { + ;(this as any)[name] = value + } + } + + values(): any[] { + // To be passed to setMaciParameters() + return [ + this.stateTreeDepth, + this.messageTreeDepth, + this.voteOptionTreeDepth, + this.tallyBatchSize, + this.messageBatchSize, + this.batchUstVerifier, + this.qvtVerifier, + this.signUpDuration, + this.votingDuration, + ] + } + + static async read(maciFactory: Contract): Promise { + const { stateTreeDepth, messageTreeDepth, voteOptionTreeDepth } = + await maciFactory.treeDepths() + const { tallyBatchSize, messageBatchSize } = await maciFactory.batchSizes() + const batchUstVerifier = await maciFactory.batchUstVerifier() + const qvtVerifier = await maciFactory.qvtVerifier() + const signUpDuration = (await maciFactory.signUpDuration()).toNumber() + const votingDuration = (await maciFactory.votingDuration()).toNumber() + return new MaciParameters({ + stateTreeDepth, + messageTreeDepth, + voteOptionTreeDepth, + tallyBatchSize, + messageBatchSize, + batchUstVerifier, + qvtVerifier, + signUpDuration, + votingDuration, + }) + } +} + export function bnSqrt(a: BigNumber): BigNumber { // Take square root from a big number // https://stackoverflow.com/a/52468569/1868395 diff --git a/docs/admin.md b/docs/admin.md index fb23e1bb2..dd93ef8ef 100644 --- a/docs/admin.md +++ b/docs/admin.md @@ -1,16 +1,12 @@ -# Running clr.fund instance on Goerli +# Running clr.fund instance on Rinkeby This document describes deployment and administration of clr.fund contracts using [hardhat console](https://hardhat.org/guides/hardhat-console.html). -For example, to start a hardhat console configured for the Goerli network: - -**Prepare .env file** - -You will need to set up an RPC provider for the `JSONRPC_HTTP_URL` variable. Can use infura, pocket, alchemy, etc. +For example, to start console configured for Rinkeby network: **Prepare wallet** -Update `contracts/.env`. See [.env.example](../contracts/.env.example) for details. +Update `contracts/.env` ```bash # Connect using mnemonic @@ -20,13 +16,24 @@ WALLET_MNEMONIC={{mnemonic-phrase}} WALLET_PRIVATE_KEY={{deployer-private-key}} ``` -**Open hardhat console** +If using single private key, update `hardhat.config.ts`: + +```ts +const WALLET_PRIVATE_KEY = process.env.WALLET_PRIVATE_KEY || '' + +// Change Rinkeby to: + accounts: [ `0x${WALLET_PRIVATE_KEY}` ], +``` + +Open hardhat console ``` cd contracts/ -yarn hardhat console --network goerli +yarn hardhat console --network rinkeby ``` +**Prepare .env file** +You will need to set up an RPC provider for the `RINKEBY_JSONRPC_HTTP_URL` variable. Can use infura, pocket, alchemy, etc. ## Deployment @@ -37,7 +44,7 @@ Deploy MACI factory: ```js const [deployer] = await ethers.getSigners() const { deployMaciFactory } = require('./utils/deployment') -const maciFactory = await deployMaciFactory(deployer, 'prod') +const maciFactory = await deployMaciFactory(deployer, 'medium') ``` The `deployMaciFactory` function deploys MACI factory and other contracts required by it: @@ -140,12 +147,11 @@ await factory.setRecipientRegistry(recipientRegistry.address) Set native token: ```js -// this can be any ERC20 compatible token address -const tokenAddress = '0x4f38007de2adba1ba6467d4b82e8de59c2298a3e' -await factory.setToken(tokenAddress) +const rinkebyDaiAddress = '0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea' +await factory.setToken(rinkebyDaiAddress) ``` -If a [coordinator](./tally-verify.md) key has not yet been created. Make sure you save your keys in a file as they will not be displayed again, and you're private key is needed to generate the proofs at the end, and tally the votes: +If a [coordinator](./coordinator.md) key has not yet been created. Make sure you save your keys in a file as they will not be displayed again, and you're private key is needed to generate the proofs at the end, and tally the votes: ```js // Generate coordinator key @@ -224,7 +230,7 @@ Finalize current round and transfer matching funds to the pool: await factory.transferMatchingFunds('', '') ``` -The arguments for `transferMatchingFunds` method should be taken from `tally.json` file published by the [coordinator](./tally-verify.md): +The arguments for `transferMatchingFunds` method should be taken from `tally.json` file published by the [coordinator](./coordinator.md): - `total-spent` value can be found by key `totalVoiceCredits.spent`. - `total-spent-salt` value can be found by key `totalVoiceCredits.salt`. @@ -235,62 +241,11 @@ Cancel current round: await factory.cancelCurrentRound() ``` -## Contract deployment script -There is a new deployRound script that has been created that automates the above process (minus taking the new factory address and injecting it into the UI). To run this, first change directory to the contracts folder, configure the `.env` file. - -Make sure the following parameters are set: - -- JSONRPC_HTTP_URL -- WALLET_PRIVATE_KEY or WALLET_MNEMONIC -- NATIVE_TOKEN_ADDRESS - -Then, run the following: - -``` -npx hardhat run --network {network-name} scripts/deployRound.ts -``` - -## Subgraph -The clrfund web app uses subgraph to index contract event data. You can set up a local instance of subgraph following this [guide](./subgraph.md) or create a hosted instance with [theGraph](https://thegraph.com/hosted-service/) and deploy the subgraphs like this: - -1) change directory to subgraph -2) update the config/goerli.json - - set `address` to your funding round factory address - - set the `factoryStartBlock` to the block before your funding round factory was created - - set the `recipientRegistryStartBlock` to the block before your recipient registry was created - -3) generate subgraph.yaml -``` -npx mustache config/goerli.json subgraph.template.yaml > subgraph.yaml -``` - -4) deploy subgraph -``` -npm run codegen -npm run build -npx graph auth --product hosted-service -npx graph deploy --product hosted-service /clrfund -``` - -## GUN -The clrfund web app stores data in the gundb. To ensure the service is available, start a gundb peer using docker like this: - -``` -docker run -p 8765:8765 gundb/gun -``` - -See https://github.com/amark/gun for more details about GUN - ## User interface User interface can be configured using environment variables. See [.env file example](../vue-app/.env.example) for details. -If following along with Goerli, - 1) make sure to update `VUE_APP_CLRFUND_FACTORY_ADDRESS` with your Goerli funding factory address - 2) update `VUE_APP_ETHEREUM_API_URL` with a Goerli provider (ie. Infura or Alchemy) - 3) update `VUE_APP_ETHEREUM_API_CHAINID` to 5 (Goerli chain id) - 4) update `VUE_APP_SUBGRAPH_URL` with your subgraph url - 5) double check you are using the same user and recipient registry types as used during deployment above. +> If following along with Rinkeby, make sure to update `VUE_APP_CLRFUND_FACTORY_ADDRESS` with your Rinkeby funding factory address, and update `VUE_APP_ETHEREUM_API_URL` with a Rinkeby provider (ie. Infura or Alchemy). Double check you are using the same user and recipient registry types as used during deployment above. Build the dApp for production: @@ -308,3 +263,9 @@ ipfs add -r vue-app/dist/ yarn start:web ``` +## deployRound Script +There is a new deployRound script that has been created that automates the above process (minus taking the new factory address and injecting it into the UI). To run this, first change directories to the contracts folder, run the following: + +``` +npx hardhat run --network {network-name} scripts/deployRound.ts +``` \ No newline at end of file diff --git a/docs/tally-verify.md b/docs/coordinator.md similarity index 58% rename from docs/tally-verify.md rename to docs/coordinator.md index 6a4e2ecd3..3530def10 100644 --- a/docs/tally-verify.md +++ b/docs/coordinator.md @@ -1,38 +1,36 @@ -# How to tally votes +# Coordinator manual -A funding round coordinator can tally votes using the MACI CLI, Docker or clrfund scripts. +## Coordinate using MACI CLI -## Using MACI CLI - -### Clone the [MACI repo](https://github.com/privacy-scaling-explorations/maci) and switch to version v0.10.1: +Clone the [MACI repo](https://github.com/appliedzkp/maci/) and switch to version v0.10.1: ``` -git clone https://github.com/privacy-scaling-explorations/maci.git +git clone https://github.com/appliedzkp/maci.git cd maci/ git checkout v0.10.1 ``` Follow instructions in README.md to install necessary dependencies. -### Download circuits parameters +### Medium Circuits -Download the [zkSNARK parameters](https://gateway.pinata.cloud/ipfs/QmbVzVWqNTjEv5S3Vvyq7NkLVkpqWuA9DGMRibZYJXKJqy) for 'batch 64' circuits into the `circuits/params/` directory. +Download [zkSNARK parameters](https://gateway.pinata.cloud/ipfs/QmRzp3vkFPNHPpXiu7iKpPqVnZB97wq7gyih2mp6pa5bmD) for 'medium' circuits into `circuits/params/` directory and rebuild the keys: -Change the permission of the c binaries to be executable: ``` -cd circuits/params -chmod u+x qvt32 batchUst32 +cd circuits +./scripts/buildSnarksMedium.sh ``` -The contract deployment scripts, `deploy*.ts` in the [clrfund repository](https://github.com/clrfund/monorepo/tree/develop/contracts/scripts) currently use the `batch 64` circuits, if you want to use a smaller size circuits, you can find them [here](../contracts/contracts/snarkVerifiers/README.md). You will need to update the deploy script to call `deployMaciFactory()` with your circuit and redeploy the contracts. +### x32 Circuits + +Download [zkSNARK parameters](https://gateway.pinata.cloud/ipfs/QmWSxPBNYDtsK23KwYdMtcDaJg3gWS3LBsqMnENrVG6nmc) for 'x32' circuits into `circuits/params/` directory and rebuild the keys: ``` - // e.g. to use the x32 circuits - const circuit = 'x32' // defined in contracts/utils/deployment.ts - const maciFactory = await deployMaciFactory(deployer, circuit) +cd circuits +./scripts/buildSnarks32.sh ``` -### Recompile the contracts: +Recompile the contracts: ``` cd ../contracts @@ -50,9 +48,7 @@ A single key can be used to coordinate multiple rounds. ### Tally votes -Download the logs to be fed to the `proveOnChain` step. This step is useful -especially to avoid hitting rating limiting from the node. Make sure to run this -step againts a node that has archiving enabled, e.g. could use the alchemy node: +Download the logs: ``` cd ../cli @@ -97,20 +93,20 @@ Finally, the [CID](https://ipfs.io/ipns/docs.ipfs.io/concepts/content-addressing await fundingRound.publishTallyHash('') ``` -## Using Docker +## Coordinate using Docker In case you are in a different OS than Linux, you can run all the previous MACI CLI commands by running the Docker image located in the MACI repo. -**Note:** the batch 64 zkSNARK parameters have been tested using Ubuntu 22.04 + Node v16.13.2 +**Note:** the [x32 params](https://gateway.pinata.cloud/ipfs/QmWSxPBNYDtsK23KwYdMtcDaJg3gWS3LBsqMnENrVG6nmc) have been tested using Ubuntu 21.04 + Node 15.8.0. ### Use the docker image -First, install [docker](https://docs.docker.com/engine/install/) and [docker-compose](https://docs.docker.com/compose/install/) +First, install [docker](https://docs.docker.com/engine/install/) and [docker-componse](https://docs.docker.com/compose/install/) Inside the maci repo, run: ``` -docker-compose up +docker-componse up ``` Once the container is built, in a different terminal, grab the container id: @@ -129,7 +125,7 @@ cd cli/ node build/index.js genProofs ... ``` -## Using clrfund scripts +## Coordinate using clrfund scripts ### Generate coordinator key @@ -150,16 +146,10 @@ Switch to `contracts` directory: cd contracts/ ``` -Download [zkSNARK parameters](https://gateway.pinata.cloud/ipfs/QmbVzVWqNTjEv5S3Vvyq7NkLVkpqWuA9DGMRibZYJXKJqy) for 'batch 64' circuits to `snark-params` directory. Example: - -``` -ipfs get --output snark-params QmbVzVWqNTjEv5S3Vvyq7NkLVkpqWuA9DGMRibZYJXKJqy -``` +Download [zkSNARK parameters](https://gateway.pinata.cloud/ipfs/QmRzp3vkFPNHPpXiu7iKpPqVnZB97wq7gyih2mp6pa5bmD) for 'medium' circuits to `snark-params` directory. Example: -Change the permission of the c binaries to be executable: ``` -cd snark-params -chmod u+x qvt32 batchUst32 +ipfs get --output snark-params QmRzp3vkFPNHPpXiu7iKpPqVnZB97wq7gyih2mp6pa5bmD ``` Set the path to downloaded parameter files and also the path to `zkutil` binary (if needed): @@ -208,27 +198,3 @@ Once you have the `tally.json` from the tally script, run: ``` yarn hardhat run --network {network} scripts/finalize.ts ``` - -# How to verify the tally results - -Anyone can verify the tally results using the MACI cli or clrfund scripts. - -### Using MACI CLI - -Follow the steps in tallying votes to get the MACI cli, circuit parameters, and tally file, and verify using the following command: - -``` -node build/index.js verify -t tally.json -``` - -### Using clrfund scripts - -From the clrfund contracts folder, run the following command to verify the result: - -``` -yarn ts-node scripts/verify.ts tally.json -``` - - -## Troubleshooting -If you encountered `core dumped` while running the genProofs script as seen in this [issue](https://github.com/clrfund/monorepo/issues/383), make sure the files are not corrupted due to disk space issue, e.g. check file sizes, checksum, and missing files. diff --git a/docs/deployment.md b/docs/deployment.md index e97a61421..e0a584177 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -2,13 +2,22 @@ ## Using the deployment scripts +### x32 Circuits + +Download the [zkSNARK contracts](https://gateway.pinata.cloud/ipfs/QmWSxPBNYDtsK23KwYdMtcDaJg3gWS3LBsqMnENrVG6nmc) for 'x32' circuits and copy them into `/contracts/contracts/snarkVerifiers`. + +- `BatchUpdateStateTreeVerifier32.sol` +- `QuadVoteTallyVerifier32.sol` + ### Edit the `/contracts/.env` file E.g. ``` RECIPIENT_REGISTRY_TYPE=simple -USER_REGISTRY_TYPE=simple +USER_REGISTRY_TYPE=brightid +BRIGHTID_CONTEXT=clr.fund.test +BRIGHTID_VERIFIER_ADDR=0xb1d71F62bEe34E9Fc349234C201090c33BCdF6DB JSONRPC_HTTP_URL=https://NETWORK.alchemyapi.io/v2/ADD_API_KEY WALLET_PRIVATE_KEY= NATIVE_TOKEN_ADDRESS= @@ -21,7 +30,7 @@ NATIVE_TOKEN_ADDRESS= ### Deploy the subgraph -Currently, we are using the [Hosted Service](https://thegraph.com/docs/en/hosted-service/what-is-hosted-service/). First, check out the official instructions to authenicate using the Graph CLI https://thegraph.com/docs/en/hosted-service/deploy-subgraph-hosted/ and create a new subgraph. +Currently, we are using the [Hosted Service](https://thegraph.com/docs/en/hosted-service/what-is-hosted-service/). First, check out the official instructions to authenicate using the Graph CLI https://thegraph.com/docs/legacyexplorer/deploy-subgraph-hosted and create a new subgraph. Inside `/subgraph`: diff --git a/docs/screenshots/dark/about-decentralization.png b/docs/screenshots/dark/about-decentralization.png deleted file mode 100644 index 8a1287a52..000000000 Binary files a/docs/screenshots/dark/about-decentralization.png and /dev/null differ diff --git a/docs/screenshots/dark/about-how-contributors.png b/docs/screenshots/dark/about-how-contributors.png deleted file mode 100644 index b8ef8a307..000000000 Binary files a/docs/screenshots/dark/about-how-contributors.png and /dev/null differ diff --git a/docs/screenshots/dark/about-how-it-works.png b/docs/screenshots/dark/about-how-it-works.png deleted file mode 100644 index 8635fa35c..000000000 Binary files a/docs/screenshots/dark/about-how-it-works.png and /dev/null differ diff --git a/docs/screenshots/dark/about-how-recipients.png b/docs/screenshots/dark/about-how-recipients.png deleted file mode 100644 index bbdb12a1e..000000000 Binary files a/docs/screenshots/dark/about-how-recipients.png and /dev/null differ diff --git a/docs/screenshots/dark/about-maci.png b/docs/screenshots/dark/about-maci.png deleted file mode 100644 index 975c21cc5..000000000 Binary files a/docs/screenshots/dark/about-maci.png and /dev/null differ diff --git a/docs/screenshots/dark/about-public-goods.png b/docs/screenshots/dark/about-public-goods.png deleted file mode 100644 index 5ca8545ad..000000000 Binary files a/docs/screenshots/dark/about-public-goods.png and /dev/null differ diff --git a/docs/screenshots/dark/about-quadratic-funding.png b/docs/screenshots/dark/about-quadratic-funding.png deleted file mode 100644 index 410e72dd9..000000000 Binary files a/docs/screenshots/dark/about-quadratic-funding.png and /dev/null differ diff --git a/docs/screenshots/dark/about-sybil.png b/docs/screenshots/dark/about-sybil.png deleted file mode 100644 index a84ad5c93..000000000 Binary files a/docs/screenshots/dark/about-sybil.png and /dev/null differ diff --git a/docs/screenshots/dark/about.png b/docs/screenshots/dark/about.png deleted file mode 100644 index f616c9ce2..000000000 Binary files a/docs/screenshots/dark/about.png and /dev/null differ diff --git a/docs/screenshots/dark/cart-connect.png b/docs/screenshots/dark/cart-connect.png deleted file mode 100644 index 3d1d40651..000000000 Binary files a/docs/screenshots/dark/cart-connect.png and /dev/null differ diff --git a/docs/screenshots/dark/cart-edit.png b/docs/screenshots/dark/cart-edit.png deleted file mode 100644 index 5d4448134..000000000 Binary files a/docs/screenshots/dark/cart-edit.png and /dev/null differ diff --git a/docs/screenshots/dark/cart-late.png b/docs/screenshots/dark/cart-late.png deleted file mode 100644 index 32734de21..000000000 Binary files a/docs/screenshots/dark/cart-late.png and /dev/null differ diff --git a/docs/screenshots/dark/join-active.png b/docs/screenshots/dark/join-active.png deleted file mode 100644 index 251f74400..000000000 Binary files a/docs/screenshots/dark/join-active.png and /dev/null differ diff --git a/docs/screenshots/dark/join-fund-error.png b/docs/screenshots/dark/join-fund-error.png deleted file mode 100644 index fea991fee..000000000 Binary files a/docs/screenshots/dark/join-fund-error.png and /dev/null differ diff --git a/docs/screenshots/dark/join-fund.png b/docs/screenshots/dark/join-fund.png deleted file mode 100644 index be59b62c1..000000000 Binary files a/docs/screenshots/dark/join-fund.png and /dev/null differ diff --git a/docs/screenshots/dark/join-furthest-info.png b/docs/screenshots/dark/join-furthest-info.png deleted file mode 100644 index 4e9d4a427..000000000 Binary files a/docs/screenshots/dark/join-furthest-info.png and /dev/null differ diff --git a/docs/screenshots/dark/join-furthest-project.png b/docs/screenshots/dark/join-furthest-project.png deleted file mode 100644 index 17186b018..000000000 Binary files a/docs/screenshots/dark/join-furthest-project.png and /dev/null differ diff --git a/docs/screenshots/dark/join-image-error.png b/docs/screenshots/dark/join-image-error.png deleted file mode 100644 index 40fc2a55d..000000000 Binary files a/docs/screenshots/dark/join-image-error.png and /dev/null differ diff --git a/docs/screenshots/dark/join-image-uploaded.png b/docs/screenshots/dark/join-image-uploaded.png deleted file mode 100644 index 77e09cddc..000000000 Binary files a/docs/screenshots/dark/join-image-uploaded.png and /dev/null differ diff --git a/docs/screenshots/dark/join-late.png b/docs/screenshots/dark/join-late.png deleted file mode 100644 index 90127703d..000000000 Binary files a/docs/screenshots/dark/join-late.png and /dev/null differ diff --git a/docs/screenshots/dark/join-links.png b/docs/screenshots/dark/join-links.png deleted file mode 100644 index e1f302f1c..000000000 Binary files a/docs/screenshots/dark/join-links.png and /dev/null differ diff --git a/docs/screenshots/dark/join-project-active.png b/docs/screenshots/dark/join-project-active.png deleted file mode 100644 index aa5dff3e6..000000000 Binary files a/docs/screenshots/dark/join-project-active.png and /dev/null differ diff --git a/docs/screenshots/dark/join-success.png b/docs/screenshots/dark/join-success.png deleted file mode 100644 index a3cfa4da7..000000000 Binary files a/docs/screenshots/dark/join-success.png and /dev/null differ diff --git a/docs/screenshots/dark/join-summary-connect.png b/docs/screenshots/dark/join-summary-connect.png deleted file mode 100644 index becb5d96b..000000000 Binary files a/docs/screenshots/dark/join-summary-connect.png and /dev/null differ diff --git a/docs/screenshots/dark/join-summary-submit.png b/docs/screenshots/dark/join-summary-submit.png deleted file mode 100644 index 6bad00e87..000000000 Binary files a/docs/screenshots/dark/join-summary-submit.png and /dev/null differ diff --git a/docs/screenshots/dark/join-summary-submitting.png b/docs/screenshots/dark/join-summary-submitting.png deleted file mode 100644 index ce8c0a31f..000000000 Binary files a/docs/screenshots/dark/join-summary-submitting.png and /dev/null differ diff --git a/docs/screenshots/dark/join-team.png b/docs/screenshots/dark/join-team.png deleted file mode 100644 index 2bbe6c265..000000000 Binary files a/docs/screenshots/dark/join-team.png and /dev/null differ diff --git a/docs/screenshots/dark/landing.png b/docs/screenshots/dark/landing.png deleted file mode 100644 index 095e66dd6..000000000 Binary files a/docs/screenshots/dark/landing.png and /dev/null differ diff --git a/docs/screenshots/dark/project-with-team.png b/docs/screenshots/dark/project-with-team.png deleted file mode 100644 index 5f76c19e7..000000000 Binary files a/docs/screenshots/dark/project-with-team.png and /dev/null differ diff --git a/docs/screenshots/dark/projects-active.png b/docs/screenshots/dark/projects-active.png deleted file mode 100644 index 206f47474..000000000 Binary files a/docs/screenshots/dark/projects-active.png and /dev/null differ diff --git a/docs/screenshots/dark/projects-empty-search.png b/docs/screenshots/dark/projects-empty-search.png deleted file mode 100644 index ac09be6d5..000000000 Binary files a/docs/screenshots/dark/projects-empty-search.png and /dev/null differ diff --git a/docs/screenshots/dark/recipients.png b/docs/screenshots/dark/recipients.png deleted file mode 100644 index 5d7d242af..000000000 Binary files a/docs/screenshots/dark/recipients.png and /dev/null differ diff --git a/docs/screenshots/dark/round-criteria.png b/docs/screenshots/dark/round-criteria.png deleted file mode 100644 index d2d265724..000000000 Binary files a/docs/screenshots/dark/round-criteria.png and /dev/null differ diff --git a/docs/screenshots/dark/round-information.png b/docs/screenshots/dark/round-information.png deleted file mode 100644 index 25305fdf2..000000000 Binary files a/docs/screenshots/dark/round-information.png and /dev/null differ diff --git a/docs/screenshots/dark/rounds.png b/docs/screenshots/dark/rounds.png deleted file mode 100644 index 4fc4d1592..000000000 Binary files a/docs/screenshots/dark/rounds.png and /dev/null differ diff --git a/docs/screenshots/dark/transaction-contribution.png b/docs/screenshots/dark/transaction-contribution.png deleted file mode 100644 index ea7b8070a..000000000 Binary files a/docs/screenshots/dark/transaction-contribution.png and /dev/null differ diff --git a/docs/screenshots/dark/transaction-realloc.png b/docs/screenshots/dark/transaction-realloc.png deleted file mode 100644 index 7bdd6d91c..000000000 Binary files a/docs/screenshots/dark/transaction-realloc.png and /dev/null differ diff --git a/docs/screenshots/dark/verify-success.png b/docs/screenshots/dark/verify-success.png deleted file mode 100644 index fd09436c3..000000000 Binary files a/docs/screenshots/dark/verify-success.png and /dev/null differ diff --git a/docs/screenshots/dark/verify.png b/docs/screenshots/dark/verify.png deleted file mode 100644 index e9a7c26b0..000000000 Binary files a/docs/screenshots/dark/verify.png and /dev/null differ diff --git a/docs/screenshots/dark/wallet-verified.png b/docs/screenshots/dark/wallet-verified.png deleted file mode 100644 index 14306207d..000000000 Binary files a/docs/screenshots/dark/wallet-verified.png and /dev/null differ diff --git a/docs/screenshots/light/about-decentralization.png b/docs/screenshots/light/about-decentralization.png deleted file mode 100644 index 7d36eabaf..000000000 Binary files a/docs/screenshots/light/about-decentralization.png and /dev/null differ diff --git a/docs/screenshots/light/about-how-contributors.png b/docs/screenshots/light/about-how-contributors.png deleted file mode 100644 index af4cf6eb5..000000000 Binary files a/docs/screenshots/light/about-how-contributors.png and /dev/null differ diff --git a/docs/screenshots/light/about-how-it-works.png b/docs/screenshots/light/about-how-it-works.png deleted file mode 100644 index 1ca4f0c66..000000000 Binary files a/docs/screenshots/light/about-how-it-works.png and /dev/null differ diff --git a/docs/screenshots/light/about-how-recipients.png b/docs/screenshots/light/about-how-recipients.png deleted file mode 100644 index 515d3549d..000000000 Binary files a/docs/screenshots/light/about-how-recipients.png and /dev/null differ diff --git a/docs/screenshots/light/about-layer2.png b/docs/screenshots/light/about-layer2.png deleted file mode 100644 index 8365cfc51..000000000 Binary files a/docs/screenshots/light/about-layer2.png and /dev/null differ diff --git a/docs/screenshots/light/about-maci.png b/docs/screenshots/light/about-maci.png deleted file mode 100644 index edf49958a..000000000 Binary files a/docs/screenshots/light/about-maci.png and /dev/null differ diff --git a/docs/screenshots/light/about-public-goods.png b/docs/screenshots/light/about-public-goods.png deleted file mode 100644 index 504f4fcd4..000000000 Binary files a/docs/screenshots/light/about-public-goods.png and /dev/null differ diff --git a/docs/screenshots/light/about-quadratic-funding.png b/docs/screenshots/light/about-quadratic-funding.png deleted file mode 100644 index e5b9a5cda..000000000 Binary files a/docs/screenshots/light/about-quadratic-funding.png and /dev/null differ diff --git a/docs/screenshots/light/about-sybil.png b/docs/screenshots/light/about-sybil.png deleted file mode 100644 index a784a888e..000000000 Binary files a/docs/screenshots/light/about-sybil.png and /dev/null differ diff --git a/docs/screenshots/light/about.png b/docs/screenshots/light/about.png deleted file mode 100644 index 3951249e0..000000000 Binary files a/docs/screenshots/light/about.png and /dev/null differ diff --git a/docs/screenshots/light/cart-approve.png b/docs/screenshots/light/cart-approve.png deleted file mode 100644 index 8796d9fa4..000000000 Binary files a/docs/screenshots/light/cart-approve.png and /dev/null differ diff --git a/docs/screenshots/light/cart-connect.png b/docs/screenshots/light/cart-connect.png deleted file mode 100644 index 171a0e470..000000000 Binary files a/docs/screenshots/light/cart-connect.png and /dev/null differ diff --git a/docs/screenshots/light/cart-contribute-confirm.png b/docs/screenshots/light/cart-contribute-confirm.png deleted file mode 100644 index 28fa964ea..000000000 Binary files a/docs/screenshots/light/cart-contribute-confirm.png and /dev/null differ diff --git a/docs/screenshots/light/cart-contribute.png b/docs/screenshots/light/cart-contribute.png deleted file mode 100644 index cfcbb5c21..000000000 Binary files a/docs/screenshots/light/cart-contribute.png and /dev/null differ diff --git a/docs/screenshots/light/cart-edit.png b/docs/screenshots/light/cart-edit.png deleted file mode 100644 index 6c8e7a30e..000000000 Binary files a/docs/screenshots/light/cart-edit.png and /dev/null differ diff --git a/docs/screenshots/light/cart-late.png b/docs/screenshots/light/cart-late.png deleted file mode 100644 index f89f4e9a8..000000000 Binary files a/docs/screenshots/light/cart-late.png and /dev/null differ diff --git a/docs/screenshots/light/cart-pool-approve.png b/docs/screenshots/light/cart-pool-approve.png deleted file mode 100644 index accc7589e..000000000 Binary files a/docs/screenshots/light/cart-pool-approve.png and /dev/null differ diff --git a/docs/screenshots/light/cart-pool.png b/docs/screenshots/light/cart-pool.png deleted file mode 100644 index a8e0b829f..000000000 Binary files a/docs/screenshots/light/cart-pool.png and /dev/null differ diff --git a/docs/screenshots/light/cart-retry.png b/docs/screenshots/light/cart-retry.png deleted file mode 100644 index c892337f5..000000000 Binary files a/docs/screenshots/light/cart-retry.png and /dev/null differ diff --git a/docs/screenshots/light/cart-signature-denied.png b/docs/screenshots/light/cart-signature-denied.png deleted file mode 100644 index c78071642..000000000 Binary files a/docs/screenshots/light/cart-signature-denied.png and /dev/null differ diff --git a/docs/screenshots/light/join-active.png b/docs/screenshots/light/join-active.png deleted file mode 100644 index 0f4f5aaf9..000000000 Binary files a/docs/screenshots/light/join-active.png and /dev/null differ diff --git a/docs/screenshots/light/join-fund-error.png b/docs/screenshots/light/join-fund-error.png deleted file mode 100644 index 2333c1934..000000000 Binary files a/docs/screenshots/light/join-fund-error.png and /dev/null differ diff --git a/docs/screenshots/light/join-fund.png b/docs/screenshots/light/join-fund.png deleted file mode 100644 index 7a7ed361b..000000000 Binary files a/docs/screenshots/light/join-fund.png and /dev/null differ diff --git a/docs/screenshots/light/join-furthest-info.png b/docs/screenshots/light/join-furthest-info.png deleted file mode 100644 index 93fc205f5..000000000 Binary files a/docs/screenshots/light/join-furthest-info.png and /dev/null differ diff --git a/docs/screenshots/light/join-furthest-project.png b/docs/screenshots/light/join-furthest-project.png deleted file mode 100644 index 29a8dfe4f..000000000 Binary files a/docs/screenshots/light/join-furthest-project.png and /dev/null differ diff --git a/docs/screenshots/light/join-image-error.png b/docs/screenshots/light/join-image-error.png deleted file mode 100644 index f48482254..000000000 Binary files a/docs/screenshots/light/join-image-error.png and /dev/null differ diff --git a/docs/screenshots/light/join-image-uploaded.png b/docs/screenshots/light/join-image-uploaded.png deleted file mode 100644 index e8d198a38..000000000 Binary files a/docs/screenshots/light/join-image-uploaded.png and /dev/null differ diff --git a/docs/screenshots/light/join-late.png b/docs/screenshots/light/join-late.png deleted file mode 100644 index fe03ebf13..000000000 Binary files a/docs/screenshots/light/join-late.png and /dev/null differ diff --git a/docs/screenshots/light/join-links.png b/docs/screenshots/light/join-links.png deleted file mode 100644 index 8648c5e5d..000000000 Binary files a/docs/screenshots/light/join-links.png and /dev/null differ diff --git a/docs/screenshots/light/join-project-active.png b/docs/screenshots/light/join-project-active.png deleted file mode 100644 index 057942247..000000000 Binary files a/docs/screenshots/light/join-project-active.png and /dev/null differ diff --git a/docs/screenshots/light/join-success.png b/docs/screenshots/light/join-success.png deleted file mode 100644 index 047420fb6..000000000 Binary files a/docs/screenshots/light/join-success.png and /dev/null differ diff --git a/docs/screenshots/light/join-summary-connect.png b/docs/screenshots/light/join-summary-connect.png deleted file mode 100644 index 51bb1ddea..000000000 Binary files a/docs/screenshots/light/join-summary-connect.png and /dev/null differ diff --git a/docs/screenshots/light/join-summary-submit.png b/docs/screenshots/light/join-summary-submit.png deleted file mode 100644 index 037abc3e3..000000000 Binary files a/docs/screenshots/light/join-summary-submit.png and /dev/null differ diff --git a/docs/screenshots/light/join-summary.png b/docs/screenshots/light/join-summary.png deleted file mode 100644 index 0b29d4138..000000000 Binary files a/docs/screenshots/light/join-summary.png and /dev/null differ diff --git a/docs/screenshots/light/join-team.png b/docs/screenshots/light/join-team.png deleted file mode 100644 index bfb3a5846..000000000 Binary files a/docs/screenshots/light/join-team.png and /dev/null differ diff --git a/docs/screenshots/light/landing.jpeg b/docs/screenshots/light/landing.jpeg deleted file mode 100644 index e17b5b5de..000000000 Binary files a/docs/screenshots/light/landing.jpeg and /dev/null differ diff --git a/docs/screenshots/light/project-with-team.png b/docs/screenshots/light/project-with-team.png deleted file mode 100644 index 94b41ef38..000000000 Binary files a/docs/screenshots/light/project-with-team.png and /dev/null differ diff --git a/docs/screenshots/light/projects-active.png b/docs/screenshots/light/projects-active.png deleted file mode 100644 index 129f40c51..000000000 Binary files a/docs/screenshots/light/projects-active.png and /dev/null differ diff --git a/docs/screenshots/light/projects-empty-search.png b/docs/screenshots/light/projects-empty-search.png deleted file mode 100644 index fed8d7170..000000000 Binary files a/docs/screenshots/light/projects-empty-search.png and /dev/null differ diff --git a/docs/screenshots/light/reallocate-fund-modal-signed.png b/docs/screenshots/light/reallocate-fund-modal-signed.png deleted file mode 100644 index db5b21b68..000000000 Binary files a/docs/screenshots/light/reallocate-fund-modal-signed.png and /dev/null differ diff --git a/docs/screenshots/light/reallocate-fund-modal.png b/docs/screenshots/light/reallocate-fund-modal.png deleted file mode 100644 index 244107a7a..000000000 Binary files a/docs/screenshots/light/reallocate-fund-modal.png and /dev/null differ diff --git a/docs/screenshots/light/recipients.jpeg b/docs/screenshots/light/recipients.jpeg deleted file mode 100644 index 4bf06c291..000000000 Binary files a/docs/screenshots/light/recipients.jpeg and /dev/null differ diff --git a/docs/screenshots/light/round-criteria.png b/docs/screenshots/light/round-criteria.png deleted file mode 100644 index a4a0617a8..000000000 Binary files a/docs/screenshots/light/round-criteria.png and /dev/null differ diff --git a/docs/screenshots/light/round-information.png b/docs/screenshots/light/round-information.png deleted file mode 100644 index 894618da3..000000000 Binary files a/docs/screenshots/light/round-information.png and /dev/null differ diff --git a/docs/screenshots/light/rounds.png b/docs/screenshots/light/rounds.png deleted file mode 100644 index 061086517..000000000 Binary files a/docs/screenshots/light/rounds.png and /dev/null differ diff --git a/docs/screenshots/light/transaction-contribution.jpeg b/docs/screenshots/light/transaction-contribution.jpeg deleted file mode 100644 index 120a18d96..000000000 Binary files a/docs/screenshots/light/transaction-contribution.jpeg and /dev/null differ diff --git a/docs/screenshots/light/transaction-realloc.jpeg b/docs/screenshots/light/transaction-realloc.jpeg deleted file mode 100644 index a62d717f0..000000000 Binary files a/docs/screenshots/light/transaction-realloc.jpeg and /dev/null differ diff --git a/docs/screenshots/light/verify-success.png b/docs/screenshots/light/verify-success.png deleted file mode 100644 index 70e17d6fb..000000000 Binary files a/docs/screenshots/light/verify-success.png and /dev/null differ diff --git a/docs/screenshots/light/verify.png b/docs/screenshots/light/verify.png deleted file mode 100644 index 6d748a848..000000000 Binary files a/docs/screenshots/light/verify.png and /dev/null differ diff --git a/docs/screenshots/light/wallet-verified.png b/docs/screenshots/light/wallet-verified.png deleted file mode 100644 index fb6c2e7f3..000000000 Binary files a/docs/screenshots/light/wallet-verified.png and /dev/null differ diff --git a/docs/sitemap.md b/docs/sitemap.md deleted file mode 100644 index 0080aa09c..000000000 --- a/docs/sitemap.md +++ /dev/null @@ -1,41 +0,0 @@ -# Sitemap - -The following sitemap was generated based on the routes defined in [router/index.ts](../vue-app/src/router/index.ts) - -``` -/ -├─── /projects -├─── /project -│ └──/:id -├─── /round-information -├─── /rounds -├─── /round -│ └──/:address -├─── /about -│ ├──/maci -│ ├──/sybil-resistance -│ ├──/layer-2 -│ ├──/how-it-works -│ │ ├──/contributors -│ │ └──/recipients -│ ├──/public-goods -│ ├──/quadratic-funding -│ ├──/decentralization -├─── /recipients -├─── /verify -│ ├──/success/:hash? -│ └──/connect -├─── /join -│ ├──/success/:hash -│ ├──/project -│ ├──/fund -│ ├──/team -│ ├──/links -│ ├──/image -│ ├──/furthestStep -│ └──/summary -├─── /cart -├─── /transaction-success -│ ├──/reallocation/:hash? -│ └──/contribution/:hash? -``` diff --git a/docs/theme-dark.md b/docs/theme-dark.md deleted file mode 100644 index a70c35fc5..000000000 --- a/docs/theme-dark.md +++ /dev/null @@ -1,159 +0,0 @@ -# Dark Theme -## Landing - -![landing](screenshots/dark/landing.png?raw=true) - -## About - -/about - -![about](screenshots/dark/about.png?raw=true) - -/about/decentralization - -![about decentralization](screenshots/dark/about-decentralization.png?raw=true) - -/about/how-it-works - -![about how it works](screenshots/dark/about-how-it-works.png?raw=true) - -/about/how-it-works/contributors - -![about contributors](screenshots/dark/about-how-contributors.png?raw=true) - -/about/how-it-works/recipients - -![about recipients](screenshots/dark/about-how-recipients.png?raw=true) - -/about/maci - -![about maci](screenshots/dark/about-maci.png?raw=true) - -/about/public-goods - -![about public goods](screenshots/dark/about-public-goods.png?raw=true) - -/about/quadratic-funding - -![about quadratic funding](screenshots/dark/about-quadratic-funding.png?raw=true) - -/about/sybil-resistance - -![about sybil resistance](screenshots/dark/about-sybil.png?raw=true) - -## Cart - -![cart-connect](screenshots/dark/cart-connect.png?raw=true) - -![cart-late](screenshots/dark/cart-late.png?raw=true) - -![cart-edit](screenshots/dark/cart-edit.png?raw=true) - -## Join - -/join - -![join-active](screenshots/dark/join-active.png?raw=true) - -![join-late](screenshots/dark/join-late.png?raw=true) - -/join/project - -![join-project-active](screenshots/dark/join-project-active.png?raw=true) - -/join/fund - -![join-fund](screenshots/dark/join-fund.png?raw=true) - -![join-fund-error](screenshots/dark/join-fund-error.png?raw=true) - -/join/team - -![join-team](screenshots/dark/join-team.png?raw=true) - -/join/links - -![join-links](screenshots/dark/join-links.png?raw=true) - -/join/image - -![join-image-error](screenshots/dark/join-image-error.png?raw=true) - -![join-image-uploaded](screenshots/dark/join-image-uploaded.png?raw=true) - -/join/furthestStep - -![join-furthest-info](screenshots/dark/join-furthest-info.png?raw=true) - -![join-furthest-project](screenshots/dark/join-furthest-project.png?raw=true) - -/join/summary - -![join-summary-connect](screenshots/dark/join-summary-connect.png?raw=true) - -![join-summary-submit](screenshots/dark/join-summary-submit.png?raw=true) - -/join/success/:hash? - -![join-success](screenshots/dark/join-success.png?raw=true) - -## Projects - -/projects - -![projects-active](screenshots/dark/projects-active.png?raw=true) - -![projects-empty-search](screenshots/dark/projects-empty-search.png?raw=true) - -## Project Detail - -/project/:id - -![project-with-team](screenshots/dark/project-with-team.png?raw=true) - -## Recipients - -/recipients - -![recipients](screenshots/dark/recipients.png?raw=true) - -## Rounds - -/rounds - -![rounds](screenshots/dark/rounds.png?raw=true) - -Round Criteria - -![round-criteria](screenshots/dark/round-criteria.png?raw=true) - -/round-information - -![round-information](screenshots/dark/round-information.png?raw=true) - -## Transaction - -/transaction-success/contribution/:hash - -![contribution](screenshots/dark/transaction-contribution.png?raw=true) - -/transaction-success/reallocation/:hash - -![reallocation](screenshots/dark/transaction-realloc.png?raw=true) - -## Verify - -/verify - -![verify](screenshots/dark/verify.png?raw=true) - -## Verify Success - -/verify/success/:hash - -![verify-success](screenshots/dark/verify-success.png?raw=true) - -## Wallet - -![wallet-verified](screenshots/dark/wallet-verified.png?raw=true) - diff --git a/docs/theme-light.md b/docs/theme-light.md deleted file mode 100644 index 656774200..000000000 --- a/docs/theme-light.md +++ /dev/null @@ -1,183 +0,0 @@ -# Light Theme -## Landing - -![landing](screenshots/light/landing.jpeg?raw=true) - -## About - -/about - -![about](screenshots/light/about.png?raw=true) - -/about/decentralization - -![about decentralization](screenshots/light/about-decentralization.png?raw=true) - -/about/how-it-works - -![about how it works](screenshots/light/about-how-it-works.png?raw=true) - -/about/how-it-works/contributors - -![about contributors](screenshots/light/about-how-contributors.png?raw=true) - -/about/how-it-works/recipients - -![about recipients](screenshots/light/about-how-recipients.png?raw=true) - -/about/layer-2 - -![about layer 2](screenshots/light/about-layer2.png?raw=true) - -/about/maci - -![about maci](screenshots/light/about-maci.png?raw=true) - -/about/public-goods - -![about public goods](screenshots/light/about-public-goods.png?raw=true) - -/about/quadratic-funding - -![about quadratic funding](screenshots/light/about-quadratic-funding.png?raw=true) - -/about/sybil-resistance - -![about sybil resistance](screenshots/light/about-sybil.png?raw=true) - -## Cart - -![cart-connect](screenshots/light/cart-connect.png?raw=true) - -![cart-late](screenshots/light/cart-late.png?raw=true) - -![cart-approve](screenshots/light/cart-approve.png?raw=true) - -![cart-contribute-confirm](screenshots/light/cart-contribute-confirm.png?raw=true) - -![cart-contribute](screenshots/light/cart-contribute.png?raw=true) - -![cart-edit](screenshots/light/cart-edit.png?raw=true) - -![cart-pool-approve](screenshots/light/cart-pool-approve.png?raw=true) - -![cart-pool](screenshots/light/cart-pool.png?raw=true) - -![cart-retry](screenshots/light/cart-retry.png?raw=true) - -![cart-signature-denied](screenshots/light/cart-signature-denied.png?raw=true) - -## Join - -/join - -![join-active](screenshots/light/join-active.png?raw=true) - -![join-late](screenshots/light/join-late.png?raw=true) - -/join/project - -![join-project-active](screenshots/light/join-project-active.png?raw=true) - -/join/fund - -![join-fund](screenshots/light/join-fund.png?raw=true) - -![join-fund-error](screenshots/light/join-fund-error.png?raw=true) - -/join/team - -![join-team](screenshots/light/join-team.png?raw=true) - -/join/links - -![join-links](screenshots/light/join-links.png?raw=true) - -/join/image - -![join-image-error](screenshots/light/join-image-error.png?raw=true) - -![join-image-uploaded](screenshots/light/join-image-uploaded.png?raw=true) - -/join/furthestStep - -![join-furthest-info](screenshots/light/join-furthest-info.png?raw=true) - -![join-furthest-project](screenshots/light/join-furthest-project.png?raw=true) - -/join/summary - -![join-summary-connect](screenshots/light/join-summary-connect.png?raw=true) - -![join-summary-submit](screenshots/light/join-summary-submit.png?raw=true) - -![join-summary](screenshots/light/join-summary.png?raw=true) - -/join/success/:hash? - -![join-success](screenshots/light/join-success.png?raw=true) - -## Projects - -/projects - -![projects-active](screenshots/light/projects-active.png?raw=true) - -![projects-empty-search](screenshots/light/projects-empty-search.png?raw=true) - -## Project Detail - -/project/:id - -![project-with-team](screenshots/light/project-with-team.png?raw=true) - -## Recipients - -/recipients - -![recipients](screenshots/light/recipients.png?raw=true) - -## Rounds - -/rounds - -![rounds](screenshots/light/rounds.png?raw=true) - -Round Criteria - -![round-criteria](screenshots/light/round-criteria.png?raw=true) - -/round-information - -![round-information](screenshots/light/round-information.png?raw=true) - -## Transaction - -/transaction-success/contribution/:hash - -![contribution](screenshots/light/transaction-contribution.jpeg?raw=true) - -/transaction-success/reallocation/:hash - -![reallocation](screenshots/light/transaction-realloc.jpeg?raw=true) - -![reallocate-fund-modal-signed](screenshots/light/reallocate-fund-modal-signed.png?raw=true) - -![reallocate-fund-modal](screenshots/light/reallocate-fund-modal.png?raw=true) - -## Verify - -/verify - -![verify](screenshots/light/verify.png?raw=true) - -## Verify Success - -/verify/success/:hash - -![verify-success](screenshots/light/verify-success.png?raw=true) - -## Wallet - -![wallet-verified](screenshots/light/wallet-verified.png?raw=true) - diff --git a/docs/theme.md b/docs/theme.md deleted file mode 100644 index 602ccf8ab..000000000 --- a/docs/theme.md +++ /dev/null @@ -1,18 +0,0 @@ -# Theme - -The light and dark theme of the web application can be toggled using the theme button on the navigation bar. - -The selected theme will be persisted to the browser local storage as `@clrfund/vue-app.theme = light|dark`, indicating whether the light or dark theme is selected. - -The existing vuex store is used to make the selected theme accessible to all components - -## Theme color scheme -The theme specific color scheme is defined as css variables in the following files. These variables are saved dynamically as the `data-theme` attribute in the `html` element when the theme is toggled. -- [light color scheme](../vue-app/src/styles/_vars-light.scss) -- [dark color scheme](../vue-app/src/styles/_vars-dark.scss) - -To customize the website with your own color scheme, simply update the css variables with your own colors. - -## Screenshots -- [light theme](theme-light.md) -- [dark theme](theme-dark.md) diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 000000000..d6c996ad7 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,12 @@ +[build] + command = "yarn build" + functions = "vue-app/dist/lambda" + publish = "vue-app/dist" + +[context.staking-round.environment] + VUE_APP_ETHEREUM_API_URL = "https://arb-rinkeby.g.alchemy.com/v2/wPwZJEp0lIu0XwccG_t0MAqF-phtI3og" + VUE_APP_ETHEREUM_API_CHAINID = "421611" + VUE_APP_CLRFUND_FACTORY_ADDRESS = "0x9cF8c20dAb0aAFC6584D5498C0A97F0F51D6F7E4" + VUE_APP_SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/name/pettinarip/clrfundrinkarby2" + VUE_APP_USER_REGISTRY_TYPE = "brightid" + VUE_APP_BRIGHTID_CONTEXT = "CLRFundTest" \ No newline at end of file diff --git a/subgraph/config/goerli.json b/subgraph/config/goerli.json deleted file mode 100644 index c413e317f..000000000 --- a/subgraph/config/goerli.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "network": "goerli", - "address": "0xb1709e5dbB787E82A7feA30da5322e77F3c7D00F", - "factoryStartBlock": 7109979, - "recipientRegistryStartBlock": 7109979 -} diff --git a/subgraph/config/xdai.json b/subgraph/config/xdai.json index b026df2a1..5021104c0 100644 --- a/subgraph/config/xdai.json +++ b/subgraph/config/xdai.json @@ -1,6 +1,6 @@ { "network": "xdai", - "address": "0x4ede8f30d9c2dc96a9d6787e9c4a478424fb960a", + "address": "0x549F91A93c94358C5f5380D7ABF23E1340CfF2db", "factoryStartBlock": 15217676, - "recipientRegistryStartBlock": 15217676 + "recipientRegistryStartBlock": 0 } diff --git a/subgraph/package.json b/subgraph/package.json index 313a33995..66ed7fcec 100644 --- a/subgraph/package.json +++ b/subgraph/package.json @@ -22,10 +22,10 @@ "lint:js": "eslint 'src/*.ts'", "lint": "yarn lint:js", "build": "graph build", - "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ clrfund/clrfund", - "create-local": "graph create --node http://localhost:8020/ clrfund/clrfund", - "remove-local": "graph remove --node http://localhost:8020/ clrfund/clrfund", - "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 clrfund/clrfund" + "deploy": "graph deploy --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ daodesigner/clrfund", + "create-local": "graph create --node http://localhost:8020/ daodesigner/clrfund", + "remove-local": "graph remove --node http://localhost:8020/ daodesigner/clrfund", + "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 daodesigner/clrfund" }, "dependencies": { "@graphprotocol/graph-cli": "0.21.0", diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index db5674c69..6072a6e6d 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -8,7 +8,7 @@ dataSources: name: FundingRoundFactory network: xdai source: - address: '0x4ede8f30d9c2dc96a9d6787e9c4a478424fb960a' + address: '0x549F91A93c94358C5f5380D7ABF23E1340CfF2db' abi: FundingRoundFactory startBlock: 15217676 mapping: @@ -20,6 +20,7 @@ dataSources: - RecipientRegistry - ContributorRegistry - FundingRound + - MACI abis: - name: FundingRoundFactory file: ./abis/FundingRoundFactory.json @@ -31,6 +32,8 @@ dataSources: file: ./abis/OptimisticRecipientRegistry.json - name: BrightIdUserRegistry file: ./abis/BrightIdUserRegistry.json + - name: MACI + file: ./abis/MACI.json eventHandlers: - event: CoordinatorChanged(address) handler: handleCoordinatorChanged diff --git a/vue-app/.env.example b/vue-app/.env.example index ed8ba9ee7..0ca3ec51c 100644 --- a/vue-app/.env.example +++ b/vue-app/.env.example @@ -19,6 +19,10 @@ VUE_APP_USER_REGISTRY_TYPE=simple # Learn more about BrightID and context in /docs/brightid.md VUE_APP_BRIGHTID_CONTEXT=clr.fund +# Optional matching pool address to override the funding round factory address +# e.g. if using a safe multisig for the matching pool +VUE_APP_MATCHING_POOL_ADDRESS= + # Supported values: simple, optimistic, kleros VUE_APP_RECIPIENT_REGISTRY_TYPE=simple @@ -30,7 +34,12 @@ VUE_APP_EXTRA_ROUNDS= # Operator of clr.fund instance VUE_APP_OPERATOR= +# Index of first round to consider +VUE_APP_FIRST_ROUND= + # Google Service Account credentials in JSON format GOOGLE_APPLICATION_CREDENTIALS= # Spreadsheet ID to send recipients data -VUE_APP_GOOGLE_SPREADSHEET_ID= \ No newline at end of file +VUE_APP_GOOGLE_SPREADSHEET_ID= +# Select the sheet's name to write the data, by default 'Raw' +GOOGLE_SHEET_NAME= \ No newline at end of file diff --git a/vue-app/.env.xdai b/vue-app/.env.xdai deleted file mode 100644 index f92ce255e..000000000 --- a/vue-app/.env.xdai +++ /dev/null @@ -1,42 +0,0 @@ -# Ethereum Mainnet provider (used for ENS lookups) -VUE_APP_ETHEREUM_MAINNET_API_URL= - -# Chain details where contract is deployed -VUE_APP_ETHEREUM_API_URL= -VUE_APP_ETHEREUM_API_CHAINID=100 -VUE_APP_INFURA_ID= -VUE_APP_IPFS_GATEWAY_URL=https://ipfs.io -VUE_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/clrfund/clrfund - -# Comma-separated list of URLs -VUE_APP_GUN_PEERS= - -VUE_APP_CLRFUND_FACTORY_ADDRESS=0x4ede8f30d9c2dc96a9d6787e9c4a478424fb960a - -# Supported values: simple, brightid -VUE_APP_USER_REGISTRY_TYPE=brightid -# clr.fund (prod) or CLRFundTest (testing) -# Learn more about BrightID and context in /docs/brightid.md -VUE_APP_BRIGHTID_CONTEXT=clr.fund - -# Supported values: simple, optimistic, kleros, universal -VUE_APP_RECIPIENT_REGISTRY_TYPE=optimistic - -VUE_APP_RECIPIENT_REGISTRY_POLICY=QmeygKjvrpidJeFHv6ywjUrj718nwtFQgCCPPR4r5nL87R - -# Comma-separated list of IPFS hashes -VUE_APP_EXTRA_ROUNDS=Qmat3wDbwNFWGXk4J7JzAJBzrRDGo6nMgPDdmNgrViwRoL,QmVUwHXC9z3WLydQAJGRTrnGUkYwtVqYoTroJGxg1E53tH,QmXAWFeZABxrs1R8CJ3jmDzvvFTXdsSoyT9Sj1EJWyKMhh/#/round/0x18604d042A77C6Ed870Bb86Bc59042daf20BC2Fe,QmXAWFeZABxrs1R8CJ3jmDzvvFTXdsSoyT9Sj1EJWyKMhh/#/round/0xA61aAd9fc284ef75B2b39575E3E0f16863e755bc,QmXAWFeZABxrs1R8CJ3jmDzvvFTXdsSoyT9Sj1EJWyKMhh/#/round/0x4a7242887b004E6C2919E8F040E5B3Cf3369Cd7C,bafybeiacf4qiuchnhyraowz2ziupymlwxkv2lfqf3ae37mzgw6wcbp6cmi/#/round/0x5D259f67FBB03bcF2F1c3f35Ec12F711d7A2D439,bafybeiacf4qiuchnhyraowz2ziupymlwxkv2lfqf3ae37mzgw6wcbp6cmi/#/round/0xf8acacfA954742Dc4eaf8Bd8498F4DFdc01B3875,bafybeiacf4qiuchnhyraowz2ziupymlwxkv2lfqf3ae37mzgw6wcbp6cmi/#/round/0x1c1DF3c3612E140B295F8D37636cBdAf209C2d99 - -# Operator of clr.fund instance -VUE_APP_OPERATOR= - -# Google Service Account credentials in JSON format -GOOGLE_APPLICATION_CREDENTIALS= -# Spreadsheet ID to send recipients data -VUE_APP_GOOGLE_SPREADSHEET_ID= - -# metadata config -# VUE_APP_METADATA_NETWORKS is comma separated network strings -# which will be appended to the METADATA_SUBGRAPH_URL_PREFIX -VUE_APP_METADATA_NETWORKS= -METADATA_SUBGRAPH_URL_PREFIX=https://api.thegraph.com/subgraphs/name/clrfund/metadata- diff --git a/vue-app/package.json b/vue-app/package.json index f959d4b1c..1f0ac6b57 100644 --- a/vue-app/package.json +++ b/vue-app/package.json @@ -1,6 +1,6 @@ { "name": "@clrfund/vue-app", - "version": "0.7.0", + "version": "0.6.0", "private": true, "scripts": { "gun": "gun --host localhost", diff --git a/vue-app/public/core_w720.png b/vue-app/public/core_w720.png new file mode 100644 index 000000000..e3a39e18a Binary files /dev/null and b/vue-app/public/core_w720.png differ diff --git a/vue-app/public/favicon.ico b/vue-app/public/favicon.ico index 74c783347..0a71afa5d 100644 Binary files a/vue-app/public/favicon.ico and b/vue-app/public/favicon.ico differ diff --git a/vue-app/public/index.html b/vue-app/public/index.html index 81b0df3b6..a100ff7af 100644 --- a/vue-app/public/index.html +++ b/vue-app/public/index.html @@ -1,16 +1,34 @@ - clr.fund - - - - - + ETHStaker QF Round + + + + + + + + + + + + + + + +
diff --git a/vue-app/src/App.vue b/vue-app/src/App.vue index 47d53d00a..60a9c88c4 100644 --- a/vue-app/src/App.vue +++ b/vue-app/src/App.vue @@ -17,7 +17,7 @@ 'mr-cart-closed': !isCartToggledOpen && isSideCartShown, }" > - +
{ this.$store.dispatch(LOAD_ROUND_INFO) }, 60 * 1000) @@ -111,6 +111,7 @@ export default class App extends Vue { await this.$store.dispatch(SELECT_ROUND, roundAddress) this.$store.dispatch(LOAD_ROUND_INFO) this.$store.dispatch(LOAD_FACTORY_INFO) + this.$store.dispatch(LOAD_MACI_FACTORY_INFO) await this.$store.dispatch(LOAD_RECIPIENT_REGISTRY_INFO) } @@ -124,22 +125,30 @@ export default class App extends Vue { loginUser = async () => { if (!this.$web3.user) return + // Connect & auth to gun db + await this.$store.dispatch(LOGIN_USER, this.$web3.user) + this.$store.commit(SET_CURRENT_USER, this.$web3.user) - await this.$store.dispatch(LOGIN_USER) this.$store.dispatch(LOAD_USER_INFO) - if (this.$store.state.currentRound) { - // Load cart & contributor data for current round - this.$store.dispatch(LOAD_CART) - this.$store.dispatch(LOAD_COMMITTED_CART) - this.$store.dispatch(LOAD_CONTRIBUTOR_DATA) + this.$store.dispatch(LOAD_BRIGHT_ID) + } + + @Watch('isUserAndRoundLoaded') + loadUserRoundData = async () => { + if (!this.isUserAndRoundLoaded) { + return } + + this.$store.dispatch(LOAD_USER_INFO) + + // Load cart & contributor data for current round + this.$store.dispatch(LOAD_CART) + this.$store.dispatch(LOAD_COMMITTED_CART) + this.$store.dispatch(LOAD_CONTRIBUTOR_DATA) } - @Watch('$store.state.theme') - setAppTheme = () => { - const savedTheme = this.$store.state.theme - const theme = savedTheme || getOsColorScheme() - document.documentElement.setAttribute('data-theme', theme) + get isUserAndRoundLoaded(): boolean { + return !!this.currentUser && !!this.$store.state.currentRound } private get currentUser(): User { @@ -194,6 +203,7 @@ export default class App extends Vue { const excludedRoutes = [ 'landing', 'join', + 'join-step', 'transaction-success', 'verify', 'project-added', @@ -223,14 +233,14 @@ body { } html { - background-color: var(--bg-primary-color); - color: var(--text-color); + background-color: $bg-primary-color; + color: $text-color; font-family: Inter, sans-serif; font-size: 16px; } a { - color: var(--link-color); + color: $highlight-color; cursor: pointer; text-decoration: none; } @@ -286,17 +296,17 @@ summary:focus { } .input { - background-color: var(--bg-light-color); + background-color: $bg-light-color; border: 2px solid $button-color; border-radius: 2px; box-sizing: border-box; - color: var(--text-color); + color: $text-color; font-family: Inter, sans-serif; font-size: 16px; padding: 7px; &.invalid { - border-color: var(--error-color); + border-color: $error-color; } &::placeholder { @@ -312,7 +322,7 @@ summary:focus { background-color: $button-color; border: none; border-radius: 20px; - color: var(--text-color); + color: $text-color; cursor: pointer; font-weight: bold; line-height: 22px; @@ -326,13 +336,13 @@ summary:focus { &:hover { background-color: $highlight-color; - color: var(--bg-secondary-color); + color: $bg-secondary-color; } &[disabled], &[disabled]:hover { background-color: $button-disabled-color !important; - color: $button-disabled-color !important; + color: $button-disabled-text-color !important; cursor: not-allowed; } } @@ -359,14 +369,14 @@ summary:focus { display: flex; /* height: calc(100vh - 61.5px); */ height: 100%; - background: var(--bg-primary-color); + background: $bg-primary-color; overflow-x: clip; /* overflow-y: scroll; */ } #sidebar { box-sizing: border-box; - background-color: var(--bg-primary-color); + background-color: $bg-primary-color; flex-shrink: 0; padding: 1.5rem; width: $cart-width-open; @@ -374,6 +384,11 @@ summary:focus { position: sticky; top: 1.5rem; + .master { + color: black; + float: right; + } + .status { font-size: 16px; display: flex; @@ -381,7 +396,7 @@ summary:focus { } .round-info-div { - background: var(--bg-light-color); + background: $bg-light-color; border-radius: 8px; padding: 1rem; margin-bottom: 2rem; @@ -421,7 +436,7 @@ summary:focus { padding: 50px 5% 0; */ a { - color: var(--text-color); + color: $text-color; display: block; font-size: 16px; margin-bottom: $content-space; @@ -457,10 +472,6 @@ summary:focus { flex: 1; padding-bottom: 4rem; - .breadcrumbs { - padding-left: 1.5rem; - } - .content-heading { display: block; font-family: 'Glacial Indifference', sans-serif; @@ -497,7 +508,7 @@ summary:focus { } .verified { - background: $gradient-highlight; + background: $clr-pink-light-gradient; height: 16px; width: 16px; border-radius: 50%; @@ -518,10 +529,10 @@ summary:focus { } .modal-body { - background-color: var(--bg-light-color); + background-color: $bg-light-color; padding: $modal-space; text-align: center; - box-shadow: var(--box-shadow); + box-shadow: $box-shadow; .loader { margin: $modal-space auto; @@ -537,7 +548,7 @@ summary:focus { } .error { - color: var(--error-color); + color: $error-color; margin-bottom: 0; margin-top: 0.5rem; font-size: 14px; @@ -606,8 +617,8 @@ summary:focus { z-index: 10000; .tooltip-inner { - background: var(--bg-primary-color); - color: var(--text-color); + background: $bg-primary-color; + color: white; font-family: Inter; line-height: 150%; font-size: 14px; @@ -690,8 +701,8 @@ summary:focus { &.popover { .popover-inner { - background: var(--bg-primary-color); - color: var(--text-color); + background: $bg-primary-color; + color: white; padding: 1rem; margin: 0.5rem; border-radius: 5px; @@ -699,7 +710,7 @@ summary:focus { } .popover-arrow { - border-color: var(--bg-primary-color); + border-color: $bg-primary-color; } } diff --git a/vue-app/src/api/abi.ts b/vue-app/src/api/abi.ts index 4a511c12d..f8ffc89d8 100644 --- a/vue-app/src/api/abi.ts +++ b/vue-app/src/api/abi.ts @@ -1,6 +1,7 @@ import { abi as ERC20 } from '../../../contracts/build/contracts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json' import { abi as FundingRoundFactory } from '../../../contracts/build/contracts/contracts/FundingRoundFactory.sol/FundingRoundFactory.json' import { abi as FundingRound } from '../../../contracts/build/contracts/contracts/FundingRound.sol/FundingRound.json' +import { abi as MACIFactory } from '../../../contracts/build/contracts/contracts/MACIFactory.sol/MACIFactory.json' import { abi as MACI } from '../../../contracts/build/contracts/maci-contracts/sol/MACI.sol/MACI.json' import { abi as UserRegistry } from '../../../contracts/build/contracts/contracts/userRegistry/IUserRegistry.sol/IUserRegistry.json' import { abi as BrightIdUserRegistry } from '../../../contracts/build/contracts/contracts/userRegistry/BrightIdUserRegistry.sol/BrightIdUserRegistry.json' @@ -13,6 +14,7 @@ export { ERC20, FundingRoundFactory, FundingRound, + MACIFactory, MACI, UserRegistry, BrightIdUserRegistry, diff --git a/vue-app/src/api/contributions.ts b/vue-app/src/api/contributions.ts index 179dfc727..4b7adf3ff 100644 --- a/vue-app/src/api/contributions.ts +++ b/vue-app/src/api/contributions.ts @@ -1,11 +1,9 @@ -import { BigNumber, Contract, Signer, FixedNumber } from 'ethers' -import { parseFixed } from '@ethersproject/bignumber' - +import { BigNumber, Contract, Signer } from 'ethers' import { TransactionResponse } from '@ethersproject/abstract-provider' import { Keypair, PrivKey } from 'maci-domainobjs' -import { RoundInfo } from './round' -import { FundingRound } from './abi' +import { FundingRound, ERC20 } from './abi' +import { factory, provider } from './core' import { Project } from './projects' import sdk from '@/graphql/sdk' @@ -13,7 +11,7 @@ export const DEFAULT_CONTRIBUTION_AMOUNT = 5 export const MAX_CONTRIBUTION_AMOUNT = 10000 // See FundingRound.sol // The batch of maximum size will burn 9100000 gas at 700000 gas per message -export const MAX_CART_SIZE = 13 +export const MAX_CART_SIZE = 8 export interface CartItem extends Project { amount: string @@ -89,29 +87,21 @@ export async function getContributionAmount( export async function getTotalContributed( fundingRoundAddress: string ): Promise<{ count: number; amount: BigNumber }> { + const nativeTokenAddress = await factory.nativeToken() + const nativeToken = new Contract(nativeTokenAddress, ERC20, provider) + const balance = await nativeToken.balanceOf(fundingRoundAddress) + const data = await sdk.GetTotalContributed({ fundingRoundAddress: fundingRoundAddress.toLowerCase(), }) - if (!data.fundingRound?.contributors) { + if (!data.fundingRound?.contributorCount) { return { count: 0, amount: BigNumber.from(0) } } const count = parseInt(data.fundingRound.contributorCount) - const amount = data.fundingRound.contributors.reduce((total, contributor) => { - if (!contributor.contributions?.length) { - return total - } - - const subtotal = contributor.contributions.reduce((total, contribution) => { - return total.add(contribution.amount) - }, BigNumber.from(0)) - - return total.add(subtotal) - }, BigNumber.from(0)) - - return { count, amount } + return { count, amount: balance } } export async function withdrawContribution( @@ -133,30 +123,3 @@ export async function hasContributorVoted( }) return !!data.fundingRound?.contributors?.[0]?.votes?.length } - -export function isContributionAmountValid( - value: string, - currentRound: RoundInfo -): boolean { - if (!currentRound) { - // Skip validation - return true - } - const { nativeTokenDecimals, voiceCreditFactor } = currentRound - let amount - try { - amount = parseFixed(value, nativeTokenDecimals) - } catch { - return false - } - if (amount.lte(BigNumber.from(0))) { - return false - } - const normalizedValue = FixedNumber.fromValue( - amount.div(voiceCreditFactor).mul(voiceCreditFactor), - nativeTokenDecimals - ) - .toUnsafeFloat() - .toString() - return normalizedValue === value -} diff --git a/vue-app/src/api/core.ts b/vue-app/src/api/core.ts index 159c88748..39ca1168c 100644 --- a/vue-app/src/api/core.ts +++ b/vue-app/src/api/core.ts @@ -52,9 +52,3 @@ export const extraRounds: string[] = process.env.VUE_APP_EXTRA_ROUNDS export const SUBGRAPH_ENDPOINT = process.env.VUE_APP_SUBGRAPH_URL || 'https://api.thegraph.com/subgraphs/name/daodesigner/clrfund' - -// application theme -export enum ThemeMode { - LIGHT = 'light', - DARK = 'dark', -} diff --git a/vue-app/src/api/factory.ts b/vue-app/src/api/factory.ts index d8559378c..933774569 100644 --- a/vue-app/src/api/factory.ts +++ b/vue-app/src/api/factory.ts @@ -7,6 +7,7 @@ export interface Factory { nativeTokenAddress: string nativeTokenSymbol: string nativeTokenDecimals: number + userRegistryAddress: string } export async function getFactoryInfo() { @@ -16,10 +17,13 @@ export async function getFactoryInfo() { const nativeTokenSymbol = await nativeToken.symbol() const nativeTokenDecimals = await nativeToken.decimals() + const userRegistryAddress = await factory.userRegistry() + return { fundingRoundAddress: factory.address, nativeTokenAddress, nativeTokenSymbol, nativeTokenDecimals, + userRegistryAddress, } } diff --git a/vue-app/src/api/maci-factory.ts b/vue-app/src/api/maci-factory.ts new file mode 100644 index 000000000..3cc909dbd --- /dev/null +++ b/vue-app/src/api/maci-factory.ts @@ -0,0 +1,20 @@ +import { Contract } from 'ethers' +import { MACIFactory as MACIFactoryABI } from './abi' +import { factory, provider } from './core' + +export interface MACIFactory { + maciFactoryAddress: string + maxRecipients: number +} + +export async function getMACIFactoryInfo(): Promise { + const maciFactoryAddress = await factory.maciFactory() + + const maciFactory = new Contract(maciFactoryAddress, MACIFactoryABI, provider) + const treeDepths = await maciFactory.treeDepths() + + return { + maciFactoryAddress, + maxRecipients: 5 ** treeDepths.voteOptionTreeDepth - 1, + } +} diff --git a/vue-app/src/api/recipient-registry-optimistic.ts b/vue-app/src/api/recipient-registry-optimistic.ts index 11c2296ab..58b38c81f 100644 --- a/vue-app/src/api/recipient-registry-optimistic.ts +++ b/vue-app/src/api/recipient-registry-optimistic.ts @@ -33,15 +33,7 @@ export async function getRegistryInfo( ) const deposit = await registry.baseDeposit() const challengePeriodDuration = await registry.challengePeriodDuration() - let recipientCount - try { - recipientCount = await registry.getRecipientCount() - } catch { - // older BaseRecipientRegistry contract did not have recipientCount - // set it to zero as this information is only - // used during current round for space calculation - recipientCount = BigNumber.from(0) - } + const recipientCount = await registry.getRecipientCount() const owner = await registry.owner() return { deposit, @@ -164,12 +156,8 @@ export async function getRequests( const requests: Record = {} for (const recipient of recipients) { - let metadata: any - try { - metadata = JSON.parse(recipient.recipientMetadata || '{}') - } catch { - metadata = {} - } + let metadata = JSON.parse(recipient.recipientMetadata || '{}') + const requestType = Number(recipient.requestType) if (requestType === RequestTypeCode.Registration) { // Registration request diff --git a/vue-app/src/api/round.ts b/vue-app/src/api/round.ts index 360b68e37..c067f8601 100644 --- a/vue-app/src/api/round.ts +++ b/vue-app/src/api/round.ts @@ -5,6 +5,9 @@ import { PubKey } from 'maci-domainobjs' import { FundingRound, MACI, ERC20 } from './abi' import { provider, factory } from './core' import { getTotalContributed } from './contributions' +import { getRounds } from './rounds' + +import { isSameAddress } from '@/utils/accounts' export interface RoundInfo { fundingRoundAddress: string @@ -50,7 +53,15 @@ export async function getCurrentRound(): Promise { if (fundingRoundAddress === '0x0000000000000000000000000000000000000000') { return null } - return fundingRoundAddress + const rounds = await getRounds() + const roundIndex = rounds.findIndex((round) => + isSameAddress(round.address, fundingRoundAddress) + ) + + if (roundIndex >= Number(process.env.VUE_APP_FIRST_ROUND || 0)) { + return fundingRoundAddress + } + return null } //TODO: update to take factory address as a parameter, default to env. variable diff --git a/vue-app/src/assets/ES-long-w-no-padding.svg b/vue-app/src/assets/ES-long-w-no-padding.svg new file mode 100644 index 000000000..fb6e47c67 --- /dev/null +++ b/vue-app/src/assets/ES-long-w-no-padding.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/vue-app/src/assets/half-moon.svg b/vue-app/src/assets/half-moon.svg deleted file mode 100644 index b3de08048..000000000 --- a/vue-app/src/assets/half-moon.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/vue-app/src/assets/sun.svg b/vue-app/src/assets/sun.svg deleted file mode 100644 index fe6de4d38..000000000 --- a/vue-app/src/assets/sun.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/vue-app/src/components/Accordion.vue b/vue-app/src/components/Accordion.vue index e5531f22d..894a6f256 100644 --- a/vue-app/src/components/Accordion.vue +++ b/vue-app/src/components/Accordion.vue @@ -47,7 +47,7 @@ export default class Accordion extends Vue { @import '../styles/theme'; .option { - background: var(--bg-light-color); + background: $bg-light-color; padding: 1rem; border-radius: 0.5rem; margin-bottom: 1rem; @@ -56,9 +56,8 @@ export default class Accordion extends Vue { margin: 0.5rem; padding: 0.5rem; cursor: pointer; - filter: var(--img-filter, invert(1)); &:hover { - background: $clr-black; + background: $bg-secondary-color; border-radius: 0.5rem; } } diff --git a/vue-app/src/components/AddToCartButton.vue b/vue-app/src/components/AddToCartButton.vue index e47161ec3..04c0fe679 100644 --- a/vue-app/src/components/AddToCartButton.vue +++ b/vue-app/src/components/AddToCartButton.vue @@ -1,26 +1,34 @@ @@ -35,21 +43,17 @@ import { TOGGLE_SHOW_CART_PANEL, TOGGLE_EDIT_SELECTION, } from '@/store/mutation-types' -import { - DEFAULT_CONTRIBUTION_AMOUNT, - isContributionAmountValid, -} from '@/api/contributions' +import { DEFAULT_CONTRIBUTION_AMOUNT } from '@/api/contributions' import { User } from '@/api/user' import { Project } from '@/api/projects' import { RoundStatus } from '@/api/round' import { CartItem } from '@/api/contributions' +import { getTokenLogo } from '@/utils/tokens' import WalletModal from '@/components/WalletModal.vue' -import InputButton from '@/components/InputButton.vue' @Component({ components: { WalletModal, - InputButton, }, }) export default class AddToCartButton extends Vue { @@ -104,11 +108,6 @@ export default class AddToCartButton extends Vue { this.$store.commit(TOGGLE_EDIT_SELECTION, true) } - get isAmountValid(): boolean { - const currentRound = this.$store.state.currentRound - return isContributionAmountValid(this.amount.toString(), currentRound) - } - handleSubmit(): void { if (this.hasContributeBtn() && this.currentUser) { this.contribute() @@ -140,5 +139,66 @@ export default class AddToCartButton extends Vue { toggleCartPanel() { this.$store.commit(TOGGLE_SHOW_CART_PANEL, true) } + + get tokenLogo(): string { + const { nativeTokenSymbol } = this.$store.state.currentRound + return getTokenLogo(nativeTokenSymbol) + } } + + diff --git a/vue-app/src/components/BackLink.vue b/vue-app/src/components/BackLink.vue index daa4be352..4d679f397 100644 --- a/vue-app/src/components/BackLink.vue +++ b/vue-app/src/components/BackLink.vue @@ -31,7 +31,7 @@ export default class extends Vue { justify-content: flex-start; align-items: center; padding: 1rem; - color: var(--text-color); + color: #fff; &:hover { opacity: 0.8; } diff --git a/vue-app/src/components/Breadcrumbs.vue b/vue-app/src/components/Breadcrumbs.vue index e33ea6a9c..dc0a8fd3c 100644 --- a/vue-app/src/components/Breadcrumbs.vue +++ b/vue-app/src/components/Breadcrumbs.vue @@ -59,7 +59,7 @@ export default class Breadcrumbs extends Vue { } .link { - color: var(--text-color); + color: #fff; &:hover { opacity: 0.8; } diff --git a/vue-app/src/components/BrightIdWidget.vue b/vue-app/src/components/BrightIdWidget.vue index 9c1de75c3..61d16f374 100644 --- a/vue-app/src/components/BrightIdWidget.vue +++ b/vue-app/src/components/BrightIdWidget.vue @@ -132,7 +132,7 @@ export default class BrightIdWidget extends Vue { @import '../styles/theme'; .setup-container { - background: var(--bg-secondary-color); + background: $bg-secondary-color; border-radius: 0.5rem; padding: 0.5rem 0; width: auto; @@ -160,7 +160,7 @@ export default class BrightIdWidget extends Vue { line-height: 0; } .unverified { - color: var(--warning-color); + color: $warning-color; } .brightid-verified { color: $clr-green; @@ -188,7 +188,7 @@ export default class BrightIdWidget extends Vue { } .bright-id-widget-container { - background: var(--bg-secondary-color); + background: $bg-secondary-color; border-radius: 0.5rem; width: auto; @@ -220,7 +220,7 @@ export default class BrightIdWidget extends Vue { line-height: 0; } .unverified { - color: var(--warning-color); + color: $warning-color; } .brightid-verified { color: $clr-green; @@ -251,30 +251,30 @@ export default class BrightIdWidget extends Vue { width: 100%; border-radius: 2rem; height: 0.5rem; - background: $gradient-inactive; + background: $clr-pink-light-gradient-inactive; margin: 1rem 0rem; .quarter { width: 25%; - background: $gradient-highlight; + background: $clr-pink-light-gradient; height: 0.5rem; border-radius: 2rem; } .half { width: 50%; - background: $gradient-highlight; + background: $clr-pink-light-gradient; height: 0.5rem; border-radius: 2rem; } .three-quarters { width: 75%; - background: $gradient-highlight; + background: $clr-pink-light-gradient; height: 0.5rem; border-radius: 2rem; } .full { width: 100%; - background: $gradient-highlight; + background: $clr-pink-light-gradient; height: 0.5rem; border-radius: 2rem; } diff --git a/vue-app/src/components/CallToActionCard.vue b/vue-app/src/components/CallToActionCard.vue index 1b9e2d1b8..c60ce1b06 100644 --- a/vue-app/src/components/CallToActionCard.vue +++ b/vue-app/src/components/CallToActionCard.vue @@ -87,8 +87,8 @@ export default class CallToActionCard extends Vue { @import '../styles/theme'; .get-prepared { - background: var(--bg-secondary-color); - border: 1px solid var(--border-strong); + background: $bg-secondary-color; + border: 1px solid #000000; border-radius: 8px; display: flex; flex-direction: column; diff --git a/vue-app/src/components/Cart.vue b/vue-app/src/components/Cart.vue index 5266c3971..651d56631 100644 --- a/vue-app/src/components/Cart.vue +++ b/vue-app/src/components/Cart.vue @@ -47,16 +47,12 @@ />
@@ -303,7 +299,7 @@ diff --git a/vue-app/src/components/FormProgressWidget.vue b/vue-app/src/components/FormProgressWidget.vue index 36c421610..f40276ddc 100644 --- a/vue-app/src/components/FormProgressWidget.vue +++ b/vue-app/src/components/FormProgressWidget.vue @@ -16,11 +16,7 @@ @click="handleStepNav(step)" >