Skip to content

Commit

Permalink
fix input data
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeytimoshin committed Nov 14, 2024
1 parent d9e9547 commit 98b6aa1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
12 changes: 7 additions & 5 deletions light-prover/prover/batch_address_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ func (circuit *BatchAddressTreeAppendCircuit) Define(api frontend.API) error {
api.Println("LowElementProofs[", i, "]: ", circuit.LowElementProofs[i])
}

startIndexBits := api.ToBinary(circuit.StartIndex, int(circuit.TreeHeight))
indexBits := api.ToBinary(circuit.StartIndex, int(circuit.TreeHeight))
for i := uint32(0); i < circuit.BatchSize; i++ {
api.Println("indexBits: ", indexBits)

api.Println("LowElementValues[", i, "]: ", circuit.LowElementValues[i])
api.Println("LowElementNextIndices[", i, "]: ", circuit.LowElementNextIndices[i])
api.Println("LowElementNextValues[", i, "]: ", circuit.LowElementNextValues[i])
Expand Down Expand Up @@ -101,17 +103,17 @@ func (circuit *BatchAddressTreeAppendCircuit) Define(api frontend.API) error {
OldRoot: currentRoot,
OldLeaf: getZeroValue(0),
NewLeaf: newLeafHash,
PathIndex: startIndexBits,
PathIndex: indexBits,
MerkleProof: circuit.NewElementProofs[i],
Height: int(circuit.TreeHeight),
})
api.Println("CurrentRoot: ", currentRoot)

startIndexBits = incrementBits(
indexBits = incrementBits(
api,
startIndexBits,
indexBits,
)
api.Println("StartIndexBits: ", startIndexBits)
api.Println("Incremented indexBits: ", indexBits)
}

api.AssertIsEqual(circuit.NewRoot, currentRoot)
Expand Down
2 changes: 1 addition & 1 deletion light-prover/prover/batch_address_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func get_test_data_2_insert() BatchAddressTreeAppendParameters {
],
[
"13859306649965657812382249699983066845935552967038026417581136538215435035637",
"9326699937298322758647210248953324788180879800245446112806190282402299353280",
"3796870957066466565085934353165460010672460214992313636808730505094443732049",
"7423237065226347324353380772367382631490014989348495481811164164159255474657",
"11286972368698509976183087595462810875513684078608517520839298933882497716792"
]
Expand Down
17 changes: 9 additions & 8 deletions merkle-tree/indexed/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,14 +1118,6 @@ pub fn print_circuit_test_data_batch_2() {
"LowElementNextValue {:?}",
BigUint::from_bytes_be(&non_inclusion_proof_0.leaf_higher_range_value)
);
relayer_merkle_tree
.append(&test_address_2, &mut relayer_indexing_array)
.unwrap();

println!(
"NewRoot {:?}",
BigUint::from_bytes_be(&relayer_merkle_tree.root())
);

let proof = relayer_merkle_tree.get_proof_of_leaf(0, true).unwrap();
println!(
Expand All @@ -1138,6 +1130,15 @@ pub fn print_circuit_test_data_batch_2() {
.collect::<Vec<_>>()
);

relayer_merkle_tree
.append(&test_address_2, &mut relayer_indexing_array)
.unwrap();

println!(
"NewRoot {:?}",
BigUint::from_bytes_be(&relayer_merkle_tree.root())
);

let proof = relayer_merkle_tree.get_proof_of_leaf(3, true).unwrap();
println!(
"NewElementProof {:?}",
Expand Down

0 comments on commit 98b6aa1

Please sign in to comment.