diff --git a/groth16/example/example.nim b/groth16/example/example.nim index fd610f2..a431a86 100644 --- a/groth16/example/example.nim +++ b/groth16/example/example.nim @@ -4,15 +4,15 @@ import groth16/files/export_json #------------------------------------------------------------------------------- -proc exampleProveAndVerify() = +proc exampleProveAndVerify() = let zkey_fname : string = "./build/product.zkey" let wtns_fname : string = "./build/product.wtns" - let proof = testProveAndVerify( zkey_fname, wtns_fname) - + let (_, proof) = testProveAndVerify( zkey_fname, wtns_fname) + exportPublicIO( "./build/nim_public.json" , proof ) exportProof( "./build/nim_proof.json" , proof ) #------------------------------------------------------------------------------- when isMainModule: - exampleProveAndVerify() \ No newline at end of file + exampleProveAndVerify() diff --git a/groth16/example/product.circom b/groth16/example/product.circom index b1bb644..a0b5283 100644 --- a/groth16/example/product.circom +++ b/groth16/example/product.circom @@ -30,7 +30,7 @@ template Main(n) { component prod = Product(n); inp ==> prod.inp; out <== prod.out + plus; - log("out =",out); + // log("out =",out); out === 2023; } diff --git a/groth16/files/export_json.nim b/groth16/files/export_json.nim index cc1c0c6..5f6fa15 100644 --- a/groth16/files/export_json.nim +++ b/groth16/files/export_json.nim @@ -3,19 +3,23 @@ # export proof and public input in `circom`-compatible JSON files # -import pkg/constantine/math/arithmetic except Fp, Fr -#import constantine/math/io/io_fields except Fp, Fr +import pkg/constantine/math/arithmetic +import pkg/constantine/math/io/io_fields +# import pkg/constantine/math/config/curves + +import pkg/constantine/named/properties_fields +import pkg/constantine/math/extension_fields/towers import groth16/bn128 from groth16/prover import Proof #------------------------------------------------------------------------------- -func toQuotedDecimalFp(x: Fp): string = +func toQuotedDecimalFp(x: Fp[BN254Snarks]): string = let s : string = toDecimalFp(x) return ("\"" & s & "\"") -func toQuotedDecimalFr(x: Fr): string = +func toQuotedDecimalFr(x: Fr[BN254Snarks]): string = let s : string = toDecimalFr(x) return ("\"" & s & "\"") @@ -24,7 +28,7 @@ func toQuotedDecimalFr(x: Fr): string = # exports the public input/output into as a JSON file proc exportPublicIO*( fpath: string, prf: Proof ) = - # debugPrintFrSeq("public IO",prf.publicIO) + debugPrintFrSeq("public IO",prf.publicIO) let n : int = prf.publicIO.len assert( n > 0 )