Skip to content

Commit

Permalink
Remove redundant validation logic from address append circuit.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeytimoshin committed Jan 3, 2025
1 parent 2cf2389 commit 2861442
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions prover/server/prover/batch_address_append_circuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,6 @@ type BatchAddressTreeAppendCircuit struct {
}

func (circuit *BatchAddressTreeAppendCircuit) Define(api frontend.API) error {
// Create an array of binary digits representing 2^height - 1
binaryDigits := make([]frontend.Variable, int(circuit.TreeHeight))
for i := range binaryDigits {
binaryDigits[i] = 1
}
// Validate StartIndex + BatchSize <= 2^TreeHeight
maxIndex := api.Sub(api.FromBinary(binaryDigits...), 1)
endIndex := api.Add(circuit.StartIndex, circuit.BatchSize)
api.AssertIsLessOrEqual(endIndex, maxIndex)

// Validate array sizes match BatchSize
if len(circuit.LowElementValues) != int(circuit.BatchSize) ||
len(circuit.LowElementNextIndices) != int(circuit.BatchSize) ||
len(circuit.LowElementNextValues) != int(circuit.BatchSize) ||
len(circuit.LowElementIndices) != int(circuit.BatchSize) ||
len(circuit.NewElementValues) != int(circuit.BatchSize) {
return fmt.Errorf("array lengths must match BatchSize")
}

// Validate proof lengths match TreeHeight
for i := 0; i < int(circuit.BatchSize); i++ {
if len(circuit.LowElementProofs[i]) != int(circuit.TreeHeight) ||
len(circuit.NewElementProofs[i]) != int(circuit.TreeHeight) {
return fmt.Errorf("proof lengths must match TreeHeight")
}
}

currentRoot := circuit.OldRoot
indexBits := api.ToBinary(circuit.StartIndex, int(circuit.TreeHeight))

Expand Down

0 comments on commit 2861442

Please sign in to comment.