initial setup

This commit is contained in:
Jaremy Creechley 2024-04-23 20:21:39 +03:00
parent 53809129a5
commit 0273b78df8
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,58 @@
import std/sequtils
import std/options
import std/importutils
import pkg/questionable
import pkg/questionable/results
import pkg/datastore
import pkg/codex/rng
import pkg/codex/stores
import pkg/codex/merkletree
import pkg/codex/utils/json
import pkg/codex/codextypes
import pkg/codex/slots
import pkg/codex/slots/builder
import pkg/codex/utils/poseidon2digest
import pkg/codex/slots/sampler/utils
import pkg/constantine/math/arithmetic
import pkg/constantine/math/io/io_bigints
import pkg/constantine/math/io/io_fields
import codex/slots/backends/helpers
var
inputData: string
inputJson: JsonNode
proofInput: ProofInputs[Poseidon2Hash]
proc setup() =
inputData = readFile("tests/circuits/fixtures/input.json")
inputJson = !JsonNode.parse(inputData)
proofInput = Poseidon2Hash.jsonToProofInput(inputJson)
let
blockCells = 32
cellIdxs = proofInput.entropy.cellIndices(proofInput.slotRoot, proofInput.nCellsPerSlot, 5)
for i, cellIdx in cellIdxs:
let
sample = proofInput.samples[i]
cellIdx = cellIdxs[i]
cellProof = Poseidon2Proof.init(
cellIdx.toCellInBlk(blockCells),
proofInput.nCellsPerSlot,
sample.merklePaths[0..<5]).tryGet
slotProof = Poseidon2Proof.init(
cellIdx.toBlkInSlot(blockCells),
proofInput.nCellsPerSlot,
sample.merklePaths[5..<9]).tryGet
cellData = Poseidon2Hash.fromCircomData(sample.cellData)
cellLeaf = Poseidon2Hash.spongeDigest(cellData, rate = 2).tryGet
slotLeaf = cellProof.reconstructRoot(cellLeaf).tryGet
# check slotProof.verify(slotLeaf, proofInput.slotRoot).tryGet

9
benchmarks/config.nims Normal file
View File

@ -0,0 +1,9 @@
--path:".."
--path:"../tests"
--threads:on
--tlsEmulation:off
when not defined(chronicles_log_level):
--define:"chronicles_log_level:NONE" # compile all log statements
--define:"chronicles_sinks:textlines[dynamic]" # allow logs to be filtered at runtime
--"import":"logging" # ensure that logging is ignored at runtime