diff --git a/hydra/garaga/definitions.py b/hydra/garaga/definitions.py index 50a9a96c..23537c7a 100644 --- a/hydra/garaga/definitions.py +++ b/hydra/garaga/definitions.py @@ -59,6 +59,8 @@ def find_value_in_string(s: str) -> int | None: """ if s.lower() == "bn128": return CurveID.BN254.value + if s.lower() == "bls12381": + return CurveID.BLS12_381.value for member in CurveID: if s.lower() in member.name.lower() or member.name.lower() in s.lower(): return member.value diff --git a/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_proof_bls12381.json b/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_proof_bls12381.json new file mode 100644 index 00000000..e14b222f --- /dev/null +++ b/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_proof_bls12381.json @@ -0,0 +1,28 @@ +{ + "pi_a": [ + "3485152954408741741926847089831059591383907630239116784995436738189865955120885556199236406038466836214421991680954", + "154860548139734477039420784520046002016510204339418245860838337803315632344536693944277400179443283236943549107802", + "1" + ], + "pi_b": [ + [ + "1189367959700558605915032782653884912231211486629234350578524664401416658006900616682649282456970345937240392951950", + "982972310153498651356609628173968597957580175097204901152956877592722284408961893988898846206769338927010864277897" + ], + [ + "3246777898221659500974166559060565219973325513989979262303831078446971987804400344091345638114129082558119558551753", + "2601576460715211741126146217362567970757072503270754030074152635959268934549623874228792250787598248683494341541345" + ], + [ + "1", + "0" + ] + ], + "pi_c": [ + "1085195810997077937681619424737706995724769918786687525244374537039253071968280399801210562531703830213202372135064", + "1856101469241092608639064972061062850713586209905212394983879031529137271988213302924644800680307370920962192472181", + "1" + ], + "protocol": "groth16", + "curve": "bls12381" +} diff --git a/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_public_bls12381.json b/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_public_bls12381.json new file mode 100644 index 00000000..cb28ef5a --- /dev/null +++ b/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_public_bls12381.json @@ -0,0 +1,3 @@ +[ + "33" +] diff --git a/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_vk_bls12381.json b/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_vk_bls12381.json new file mode 100644 index 00000000..b4677f23 --- /dev/null +++ b/hydra/garaga/starknet/groth16_contract_generator/examples/snarkjs_vk_bls12381.json @@ -0,0 +1,94 @@ +{ + "protocol": "groth16", + "curve": "bls12381", + "nPublic": 1, + "vk_alpha_1": [ + "617719894357822707200338965866967288645916822989814952192128521680407982056935061292695539424789514436737649020570", + "1775573569831396653264686560336309197621289936135046264821117695406799098608560841754755393604030414133628560466572", + "1" + ], + "vk_beta_2": [ + [ + "3190671720697032579966038958043749082431910320185488438584885357799875666538007862225898857680071255183618784274526", + "2109983048617590705863408957465158941209063119456198804564963336478451431685374476111629305482784904783586572857246" + ], + [ + "1307607189905149666129102654072967019627092794077689555202822796396352439021424323347818324960573077183522770267856", + "1900404121357448535297505849416920425024592269018282269140428150423889516785732814217546769869760115347972284687857" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ + "352701069587466618187139116011060144890029952792775240219908644239793785735715026873347600343865175952761926303160", + "3059144344244213709971259814753781636986470325476647558659373206291635324768958432433509563104347017837885763365758" + ], + [ + "1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905", + "927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582" + ], + [ + "1", + "0" + ] + ], + "vk_delta_2": [ + [ + "366852083359495771420573803655070706723887233165902344758249134050725732074986801357894854373787524097680485812160", + "1929292879518777463856044488640461740981505725491596027554586896635088707623734426665110797692856487251503397957282" + ], + [ + "2254598519443759139488766131014151518103540652139959875744365134034290926557579834892936284712306438078601592202835", + "1579781860493165881746712648978923866265169372051099801148285774757263488928119091040455043002626040812019987523163" + ], + [ + "1", + "0" + ] + ], + "vk_alphabeta_12": [ + [ + [ + "1452142021944451817001147821488760980628197809555746492149088759376801558507230381398112130922956796247321861289375", + "3589943335445990207300848887279844052457873229678183531370805993048668299080419850906570256571227243962847710761873" + ], + [ + "3903597354592031103308309118871575021632884960350471330510988979702965789330630890059202001609171434068520258153205", + "3946350093536016351995160752026495035937348552583156252303497900799349531692051040596420119357283952583443910389762" + ], + [ + "2102282561888264062210801164264241839369117163743635507322118155750136113340405089604922100303091868554501721762249", + "2531185738689051206532445179458651900005160607002689799912357857873389589160857097337310452692979772133435166849387" + ] + ], + [ + [ + "268035266762967876874392987406000236382149655324619726254104233887291204086099445046465766838845123428210938888504", + "2284065767947019642521131033343080546417534737660925549949366442700626920713795808783010752157627204943408136876028" + ], + [ + "1076537136017235627643817565337814768374777902297407144864672924447764202619243468694678042650211399863336315675838", + "1887009084884823613240596596478048882143219870470500630710509802045379651327808154628725590953166551541512136377769" + ], + [ + "1046436074149317708619564652103131188371298898561346600949516219491937906176848261764926236247040532660408816935149", + "2498548906947681374488377175516087586952508282368134324705625079446848595370708686705968001763117178823569586185480" + ] + ] + ], + "IC": [ + [ + "3038675585551733423759427014529506635383300842391718374851632488058684610686018372519161362761589617875149189018434", + "3457250587514594213032030450777853834958299643191424041917496003575595361031754963283792975531474621085487370891270", + "1" + ], + [ + "2908373117630088213536346041612807972869015198725869057358798292417391140094075526116715756590056301255114140540096", + "2978460359983701297569278319168561969577969749822291955720738000037752496066084206945259159825701820797945902273048", + "1" + ] + ] +} diff --git a/tests/hydra/starknet/test_groth16_vk_proof_parsing.py b/tests/hydra/starknet/test_groth16_vk_proof_parsing.py index 91103813..25263ba5 100644 --- a/tests/hydra/starknet/test_groth16_vk_proof_parsing.py +++ b/tests/hydra/starknet/test_groth16_vk_proof_parsing.py @@ -12,6 +12,7 @@ "vk_path", [ f"{PATH}/snarkjs_vk_bn254.json", + f"{PATH}/snarkjs_vk_bls12381.json", f"{PATH}/vk_bn254.json", f"{PATH}/vk_bls.json", f"{PATH}/gnark_vk_bn254.json", @@ -36,6 +37,7 @@ def test_proof_parsing(proof_path: str): "proof_path, pub_inputs_path", [ (f"{PATH}/snarkjs_proof_bn254.json", f"{PATH}/snarkjs_public_bn254.json"), + (f"{PATH}/snarkjs_proof_bls12381.json", f"{PATH}/snarkjs_public_bls12381.json"), (f"{PATH}/gnark_proof_bn254.json", f"{PATH}/gnark_public_bn254.json"), ], )