# # export proof and public input in `circom`-compatible JSON files # import constantine/math/arithmetic except Fp, Fr #import constantine/math/io/io_fields except Fp, Fr import groth16/bn128 from groth16/prover import Proof #------------------------------------------------------------------------------- func toQuotedDecimalFp(x: Fp): string = let s : string = toDecimalFp(x) return ("\"" & s & "\"") func toQuotedDecimalFr(x: Fr): string = let s : string = toDecimalFr(x) return ("\"" & s & "\"") #------------------------------------------------------------------------------- # exports the public input/output into as a JSON file proc exportPublicIO*( fpath: string, prf: Proof ) = # debugPrintFrSeq("public IO",prf.publicIO) let n : int = prf.publicIO.len assert( n > 0 ) assert( bool(prf.publicIO[0] == oneFr) ) let f = open(fpath, fmWrite) defer: f.close() # note: we start from 1 because the 0th element is the constant 1 "variable", # which is automatically added by the tools for i in 1..