Skip to content

Commit

Permalink
verkle multiproofs: workaround failure when ref/heap allocating input…
Browse files Browse the repository at this point in the history
… in test
  • Loading branch information
mratsim committed Jun 7, 2024
1 parent bc74902 commit dc2084f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/t_ethereum_verkle_ipa_primitives.nim
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,11 @@ suite "IPA proof tests":
var prover_transcript {.noInit.}: sha256
prover_transcript.newTranscriptGen(asBytes"ipa")

#from a shared view
# from a shared view
var point: Fr[Banderwagon]
point.fromInt(123456789)

#from the prover's side
# from the prover's side
var testVals: array[14, int] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
var poly: array[256, Fr[Banderwagon]]
poly.testPoly256(testVals)
Expand Down Expand Up @@ -671,15 +671,18 @@ suite "Multiproof Tests":
var prover_comm: EC_P
prover_comm.pedersen_commit_varbasis(ipaConfig.SRS, ipaConfig.SRS.len, poly, poly.len)

#Prover's view
# Prover's view
var prover_transcript {.noInit.}: sha256
prover_transcript.newTranscriptGen(asBytes"multiproof")

var one: Fr[Banderwagon]
one.setOne()

var Cs: seq[EC_P]
var Fs = new array[VerkleDomain, array[VerkleDomain, Fr[Banderwagon]]]
# Large array, need heap allocation.
# However using a ref array here makes the test fail. TODO.
# expecially with address-sanitizer to reliably trigger the failure.
var Fs: array[VerkleDomain, array[VerkleDomain, Fr[Banderwagon]]]

for i in 0 ..< VerkleDomain:
for j in 0 ..< VerkleDomain:
Expand All @@ -697,13 +700,11 @@ suite "Multiproof Tests":

var multiproof {.noInit.}: MultiProof
var stat_create_mult: bool
stat_create_mult = multiproof.createMultiProof(prover_transcript, ipaConfig, Cs, Fs[], Zs)
discard Fs
stat_create_mult = multiproof.createMultiProof(prover_transcript, ipaConfig, Cs, Fs, Zs)

doAssert stat_create_mult.bool() == true, "Multiproof creation error!"


#Verifier's view
# Verifier's view
var verifier_transcript: sha256
verifier_transcript.newTranscriptGen(asBytes"multiproof")

Expand Down

0 comments on commit dc2084f

Please sign in to comment.