Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

utils

Utility functions for Cartesian Merkle Trees.

This module provides the core utility functions for CMT operations:

  • Priority calculation using cryptographic hashing
  • Merkle hash computation with consistent ordering
  • Tree rotation operations for maintaining heap property
  • Helper functions for child node management

The utilities ensure deterministic behavior and cryptographic security through the use of Poseidon hashing for both priorities and Merkle commitments.

Examples

Computing priorities:

let key = 42;
let priority = CMTUtilsTrait::calculate_priority(key);

Computing Merkle hashes:

let hash = CMTUtilsTrait::calculate_merkle_hash(key, left_hash, right_hash);
assert!(hash != 0);

Performing tree rotations:

let rotated = CMTUtilsTrait::right_rotate(node_box);
// Tree structure is now rotated while maintaining properties

Fully qualified path: cartesian_merkle_tree::library::utils

Traits

Impls