mirror of https://github.com/vacp2p/zerokit.git
parent
f6b428fb24
commit
1129611b0e
|
@ -53,36 +53,40 @@ fn groth16_proof_example() -> Result<()> {
|
|||
let trace = ConstraintTrace::capture();
|
||||
println!("Trace is: {:?}", trace);
|
||||
|
||||
// XXX: Weird mix here
|
||||
// From poseidon-tornado JSON witness
|
||||
let input_json_str = r#"
|
||||
{"root":"0x11cd2b4d61ad61dee506cac59c657e269cbbf5fbd548cd2f1d41dedaf4293748",
|
||||
"nullifierHash":"0x285edfd6d2499ea9eea742d4ece6a4668efbbf93b4c2194d9e086997ad59aa4f",
|
||||
"recipient":"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
|
||||
"relayer":"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
||||
"fee":0,
|
||||
"nullifier":"34284017061184348684424679404576688",
|
||||
"pathElements":["21663839004416932945382355908790599225266501822907911457504978515578255421292",
|
||||
"0x13e37f2d6cb86c78ccc1788607c2b199788c6bb0a615a21f2e7a8e88384222f8",
|
||||
"0x217126fa352c326896e8c2803eec8fd63ad50cf65edfef27a41a9e32dc622765",
|
||||
"0x0e28a61a9b3e91007d5a9e3ada18e1b24d6d230c618388ee5df34cacd7397eee",
|
||||
"0x27953447a6979839536badc5425ed15fadb0e292e9bc36f92f0aa5cfa5013587",
|
||||
"0x194191edbfb91d10f6a7afd315f33095410c7801c47175c2df6dc2cce0e3affc",
|
||||
"0x1733dece17d71190516dbaf1927936fa643dc7079fc0cc731de9d6845a47741f",
|
||||
"0x267855a7dc75db39d81d17f95d0a7aa572bf5ae19f4db0e84221d2b2ef999219",
|
||||
"0x1184e11836b4c36ad8238a340ecc0985eeba665327e33e9b0e3641027c27620d",
|
||||
"0x0702ab83a135d7f55350ab1bfaa90babd8fc1d2b3e6a7215381a7b2213d6c5ce",
|
||||
"0x2eecc0de814cfd8c57ce882babb2e30d1da56621aef7a47f3291cffeaec26ad7",
|
||||
"0x280bc02145c155d5833585b6c7b08501055157dd30ce005319621dc462d33b47",
|
||||
"0x045132221d1fa0a7f4aed8acd2cbec1e2189b7732ccb2ec272b9c60f0d5afc5b",
|
||||
"0x27f427ccbf58a44b1270abbe4eda6ba53bd6ac4d88cf1e00a13c4371ce71d366",
|
||||
"0x1617eaae5064f26e8f8a6493ae92bfded7fde71b65df1ca6d5dcec0df70b2cef",
|
||||
"0x20c6b400d0ea1b15435703c31c31ee63ad7ba5c8da66cec2796feacea575abca",
|
||||
"0x09589ddb438723f53a8e57bdada7c5f8ed67e8fece3889a73618732965645eec",
|
||||
"0x0064b6a738a5ff537db7b220f3394f0ecbd35bfd355c5425dc1166bf3236079b",
|
||||
"0x095de56281b1d5055e897c3574ff790d5ee81dbc5df784ad2d67795e557c9e9f",
|
||||
"0x11cf2e2887aa21963a6ec14289183efe4d4c60f14ecd3d6fe0beebdf855a9b63"
|
||||
],
|
||||
"pathIndices":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
|
||||
{
|
||||
"root": "997081082615117049959303490727516834793837256674870965970007115055033892616",
|
||||
"nullifierHash": "13905360060976153554846115832161423551611834206350930827157109583498962839437",
|
||||
"recipient": "344073830386746567427978432078835137280280269756",
|
||||
"relayer": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
|
||||
"fee": 0,
|
||||
"nullifier": "1249796195936770466725690800614346988",
|
||||
"pathElements": [
|
||||
"21663839004416932945382355908790599225266501822907911457504978515578255421292",
|
||||
"8995896153219992062710898675021891003404871425075198597897889079729967997688",
|
||||
"15126246733515326086631621937388047923581111613947275249184377560170833782629",
|
||||
"6404200169958188928270149728908101781856690902670925316782889389790091378414",
|
||||
"17903822129909817717122288064678017104411031693253675943446999432073303897479",
|
||||
"11423673436710698439362231088473903829893023095386581732682931796661338615804",
|
||||
"10494842461667482273766668782207799332467432901404302674544629280016211342367",
|
||||
"17400501067905286947724900644309270241576392716005448085614420258732805558809",
|
||||
"7924095784194248701091699324325620647610183513781643345297447650838438175245",
|
||||
"3170907381568164996048434627595073437765146540390351066869729445199396390350",
|
||||
"21224698076141654110749227566074000819685780865045032659353546489395159395031",
|
||||
"18113275293366123216771546175954550524914431153457717566389477633419482708807",
|
||||
"1952712013602708178570747052202251655221844679392349715649271315658568301659",
|
||||
"18071586466641072671725723167170872238457150900980957071031663421538421560166",
|
||||
"9993139859464142980356243228522899168680191731482953959604385644693217291503",
|
||||
"14825089209834329031146290681677780462512538924857394026404638992248153156554",
|
||||
"4227387664466178643628175945231814400524887119677268757709033164980107894508",
|
||||
"177945332589823419436506514313470826662740485666603469953512016396504401819",
|
||||
"4236715569920417171293504597566056255435509785944924295068274306682611080863",
|
||||
"8055374341341620501424923482910636721817757020788836089492629714380498049891"
|
||||
],
|
||||
"pathIndices": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
}
|
||||
"#;
|
||||
|
||||
let witness_input : WitnessInput = serde_json::from_str(input_json_str).expect("JSON was not well-formatted");
|
||||
|
@ -98,29 +102,22 @@ fn groth16_proof_example() -> Result<()> {
|
|||
|
||||
builder.push_input(
|
||||
"root",
|
||||
BigInt::parse_bytes(
|
||||
witness_input.root.strip_prefix("0x").unwrap().as_bytes(),
|
||||
16,
|
||||
)
|
||||
.unwrap(),
|
||||
BigInt::parse_bytes(witness_input.root.as_bytes(), 10).unwrap(),
|
||||
);
|
||||
|
||||
builder.push_input(
|
||||
"nullifierHash",
|
||||
BigInt::parse_bytes(
|
||||
witness_input.nullifier_hash.strip_prefix("0x").unwrap().as_bytes(),
|
||||
16,
|
||||
)
|
||||
.unwrap(),
|
||||
BigInt::parse_bytes(witness_input.nullifier_hash.as_bytes(), 10).unwrap(),
|
||||
);
|
||||
|
||||
builder.push_input(
|
||||
"recipient",
|
||||
BigInt::parse_bytes(
|
||||
witness_input.recipient.strip_prefix("0x").unwrap().as_bytes(),
|
||||
16,
|
||||
)
|
||||
.unwrap(),
|
||||
// BigInt::parse_bytes(
|
||||
// witness_input.recipient.strip_prefix("0x").unwrap().as_bytes(),
|
||||
// 16,
|
||||
// )
|
||||
// .unwrap(),
|
||||
BigInt::parse_bytes(witness_input.recipient.as_bytes(), 10).unwrap(),
|
||||
);
|
||||
|
||||
builder.push_input(
|
||||
|
@ -146,17 +143,10 @@ fn groth16_proof_example() -> Result<()> {
|
|||
|
||||
// XXX We have a mix here - conditionally push? seems smelly
|
||||
for v in witness_input.path_elements.iter() {
|
||||
if v.starts_with("0x") {
|
||||
builder.push_input(
|
||||
"pathElements",
|
||||
BigInt::parse_bytes(v.strip_prefix("0x").unwrap().as_bytes(), 16,).unwrap(),
|
||||
);
|
||||
} else {
|
||||
builder.push_input(
|
||||
"pathElements",
|
||||
BigInt::parse_bytes(v.as_bytes(), 10).unwrap(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for v in witness_input.path_indices.iter() {
|
||||
|
|
Loading…
Reference in New Issue