mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-08 00:13:08 +00:00
feat: add single-block slot proof tests and update NimGroth16 backend configuration
This commit is contained in:
parent
c0b8275c51
commit
0817ab9e07
@ -175,7 +175,7 @@ proc verify*(
|
||||
|
||||
proc new*(
|
||||
_: type NimGroth16BackendRef,
|
||||
graph: string,
|
||||
graphPath: string,
|
||||
r1csPath: string,
|
||||
zkeyPath: string,
|
||||
curve = DefaultCurve,
|
||||
@ -190,7 +190,7 @@ proc new*(
|
||||
##
|
||||
|
||||
let
|
||||
graph = ?loadGraph(graph).catch
|
||||
graph = ?loadGraph(graphPath).catch
|
||||
r1cs = ?parseR1CS(r1csPath).catch
|
||||
zkey = ?parseZKey(zkeyPath).catch
|
||||
|
||||
|
||||
@ -93,3 +93,80 @@ suite "Test CircomCompat Prover":
|
||||
|
||||
check:
|
||||
checked.isSome and checked.get == true
|
||||
|
||||
suite "Test NimGroth16 Prover":
|
||||
let
|
||||
samples = 5
|
||||
blockSize = DefaultBlockSize
|
||||
cellSize = DefaultCellSize
|
||||
repoTmp = TempLevelDb.new()
|
||||
metaTmp = TempLevelDb.new()
|
||||
tp = Taskpool.new()
|
||||
challenge = 1234567.toF.toBytes.toArray32
|
||||
|
||||
var
|
||||
store: BlockStore
|
||||
prover: Prover
|
||||
|
||||
setup:
|
||||
let
|
||||
tp = Taskpool.new()
|
||||
repoDs = repoTmp.newDb()
|
||||
metaDs = metaTmp.newDb()
|
||||
backend = NimGroth16BackendRef.new(
|
||||
r1csPath = "tests/circuits/fixtures/proof_main.r1cs",
|
||||
graphPath = "tests/circuits/fixtures/proof_main.bin",
|
||||
zkeyPath = "tests/circuits/fixtures/proof_main.zkey",
|
||||
tp = tp,
|
||||
).tryGet
|
||||
|
||||
store = RepoStore.new(repoDs, metaDs)
|
||||
prover = Prover.new(backend, samples, tp)
|
||||
|
||||
teardown:
|
||||
await repoTmp.destroyDb()
|
||||
await metaTmp.destroyDb()
|
||||
|
||||
test "Should sample and prove a slot":
|
||||
let
|
||||
(_, _, verifiable) = await createVerifiableManifest(
|
||||
store,
|
||||
8, # number of blocks in the original dataset (before EC)
|
||||
5, # ecK
|
||||
3, # ecM
|
||||
blockSize,
|
||||
cellSize,
|
||||
)
|
||||
|
||||
builder =
|
||||
Poseidon2Builder.new(store, verifiable, verifiable.verifiableStrategy).tryGet
|
||||
sampler = Poseidon2Sampler.new(1, store, builder).tryGet
|
||||
(_, checked) =
|
||||
(await prover.prove(sampler, verifiable, challenge, verify = true)).tryGet
|
||||
|
||||
check:
|
||||
checked.isSome and checked.get == true
|
||||
|
||||
test "Should generate valid proofs when slots consist of single blocks":
|
||||
# To get single-block slots, we just need to set the number of blocks in
|
||||
# the original dataset to be the same as ecK. The total number of blocks
|
||||
# after generating random data for parity will be ecK + ecM, which will
|
||||
# match the number of slots.
|
||||
let
|
||||
(_, _, verifiable) = await createVerifiableManifest(
|
||||
store,
|
||||
2, # number of blocks in the original dataset (before EC)
|
||||
2, # ecK
|
||||
1, # ecM
|
||||
blockSize,
|
||||
cellSize,
|
||||
)
|
||||
|
||||
builder =
|
||||
Poseidon2Builder.new(store, verifiable, verifiable.verifiableStrategy).tryGet
|
||||
sampler = Poseidon2Sampler.new(1, store, builder).tryGet
|
||||
(_, checked) =
|
||||
(await prover.prove(sampler, verifiable, challenge, verify = true)).tryGet
|
||||
|
||||
check:
|
||||
checked.isSome and checked.get == true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user