Skip to content

Underflow in MerkleTree #439

@ed255

Description

@ed255

When the tree is empty new_siblings.len() is 0. This triggers an underflow in the code:

F::from_canonical_u64((new_siblings.len() - 1) as u64),

The self.divergence_level is not used in this situation so the value assigned there doesn't matter, but I think we should fix the underflow condition, which is checked by rust in debug mode and panics.

A solution could be to do a conditional assignment of 0 if new_siblings.len() == 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendTopics: Encoding, Arithmetic constraints, Verification, LayoutingbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions