temp log proof inputs for debug

log proof inputs so we can find out which proof inputs are failing proof generation
This commit is contained in:
Eric 2025-06-25 15:47:02 +10:00
parent 57a81cc92f
commit 29257a57f9
No known key found for this signature in database

View File

@ -30,6 +30,10 @@ import ../sampler
import ./backends
import ../types
import pkg/constantine/math/arithmetic
import pkg/constantine/math/io/io_bigints
import pkg/constantine/math/io/io_fields
export backends
logScope:
@ -44,6 +48,25 @@ type Prover* = ref object
nSamples: int
tp: Taskpool
func toJsonDecimal*(big: BigInt[254]): string =
let s = big.toDecimal.strip(leading = true, trailing = false, chars = {'0'})
if s.len == 0: "0" else: s
func toJson*(input: ProofInputs[Poseidon2Hash]): JsonNode =
var input = input
%*{
"dataSetRoot": input.datasetRoot.toBig.toJsonDecimal,
"entropy": input.entropy.toBig.toJsonDecimal,
"nCellsPerSlot": input.nCellsPerSlot,
"nSlotsPerDataSet": input.nSlotsPerDataSet,
"slotIndex": input.slotIndex,
"slotRoot": input.slotRoot.toDecimal,
"slotProof": input.slotProof.mapIt(it.toBig.toJsonDecimal),
"cellData": input.samples.mapIt(it.cellData.mapIt(it.toBig.toJsonDecimal)),
"merklePaths": input.samples.mapIt(it.merklePaths.mapIt(it.toBig.toJsonDecimal)),
}
proc prove*[SomeSampler](
self: Prover,
sampler: SomeSampler,
@ -73,6 +96,7 @@ proc prove*[SomeSampler](
(?await self.groth16Backend.verify(proof)).some
else:
bool.none
trace "Proof generated with input", input = proofInput.toJson
return success (proof.toGroth16Proof, verified)
of ProverBackendCmd.circomcompat:
let