From ab34a5b88bee7dfcd11a7082975638a466af487f Mon Sep 17 00:00:00 2001 From: Jeeiii Date: Thu, 22 Feb 2024 21:08:13 +0100 Subject: [PATCH] refactor: remove nullifier from poseidon-proof circuit BREAKING CHANGE: The nullifier can be computed outside of the circuits by using the scope and digest, resulting in an optimized circuit. closes #136 --- .../circuits/circom/poseidon-proof.circom | 10 +- .../circuits/tests/poseidon-proof.test.ts | 8 +- packages/poseidon-proof/src/generate.ts | 3 +- packages/poseidon-proof/src/types/index.ts | 1 - .../poseidon-proof/src/verification-keys.json | 402 +++++++----------- packages/poseidon-proof/src/verify.ts | 7 +- packages/poseidon-proof/tests/index.test.ts | 2 - 7 files changed, 171 insertions(+), 262 deletions(-) diff --git a/packages/circuits/circom/poseidon-proof.circom b/packages/circuits/circom/poseidon-proof.circom index ab41a8cf2..6e82ecf18 100644 --- a/packages/circuits/circom/poseidon-proof.circom +++ b/packages/circuits/circom/poseidon-proof.circom @@ -8,8 +8,8 @@ include "poseidon.circom"; // for zero-knowledge proof contexts. A parameter is defined to specify // the number of inputs a Poseidon hash function can support // (i.e. 'NUMBER_OF_INPUTS'). -// A scope value can be used to define a nullifier to prevent the same -// proof from being re-used twice. +// A scope value can be used to externally compute a nullifier to prevent +// the same proof from being re-used twice. template PoseidonProof(NUMBER_OF_INPUTS) { // The circuit takes two inputs: the pre-images and an additional scope parameter. signal input preimages[NUMBER_OF_INPUTS]; @@ -22,8 +22,6 @@ template PoseidonProof(NUMBER_OF_INPUTS) { signal output digest; digest <== Poseidon(NUMBER_OF_INPUTS)(preimages); - // A nullifier is also computed using both the scope and the digest, providing a value - // to prevent the same proof from being reused twice. - signal output nullifier; - nullifier <== Poseidon(2)([scope, digest]); + // Dummy constraint to prevent compiler from optimizing it. + signal dummySquare <== scope * scope; } diff --git a/packages/circuits/tests/poseidon-proof.test.ts b/packages/circuits/tests/poseidon-proof.test.ts index 99a93d3a6..8405954bf 100644 --- a/packages/circuits/tests/poseidon-proof.test.ts +++ b/packages/circuits/tests/poseidon-proof.test.ts @@ -1,15 +1,14 @@ import { WitnessTester } from "circomkit" -import { poseidon2, poseidon3 } from "poseidon-lite" +import { poseidon3 } from "poseidon-lite" import { circomkit } from "./common" describe("poseidon-proof", () => { - let circuit: WitnessTester<["preimages", "scope"], ["digest", "nullifier"]> + let circuit: WitnessTester<["preimages", "scope"], ["digest"]> const numberOfInputs = 3 const preimages = [1, 2, 3] const scope = 2 const digest = poseidon3(preimages) - const nullifier = poseidon2([scope, digest]) const INPUT = { preimages, @@ -17,8 +16,7 @@ describe("poseidon-proof", () => { } const OUTPUT = { - digest, - nullifier + digest } before(async () => { diff --git a/packages/poseidon-proof/src/generate.ts b/packages/poseidon-proof/src/generate.ts index e621def06..ce924483b 100644 --- a/packages/poseidon-proof/src/generate.ts +++ b/packages/poseidon-proof/src/generate.ts @@ -9,7 +9,7 @@ import { PoseidonProof, SnarkArtifacts } from "./types" /** * Creates a zero-knowledge proof to prove that you have the preimages of a hash, * without disclosing the actual preimages themselves. - * The use of a scope parameter along with a nullifier helps ensure the uniqueness + * The use of a scope parameter helps ensure the uniqueness * and non-reusability of the proofs, enhancing security in applications like * blockchain transactions or private data verification. * If, for example, this package were used with Semaphore to demonstrate possession @@ -44,7 +44,6 @@ export default async function generate( return { scope: BigNumber.from(scope).toString() as NumericString, digest: publicSignals[0], - nullifier: publicSignals[1], proof: packProof(proof) } } diff --git a/packages/poseidon-proof/src/types/index.ts b/packages/poseidon-proof/src/types/index.ts index e97483d62..260d187fa 100644 --- a/packages/poseidon-proof/src/types/index.ts +++ b/packages/poseidon-proof/src/types/index.ts @@ -8,7 +8,6 @@ export type SnarkArtifacts = { export type PoseidonProof = { scope: NumericString digest: NumericString - nullifier: NumericString proof: PackedProof } diff --git a/packages/poseidon-proof/src/verification-keys.json b/packages/poseidon-proof/src/verification-keys.json index db15a1c49..219fee429 100644 --- a/packages/poseidon-proof/src/verification-keys.json +++ b/packages/poseidon-proof/src/verification-keys.json @@ -1,7 +1,7 @@ { "protocol": "groth16", "curve": "bn128", - "nPublic": 3, + "nPublic": 2, "vk_alpha_1": [ "20491192805390485299153009773594534940189261866228447918068658471970481763042", "9383485363053290200918347156157836566562967994039712273449902621266178545958", @@ -32,177 +32,177 @@ "vk_delta_2": [ [ [ - "11435398769033176443487359096543239312464274789946279258549626330915915881306", - "12859727255817857457931574581953929257112904138765493283765188256562183128436" + "13706475760348979760036830132895651891430491737107219958621176809506362280128", + "15094254295547289439942981393834758601507709856123816894081402319319067362603" ], [ - "17428388494135987195466322945224179029777784308198146069920085571537261888751", - "13712706251123768274632201984924934698027620796555310139251269380749829309855" + "17472468538458053188561218268165771051639899613697516029120202247645120422701", + "9611658009779480807948574640638964844469564302868418561739992055788900932440" ], ["1", "0"] ], [ [ - "5534367195856019704532237857260233027421720051858263162488448477768676720442", - "21844244547581448055984603302714157363812536084988631000708099557168324813672" + "15180666788705534827610422737971222956058023161017804972893229120603150084955", + "1188397086375426276137519109903162790662567818704468623545423081800470081929" ], [ - "964067162049981161072950653638026212015281369641658508830812331127443123637", - "17206248939056274926228703076030237438560877174151026709641216982232202850252" + "3737810741722771095299202430101123098062130705975685029086383839858766968358", + "4983412009368596099583857839039148741839212880019282834842756226581733611611" ], ["1", "0"] ], [ [ - "4668992425576668825196218100944726211430646232261214386515529483217963979333", - "13651931748728354054751273358212700435370680618848791456073898937286795403002" + "6211041026018748191163906117178155784175962691243500460169640118124452284231", + "17696448039619648997097518949287333460247451463117808440030519649067365464316" ], [ - "18071342182836114972637211631654984373590050112268547887057231535751943330224", - "13368214792906767472186307170623739481252298306917183478705202541188665191714" + "4694150310306281406024151693082549614597412869848307724864440890121133836524", + "14440068243910328404000992063301586075121227158898928167215939090557336765482" ], ["1", "0"] ], [ [ - "4157804045398202412989509892267036179476995703193606156138529680772398705665", - "20378971087548375623310427850910145059752143003401617059285995667590489621625" + "14193821257031041430231358593800492638909684058022317080509744583977675366832", + "10876379014653354623732114659569294940564984325729163201568689357439498542930" ], [ - "15223605876340906238418591769148861103488850973744270265275409828645511933532", - "7964904734523150760482714268314173621890333434791331227448338339404329623444" + "10595072504420925738131095919486520165643951324697929736534159142453919260763", + "3454845048774741983752146266576153838996767674208500946172152148094511835905" ], ["1", "0"] ], [ [ - "4505253029324102500370754029745931605932609582360001047069854977487819676501", - "19248209891324803783169712137319248334080357468609265525541215351119835930809" + "1003892686954891785289839116329667185817159239506774436619099189529939041155", + "2048554130836948199097313619535151646623815860862265051887872449243408398716" ], [ - "9076659752050958963336722574446643311412298429604462238150478552804784315723", - "20988733150892785387963886077607882377537976837273930563557275860140311531306" + "4318997748563778256507392799636547197157436229273000606489915385570697153121", + "19965821763797383443005801468643400526335031871581290810839074333215915406487" ], ["1", "0"] ], [ [ - "14781746472758277172427890109156349054823989142773743858405439298344170550775", - "954959007121709021658263166227759467308574279843217040607180270739926874742" + "15105765114956680836202210865231598967911397891786741290322437544189547676069", + "2538517056712117700030178042637069279845990264890526820288638680819397475661" ], [ - "11284895417037349651460895288571972449959159175346486699083096685831165832382", - "12591183239050625008259152001488995663931321037641236514495372181975154365547" + "18786175189553096411319802476068302093927016621109621952471523317418867111033", + "11118998069112172383489570967948360694059714536079444439788716867327601952550" ], ["1", "0"] ], [ [ - "16293136162310406400194256601143515519796617403158525642581949756487500025212", - "10017565205928362935185148999883194462653580211178499384808215357263781021164" + "20224324394147974445779565962971950632962554757530491483681462130445623352765", + "772834050376066155784310347981559455633842948269967582007664546083952408842" ], [ - "7746436023647347605144535867336348484771413154273647307971777208058878375752", - "13732275579943349018512757950079138848227830240954796247236942962126503473869" + "587231629154336209117977728475360391033648110237882997857636585583099252369", + "8156364543337382412065835984008571522890186133149360637585592814441052989754" ], ["1", "0"] ], [ [ - "16610408376063803121644082650815955849492323013237913724571923369319112796337", - "17421986376545073491324576483716172544487541295687688876759253459070975826569" + "9588145097807616139806255459174523584399805047922458106080377362933935185769", + "6026000143945998675552149766329809690660791270086899201587495944007453963347" ], [ - "617789820605474513134955868134530301793239646372202959313764758056730545890", - "20730570877381609592906890389047816315265516604375758674840981565690556860142" + "15264150390135947870842827119463843726672893780143494505046740339336093366699", + "15523361548983791715932687123569178951275102244621508161625013683787254886505" ], ["1", "0"] ], [ [ - "14779761122833911994145268431865098548464190152934151633551952898307451468622", - "21885074913662574366766611868599556435133037207704797458177310258680098848802" + "3486745667680205672380019263514710300262728136652076492333254046099735699561", + "973879074474437021110465509434796545239232969887114143741170087941907614386" ], [ - "1775320730697052465302461203666649666838142028135533450929773360092777235537", - "19613011329725026519327040538751862194606710787679053967278954231134701869491" + "19221738248747450008801118888473856216956413377039324068898288016724020077178", + "19928750574388854086719009301005254042688918602684673384046393958626050880463" ], ["1", "0"] ], [ [ - "12643590910892687140935022856160483308540292915163005946229017738186744764205", - "14946293602659757389097534740523522554271047961827027944219555386995708763749" + "16735010820086440457822128600860506459990848760928948998677658671284641680963", + "7937712084823346326392481190972656358275773550148656270785512287375696655778" ], [ - "3998462903977597474588680434747118696593954375630828511552734527452683152368", - "11361970791040737011260650810479049684887022904777016659116098755945236589285" + "3257111810373607833130194420207613638319621703687656308032660729147165306684", + "8080623892303381379471296001408428971090395719052751791967004968894517526394" ], ["1", "0"] ], [ [ - "4612360618060236051289367223064667860248165416436378783015366953553401823647", - "7990236769268360144756382788896248968488317621973937503247459981110000029620" + "35030490672781228124533603032626008638139887250038393694172399695097818202", + "13022101738995931139921019845290549216603353789758353928016647555206190702928" ], [ - "10551645860237386774015586664155122092180459296336545497167761525789744590241", - "3668539144495593441100164350314287515294957676795860990866801714468121783681" + "15646293047440613625912023853894166039961922480354753250479753527892426757710", + "13419602005611044580692931509922344039391713877846013336412192194494195867848" ], ["1", "0"] ], [ [ - "3137137543148515634035560960393315447170374418997788439099876181306583356097", - "4792475235279995194263776002140899287715640022343103264252160797355039116581" + "11512154716943179621127741535888355122618126528504984792632463393864126008061", + "2178219644666255569220492548528637985903642915837303417325446256900749043701" ], [ - "1900103000352506792156350490804859740694428751352676827186095716087674406300", - "2583636096620868859508522553872775301465585058759815676638510118445458290168" + "788731803577442368448609173252962986339560724309698965677024701609911443637", + "5737934927786107811248750101457662106085184518848705086852615307177934599309" ], ["1", "0"] ], [ [ - "1434653571380747654094973668897521879746310679429721602769931293155149612796", - "3007782663245243352388675360542480997352411998678077095352184817286162543559" + "18257194318692896308745576039437647331257011226564483433086650421046318407806", + "17506882052276945845187329696321964532711476188006089198454749961446808405720" ], [ - "10928828933163423412538353503095846407975065923463324135529141629476475842539", - "4138031756040872373432029956945082406673806184559096003686806595546208140427" + "3536562505411576195780948964724932192916330638961417184885152510348674608201", + "18190009899872985856863492559738353313633428842354802978966237879451252642905" ], ["1", "0"] ], [ [ - "9327989283511458216572255435238035279306904088311807349908910451751104996151", - "21422879721713017217743402268497657472728846107605085438504611672493978487791" + "16546337281054866043515426698314217271507447374392786624208659036445884156594", + "3120905705409001137978298173991770910603543584072180907701344975205611550314" ], [ - "5332141095854676533471436168521302605517694258634935206643127829982572318399", - "16524800456620845928685824535075079130012236476445648985080764380321215147528" + "10555933778717815873380035333114291715678986583375405555723279122922324038407", + "2896189065474187800133294952821664399120580893757838223278485520249036482597" ], ["1", "0"] ], [ [ - "3866902382703480098390805488238281838157010609968981252981706952179468074497", - "1080718911986891347740421992873265581741205931819815179232904800606787269358" + "3026288273069384324071143122068968036616025200747850467104893129503675220411", + "8744116588788634626342323016437456090745524919721896268429888897209902525525" ], [ - "13131194441949903901405825462658603835247520170862765966190962371703995609662", - "19778581273641615797461460196894136166476702013515522431745946450916051257557" + "7849496130697821859109161813243343499709542871530989602818475312489560728108", + "14887336996614953825581710705593593104354930474962017366343388578993699081126" ], ["1", "0"] ], [ [ - "16606581604666847097737240107889671230011501751676373132575118946181810798001", - "19831487023231976883504782789517092434312232415792416528409785316117638307512" + "3690425969979591046911013328616404896021771118499376399856938790389173593466", + "2933066416177670820313394209576390670642997566064220267324974784872140417347" ], [ - "4915397317854797743676000398737806240909188493447442534342134660312549624514", - "9698686202069682185424217393865534924379449543110499615311634174783619445626" + "15770365350783203379305503176400894252352489685188765698118141075675371145178", + "20143372781510612013237176910002489335593925776546814410387131354374493170367" ], ["1", "0"] ] @@ -240,353 +240,273 @@ "IC": [ [ [ - "10540353245037691655240058832465935071147222378795512774896416883563614389198", - "20042286059857913285646233979306226083538103143380748863555356103197961213823", + "19490069286251317200471893224761952280235157078692599655063040494106083015102", + "15613730057977833735664106983317680013118142165231654768046521650638333652991", "1" ], [ - "5831260214145524146501320942030802135386415386731869532840770699430145685903", - "10936406497477698856797103676487112559914492317404578945377836522823774186039", + "1563543155852853229359605494188815884199915022658219002707722789976065966419", + "858819375930654753672617171465307097688802650498051619587167586479724200799", "1" ], [ - "1295407852409244811850984901965423450287105807829809873962419792828349329577", - "11301654800484264796111478656697951131719015244071014736702281514571505462297", - "1" - ], - [ - "6823739927950557742246913693052072220213742766782370219666937126411380340633", - "19878777316727584245579797737044924949420447706770682437221414501064053790692", + "3808889614445935800597561392085733302718838702771107544944545050886958022904", + "13293649293049947010793838294353767499934999769633605908974566715226392122400", "1" ] ], [ [ - "5242614605512579710797834332189953700725021866961352777376090045439043674857", - "11181649137001515609817854211524749444285873692523445362324285633380935722379", - "1" - ], - [ - "15882982032365656309429962180148400353947472431560068803176671873961561034392", - "6261094856557877680548248976851704355640453722635285375539604518856348524137", + "16314216713263812259250797674288246089499962988847721936436321307378336592095", + "11117018508219521589294010525047040473526927855655175840819026305851777765475", "1" ], [ - "11717969162643492078448139958094222576451399844648683398952335034663203268989", - "18875460821706374217359397986634801455343560030907089104133727050541866342790", + "1489322533177716064948875575926922312447753206440552240050276050387942900438", + "12165171936521766159101308675345703232678022163590860407018275007604526533982", "1" ], [ - "11564513239444124759564596307950189410962425639272500318420328570752510309502", - "19096392203471238234648344888019712959430634588442239805290432303947310082323", + "6960512141760522400088094283402946234174678264161998436678471144494429317205", + "20452221478986281611081187536083135297872601218015116497971140905889313743165", "1" ] ], [ [ - "21120704080725444977994415060625231020953242159275516356545631588335510554993", - "2653625781550479147177876934468426279555459876822234647393078110039343224440", + "5777689742082005715270723054664547692838725793611115367188093577876286319897", + "10454075320040159670083485671678517137046698003354189208581600890161008983741", "1" ], [ - "18822744204838381885065659496024864759186974324521165481966336677426489096369", - "21460030554750748334655777714813591413293578026926128104979719949479594711473", + "2642098050452795834338379096531211995188230502015980900343056782376948339687", + "14124928114351826183770480091879839058993316965479121067425548494569501532377", "1" ], [ - "18110952578401484000952293155663116061060443880743703532393374785134906513663", - "20157851394978769948831441506200349920379228523696724748243798406022689916037", - "1" - ], - [ - "15209159506516900332826495478169042130999279524477269510109073758156017770529", - "15992574404053283203110611383353931924326277403138611380297575595662612534172", + "15148305354610832828183744524377641188304327550206135491675778059310640673138", + "4893932453452103247939341257230497114673566246321965048356049178501986246725", "1" ] ], [ [ - "14014421044779723561363735328880559672641788811582510427726550314635931023644", - "13467715607733979845566874761302147324336867405138554848358740127558133751785", - "1" - ], - [ - "15012759557637006526840841766096686867165903691763460445126105346881061285100", - "12797551550346158579151227916744122630165513691915495752825533807189323704658", + "20915408346262913832848096115897083424191782014558753292028210172329556489891", + "20477324302289652567921221514286340472175521364608819396373915910203052137234", "1" ], [ - "20313635280656705627379428582894389867518770374004005221923800750018168186076", - "12759248162736063970843352718145299967829311932234155037352548039410195461617", + "18109741480520484438583085965849393053790689016366934256867378379242288457686", + "13619404282196516647345713373498249513238472014983969488668509336400876494311", "1" ], [ - "2275663311281049839342268164093419925254508481077490270916487802489791672120", - "713997569999597273034003729002037483748990084574905051202912293366612253839", + "11765051984214979755732420036077340861427462185621265051697279669517347262729", + "17955014055238146126632398568346244655216767709119096967135392509704733491844", "1" ] ], [ [ - "10323366193759838710162535183435644639074947980437244507787968096069618824408", - "6129412118114405510255264632952960532266728438463722437515145876930485881310", + "16481192909169214010392200653283275987325709982486805651427539789368110643965", + "9600634861073295096550032788240078277063249868126439630400649560046604582951", "1" ], [ - "18409823095183452891942208756206259490575556918622063596858362234482241694991", - "12470856401503793292581941695539261190881567378495379275259557070602584959785", + "8716855468226815195040220782769615065622022528430076687863434910949019560115", + "5144800664114113488204783976150442697336491675680169297817164380798395482501", "1" ], [ - "21377449560442270889486427592959547880511727113127981218346002830025764437322", - "20350198774130301283047466266694640012011409673403841486946098055047439215677", - "1" - ], - [ - "12753960208771622521868737254456202267578255916156774957388343435271150481004", - "18318009002815766919029001923938216725357322299750422853851647922883394480966", + "14279736595764028921246337982363760894086288686502096693089864776683515170827", + "6403920333376154835269627270297651759933138762638770910356946391337790253284", "1" ] ], [ [ - "9686715569141011434393080273301239668139040801749502881170316931439733129580", - "8173293043492711525356577384418994006157055834865886711614264854224121437297", - "1" - ], - [ - "10894390050074904141546644593852026412023455722409606764411231689164449748972", - "10688219653621421339550121620887175519860702086329339370119246135141855425561", + "19427312127307233114043544532010141761737668406845711063737151756341969518115", + "19497001261488307700108517382899830645465934586931341109009380207822933853538", "1" ], [ - "19971639706296511378823280898621719926927744851918281297131624217685951712852", - "15236736675116726003407595286560452795757129799303724852288438432641281960720", + "18850362688565117327473227965231396785394256896015207979763863952560092318905", + "19845569423696587838445968823785398846474692097131528981298815653580718689592", "1" ], [ - "6152064961852488500187610009620195565131743282259732203362434639069205631597", - "15648352471534846688416851313673179079996608956368999573269708786747963275589", + "840756707954101069142723209419963051403617828309738249721569313340266702555", + "5780878828618912743300640785478897234401371585090207748306483967163886135973", "1" ] ], [ [ - "17617209650857578062243296798859670543139761896294323984379437758841786001355", - "5517303560405424477652851898637561064575616762901204408327892551156963162266", + "546027003027570802029398089463935069893813566041096597150463996505426053761", + "14014506297856732287662693039958827017385498211983409974050280467221019100956", "1" ], [ - "19676035278400196518554471656929870135280003695695825460768368726233376223141", - "4615368985921173365360619657024139431453693520875133314207373125367392735446", + "11189450817957093937106621030429756748082057026435929105575426657564882386802", + "4509940161802247020195238005432388756974430777298874217078810778762343128329", "1" ], [ - "646901404401129609814900200285994252853841473909067560081800416847810456933", - "11676817909204160058065993659266678516748395946882654783813074549093637321868", - "1" - ], - [ - "4859751292516253218999514246954608804194819250590638419489151345038097291472", - "3130840452423593093131070441509769627492130486000066245718389330705917823455", + "17755051906548101790853642244089657439893646632620305489913721603670784250069", + "8904395938511806014192726926365647143660749609881308620335528629337973923713", "1" ] ], [ [ - "814528634495590838031685794442821804144267515975408891697762715084133408965", - "18871481528013212924839444399238525914877248853383236984047960840543259331023", - "1" - ], - [ - "241916209278866887456362802737732672727784551473592235718254862532158383884", - "824331831860335342202923790667992218839025721569206929655439668934822724808", + "13213356598199847269699632272566750853813594809392061230885705868548131437637", + "895153038996134925237046737026834738970028513999527722413774967155341310435", "1" ], [ - "12716852218543669901923150791222928328112484410938054246666506928566249525358", - "20543720698618630314815420053720576029989350604211221221488458108900797096572", + "471993200552326549203598917362027198173949469152420169709884479126339292271", + "14174598991630085582601473833852162779297438091497079256707119545704654236327", "1" ], [ - "9366951766389957489856806674447963600365403823299116849675572446858153902353", - "2316885093149765297467173168815646569577297067336519829761779241686124159086", + "12711216628891510607753358833453031250654744351039303007840207871043484081967", + "2173441600878949731991469203266793443327643325686272565914594621955348362526", "1" ] ], [ [ - "2185163715755760522724458722395367700514542693843312048990472230796633001486", - "678491364100090020080164675733539206762712894431833334280420153485295123666", + "18887882527574578188655084466752577798014308073107368854351124461973580787910", + "651081314890381475167064795691942982045799761791181574107224090162291115938", "1" ], [ - "11787027923462532841155188707018507915798749166970051156103389208833149601233", - "11854161340757384396036982003439783634345872448394105789575302325399594585817", + "18346790043873442676694511075634026436566932544111333965589071781644561478536", + "17900923331213210712376047327769111823453727818721826870886503477889503452320", "1" ], [ - "21338707413981006724717667831563856275598915128839070734589669439153791496429", - "15003240903045729972245732489571358776688034598681403311195112815780344874496", - "1" - ], - [ - "15172644267142129295488850420265333521282833843444807873691234050704667202387", - "16851812316234239964418522013280176312823419655076507942305784950487982780141", + "8253813990164202614612417399858531257146056572623956512005125798531486848635", + "1912679600385690796934031421829930466203893397004242578775877223967293806293", "1" ] ], [ [ - "13082787509070076799373249832402968030679622079136417890924866461815371119989", - "2796725803350406847570807862943404841825100585533851797299312741545603459748", - "1" - ], - [ - "600435881111513760445591569369924154279892009573011090211563857569225700557", - "3024807350756961795500406054481990295887166666512161218549897863175375396486", + "798266006634704296356807896304782617057267109446481684272074776676559365377", + "2119139191057773416624154862008823601747165120947596460685518302760052477540", "1" ], [ - "21458372851278868119696457162743215229458672291262483987265294689453623819735", - "19128915577584170201167842459266141452264679529987463663847652243037435227152", + "17743954615775269739473094351635203185883870143434239552566169722164063573412", + "4830438380339493939707702694553275524057591153138914848741234629532535265855", "1" ], [ - "763622831480038506246814070582977258756171628025442871923231661899495568610", - "3219660704464333953354124287196256576596113711577493042418161297599669940888", + "3796651289821923027753272300677071875561083096603899517484713434570556592125", + "6095027127012064440741913106185486005983523295112206123623056096004008125125", "1" ] ], [ [ - "1943423927727809935542589412648097037479379857880866999850939616294485224038", - "10683538372937715283971763571683016343097014502813023110829765464109794435341", + "20896314949419669765122080719670563957005377809880391165219112342045724637250", + "4832396215740174951649707718991048955348422076401947958263135738277030640702", "1" ], [ - "20248595786252137567281089387111444210022249423638800711807375039370448531710", - "7735440831386134681411723925967199383223680019665313017278384059849387585287", + "16593634394872419207033083223572861328698354554381035892795187358904450228380", + "9701239775839670407542964511868405320901788463030859950701125893205826970190", "1" ], [ - "13296934291957965046842160314100036607507181879172710236689416319637941796738", - "4470240440026274504513746888077263006816226329772598920349032098359809831728", - "1" - ], - [ - "4053708634185791917945667002054140134946471590516880440239120753546971916521", - "9882306731546375558642270941189734579707135449141710917684765573610117466484", + "9167350343757520738096817169608613527226407725783625898259506700381039420314", + "15333436194900493791133741272915135408304144665526863658315589456211375313779", "1" ] ], [ [ - "7630347473342125580881120799259502730892422751417128263288470548096384508403", - "19008824331610070973678952811816498823914870060788044121060043715104709013158", - "1" - ], - [ - "16022429349188131325100711176021523424253854635967564638316489811866274911329", - "5546146081338173521532836645301087449187189657478263693400677733359788890349", + "16543510929460662532386886546901011043138961778902766992229923474505072642586", + "7288111264950369152610735086150458884933258785894500389698639872930852462663", "1" ], [ - "8394574348713334769879392707566632773917729989384377529403514946195600652074", - "15198135607607159051502140114389780937408542378103224266696264451093178485825", + "1994453756596995022826442237786101382469308865506647442894126417820462624694", + "12283578265208666129358338863068849999489745351625672248537470813852350624388", "1" ], [ - "13382877847105853373542425636604896357289254105539883620067522085789703203857", - "5202085682735807035613217511584164560104913796487886860927083622596044807650", + "15764090122090539610137315975980769027497965597241892197050094573700859685031", + "16127936860826353217400374080861290401287757977000068338683474176835798271546", "1" ] ], [ [ - "6621292033580526445047770079986840309572805387704204494582819337843070208593", - "574535379951440133354578361453801233716501951662000143741418750255957097508", + "6814792559890925047818282843694260141378659909315003118590070069849331402952", + "11487140246612953459078678078682837634162621680655211065906468894225318882237", "1" ], [ - "288985122321302422047178265599335932421742199516061720717125444516305779635", - "7429658141337288494618965392730534418068285512296109737978498924197957645091", + "17360742729430479877984059553981878760229504858672709960462279772992971228248", + "13690322572462596796349153488376752918916016991516526844586250585646241977694", "1" ], [ - "12980342539618318288785689793130161471823796502286901206445060743059739830581", - "14088233877552133757071532367680291298130277036638442211421139523009311555099", - "1" - ], - [ - "9305595116432422088583980777434597321487181667982399932565364469635695612530", - "15005324695096892864597192783774361097192046135793407242179199318768868171597", + "4906588735496489330523967649950093670925034337304754138190133951387294341057", + "5218460120914285994082898891708144613476357035579628488245805720152917550286", "1" ] ], [ [ - "21382054614775972200282791201797411014327172311719138695827887077863311547788", - "20680267821683237191216701322149817548765360484398200019343499369437394717857", - "1" - ], - [ - "10126592945888745496623662166009524518313507218303087023168261797036338254416", - "3573295887665990948106889308699690754841765809079852825178309092620145137519", + "13282248485020570420370930767608741307342877737916403488447236834118682154819", + "13643529490169828084500852304502939907684096114138860997087808495233563072227", "1" ], [ - "10186268032620052698848398466197162685883727825420404354026398480157164287900", - "6032150773409759529000477475244297307523053824224348917410449633073415700479", + "5830864539585072595043466360478712864357530872155710302353766522442537458812", + "19630573211115930246472127117269713022239927640438155481395734635211224817450", "1" ], [ - "14087994699586195495103954613736855164883207427728995627321079804847390584783", - "12448892771324809412190231941533050644524946263464620549986049520862443629648", + "19595834379767327691325219705384917752650436054074663235665180007150886015402", + "21776132326533679474262043062256203971768128822420306261908561590372896137645", "1" ] ], [ [ - "19164044369085180820556821502697146919975387664704507698674362748791809413121", - "16308832702626504019709753822579324212926403763871655850287238183803540959311", + "10672190684358488826593441743377739192693575863202325591312856408936680120020", + "9717978615445017015997632608006427441955061002796104162232282550809107181476", "1" ], [ - "12987940002414025762564557470014647504607541464450457220013313198724845795475", - "13643337655881850897588681303489143236759703031289186457837101384264559181317", + "5828007128983331222838337093606954646925973608593933197261396517201848325094", + "12964702707860770903006771736549085339329027071623624221129924563214896441694", "1" ], [ - "10871683803050713450658292604486655361490779195572520284131181385673348272227", - "6057379832279901876612779584804064905897102758696555878671822563925334307231", - "1" - ], - [ - "1155441738297673584012351503623944368747519291455295331903271162144808734245", - "55289495220370100788123095749893839679215303437968395368525988903942254053", + "11332800322397218917690923441720418652504295099919694685995980166401299180449", + "277445635710795537937356070051610985002729781994507435749406622715010456375", "1" ] ], [ [ - "2467812474205362728420453877030723351709652066283852196569916319520559026650", - "3309182383692895314563504485801270289650755558253722552457169978635116299507", - "1" - ], - [ - "2500673857908744164232363428352656943591320996323339979224347670037010422650", - "2944328926671320048166852222930404674711179800353520762046355957453017901253", + "86775556699891941583123276431604861117607918118921404923042712889138274879", + "14759328092142878568124943477991930809809651785962195940712634115221722222569", "1" ], [ - "20037749193619215095965287258820858404298371475018010442382583602534756710557", - "20963984287705776547612072374335315427691700100133137518230955641134810343322", + "20587317296408903557562082822150306305156789836788233257760942330988928993338", + "12774638026052488480510449004117723866673354480831773481619251986421580001942", "1" ], [ - "12552745675300260691565743820215413850054169710831102915617046739484717211041", - "16897169502142704911348817321992639840384628740562831476206901145161605523824", + "18790156527059336816249174042938006922945801451739084347405900279382431369589", + "20245819713646952948400401365133759240714478548907783423055257617618511044262", "1" ] ] diff --git a/packages/poseidon-proof/src/verify.ts b/packages/poseidon-proof/src/verify.ts index a28d5edeb..297674390 100644 --- a/packages/poseidon-proof/src/verify.ts +++ b/packages/poseidon-proof/src/verify.ts @@ -9,15 +9,12 @@ import verificationKeys from "./verification-keys.json" * @param poseidonProof The Poseidon zero-knowledge proof. * @returns True if the proof is valid, false otherwise. */ -export default function verify( - numberOfInputs: number, - { scope, digest, nullifier, proof }: PoseidonProof -): Promise { +export default function verify(numberOfInputs: number, { scope, digest, proof }: PoseidonProof): Promise { const verificationKey = { ...verificationKeys, vk_delta_2: verificationKeys.vk_delta_2[numberOfInputs - 1], IC: verificationKeys.IC[numberOfInputs - 1] } - return groth16.verify(verificationKey, [digest, nullifier, hash(scope)], unpackProof(proof)) + return groth16.verify(verificationKey, [digest, hash(scope)], unpackProof(proof)) } diff --git a/packages/poseidon-proof/tests/index.test.ts b/packages/poseidon-proof/tests/index.test.ts index bc28425dc..f4130ec87 100644 --- a/packages/poseidon-proof/tests/index.test.ts +++ b/packages/poseidon-proof/tests/index.test.ts @@ -69,12 +69,10 @@ describe("PoseidonProof", () => { fullProof = await generate(currentPreimages, scope) const digest = computePoseidon(currentPreimages.map((preimage) => hash(preimage))) - const nullifier = poseidon2([hash(scope), digest]) expect(fullProof.proof).toHaveLength(8) expect(fullProof.scope).toBe(scope.toString()) expect(fullProof.digest).toBe(digest.toString()) - expect(fullProof.nullifier).toBe(nullifier.toString()) // Verify. const response = await verify(currentPreimages.length, fullProof)