From 8ff6b50c37199862122f3e2543e6617c6b6bbb8d Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 4 Mar 2024 13:09:35 +0100 Subject: [PATCH] Fixes testprover.nim --- codex/slots/proofs/backendfactory.nim | 5 +---- codex/slots/proofs/prover.nim | 4 ++-- tests/codex/slots/testprover.nim | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/codex/slots/proofs/backendfactory.nim b/codex/slots/proofs/backendfactory.nim index 8c02f781..7f2e159d 100644 --- a/codex/slots/proofs/backendfactory.nim +++ b/codex/slots/proofs/backendfactory.nim @@ -69,10 +69,7 @@ proc downloadCeremony( # In the future, the zip file will be stored in the Codex network # instead of a url + ceremonyHash, we'll get a CID from the marketplace contract. - echo "OVERRIDE!" - let hash = "1f512a1c6a089eff7eb22b810438c34fc59d4b0e7935dbc77ec77255d39ec094" - - let url = "https://circuit.codex.storage/proving-key/" & hash # was ceremonyHash + let url = "https://circuit.codex.storage/proving-key/" & ceremonyHash trace "Downloading ceremony file", url, filepath = config.zipFilePath try: # Nim's default webclient does not support SSL on all platforms. diff --git a/codex/slots/proofs/prover.nim b/codex/slots/proofs/prover.nim index 40a39e73..48396de1 100644 --- a/codex/slots/proofs/prover.nim +++ b/codex/slots/proofs/prover.nim @@ -99,9 +99,9 @@ proc verify*( proc start*( self: Prover, config: CodexConf, - proofCeremonyUrl: ?string): Future[?!void] {.async.} = + ceremonyHash: ?string): Future[?!void] {.async.} = - without backend =? (await initializeBackend(config, proofCeremonyUrl)), err: + without backend =? (await initializeBackend(config, ceremonyHash)), err: error "Failed to initialize backend", msg = err.msg return failure(err) diff --git a/tests/codex/slots/testprover.nim b/tests/codex/slots/testprover.nim index 9deed96a..42cf2265 100644 --- a/tests/codex/slots/testprover.nim +++ b/tests/codex/slots/testprover.nim @@ -15,6 +15,8 @@ import pkg/codex/chunker import pkg/codex/blocktype as bt import pkg/codex/slots import pkg/codex/stores +import pkg/codex/conf +import pkg/confutils/defs import pkg/poseidon2/io import pkg/codex/utils/poseidon2digest @@ -57,13 +59,23 @@ suite "Test Prover": test "Should sample and prove a slot": let - r1cs = "tests/circuits/fixtures/proof_main.r1cs" - wasm = "tests/circuits/fixtures/proof_main.wasm" - - circomBackend = CircomCompat.init(r1cs, wasm) - prover = Prover.new(store, circomBackend, samples) + prover = Prover.new(store, samples) challenge = 1234567.toF.toBytes.toArray32 - (inputs, proof) = (await prover.prove(1, verifiable, challenge)).tryGet + config = CodexConf( + cmd: StartUpCmd.persistence, + nat: ValidIpAddress.init("127.0.0.1"), + discoveryIp: ValidIpAddress.init(IPv4_any()), + metricsAddress: ValidIpAddress.init("127.0.0.1"), + persistenceCmd: PersistenceCmd.prover, + circomR1cs: InputFile("tests/circuits/fixtures/proof_main.r1cs"), + circomWasm: InputFile("tests/circuits/fixtures/proof_main.wasm"), + circomZkey: InputFile("tests/circuits/fixtures/proof_main.zkey") + ) + ceremonyHash = string.none + + (await prover.start(config, ceremonyHash)).tryGet() + + let (inputs, proof) = (await prover.prove(1, verifiable, challenge)).tryGet check: (await prover.verify(proof, inputs)).tryGet == true