mirror of
https://github.com/logos-storage/nim-groth16.git
synced 2026-01-02 21:53:09 +00:00
52 lines
1.3 KiB
Nim
52 lines
1.3 KiB
Nim
|
|
import ./groth16
|
|
import ./witness
|
|
import ./r1cs
|
|
import ./zkey
|
|
import ./zkey_types
|
|
import ./fake_setup
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
proc testProveAndVerify*( zkey_fname, wtns_fname: string): Proof =
|
|
|
|
echo("parsing witness & zkey files...")
|
|
let witness = parseWitness( wtns_fname)
|
|
let zkey = parseZKey( zkey_fname)
|
|
|
|
# printCoeffs(zkey.coeffs)
|
|
|
|
echo("generating proof...")
|
|
let vkey = extractVKey( zkey)
|
|
let proof = generateProof( zkey, witness )
|
|
|
|
echo("verifying the proof...")
|
|
let ok = verifyProof( vkey, proof )
|
|
echo("verification succeeded = ",ok)
|
|
|
|
return proof
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
proc testFakeSetupAndVerify*( r1cs_fname, wtns_fname: string, flavour=Snarkjs): Proof =
|
|
echo("trusted setup flavour = ",flavour)
|
|
|
|
echo("parsing witness & r1cs files...")
|
|
let witness = parseWitness( wtns_fname)
|
|
let r1cs = parseR1CS( r1cs_fname)
|
|
|
|
echo("performing fake trusted setup...")
|
|
let zkey = createFakeCircuitSetup( r1cs, flavour=flavour )
|
|
|
|
# printCoeffs(zkey.coeffs)
|
|
|
|
echo("generating proof...")
|
|
let vkey = extractVKey( zkey)
|
|
let proof = generateProof( zkey, witness )
|
|
|
|
echo("verifying the proof...")
|
|
let ok = verifyProof( vkey, proof )
|
|
echo("verification succeeded = ",ok)
|
|
|
|
return proof
|