diff --git a/tests/codex/slots/sampler/testproofinput.nim b/tests/codex/slots/sampler/testproofinput.nim new file mode 100644 index 00000000..c8f2c1aa --- /dev/null +++ b/tests/codex/slots/sampler/testproofinput.nim @@ -0,0 +1,150 @@ +import std/sequtils +import std/options +import std/importutils + +import ../../../asynctest + +import pkg/questionable/results +import pkg/datastore +import pkg/constantine/math/arithmetic +import pkg/constantine/math/io/io_bigints +import pkg/constantine/math/io/io_fields + +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/sampler +import pkg/codex/slots/builder +import pkg/codex/utils/poseidon2digest +import pkg/codex/slots/sampler/utils + +import ../backends/helpers +import ../helpers +import ../../helpers + +suite "Test control inputs": + + test "Should verify control inputs": + let + inputData = readFile("tests/circuits/fixtures/input.json") + inputJson = parseJson(inputData) + proofInput = jsonToProofInput[Poseidon2Hash](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 = + block: + var + pos = 0 + cellElms: seq[Bn254Fr] + while pos < sample.cellData.len: + var + step = 32 + offset = min(pos + step, sample.cellData.len) + data = sample.cellData[pos..