fix(merkle): fix overflow in to_scalar_index for nodes at depth 64

This commit is contained in:
Qyriad 2024-09-18 16:37:03 -06:00
parent e5dd7c6d6a
commit 0e7e6705d8

View file

@ -114,8 +114,8 @@ impl NodeIndex {
/// Returns the scalar representation of the depth/value pair. /// Returns the scalar representation of the depth/value pair.
/// ///
/// It is computed as `2^depth + value`. /// It is computed as `2^depth + value`.
pub const fn to_scalar_index(&self) -> u64 { pub const fn to_scalar_index(&self) -> u128 {
(1 << self.depth as u64) + self.value (1 << self.depth as u64) + (self.value as u128)
} }
/// Returns the depth of the current instance. /// Returns the depth of the current instance.