Fixes testprover.nim

This commit is contained in:
benbierens 2024-03-04 13:09:35 +01:00
parent 983da3c24f
commit 8ff6b50c37
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
3 changed files with 21 additions and 12 deletions

View File

@ -69,10 +69,7 @@ proc downloadCeremony(
# In the future, the zip file will be stored in the Codex network # 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. # instead of a url + ceremonyHash, we'll get a CID from the marketplace contract.
echo "OVERRIDE!" let url = "https://circuit.codex.storage/proving-key/" & ceremonyHash
let hash = "1f512a1c6a089eff7eb22b810438c34fc59d4b0e7935dbc77ec77255d39ec094"
let url = "https://circuit.codex.storage/proving-key/" & hash # was ceremonyHash
trace "Downloading ceremony file", url, filepath = config.zipFilePath trace "Downloading ceremony file", url, filepath = config.zipFilePath
try: try:
# Nim's default webclient does not support SSL on all platforms. # Nim's default webclient does not support SSL on all platforms.

View File

@ -99,9 +99,9 @@ proc verify*(
proc start*( proc start*(
self: Prover, self: Prover,
config: CodexConf, 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 error "Failed to initialize backend", msg = err.msg
return failure(err) return failure(err)

View File

@ -15,6 +15,8 @@ import pkg/codex/chunker
import pkg/codex/blocktype as bt import pkg/codex/blocktype as bt
import pkg/codex/slots import pkg/codex/slots
import pkg/codex/stores import pkg/codex/stores
import pkg/codex/conf
import pkg/confutils/defs
import pkg/poseidon2/io import pkg/poseidon2/io
import pkg/codex/utils/poseidon2digest import pkg/codex/utils/poseidon2digest
@ -57,13 +59,23 @@ suite "Test Prover":
test "Should sample and prove a slot": test "Should sample and prove a slot":
let let
r1cs = "tests/circuits/fixtures/proof_main.r1cs" prover = Prover.new(store, samples)
wasm = "tests/circuits/fixtures/proof_main.wasm"
circomBackend = CircomCompat.init(r1cs, wasm)
prover = Prover.new(store, circomBackend, samples)
challenge = 1234567.toF.toBytes.toArray32 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: check:
(await prover.verify(proof, inputs)).tryGet == true (await prover.verify(proof, inputs)).tryGet == true