rootchain-crypto 1.0.2

Cryptographic primitives for the RootChain ecosystem, including Ed25519 signing and Merkle tree implementations.
Documentation

rootchain-crypto

Crates.io License: MIT

Cryptographic primitives for the RootChain ecosystem.

This crate provides the core cryptographic building blocks used by the entire RootChain network: Ed25519 key management, Blake3 hashing, and a Sparse Merkle Tree implementation for verifiable state proofs.


What's Inside

Module Description
signing Ed25519 keypair generation, signing, and signature verification
hashing Blake3 hashing with deterministic output for use in Merkle trees and block headers
smt Sparse Merkle Tree (SMT) implementation for state root derivation and inclusion proofs
error Unified CryptoError type for this crate

Installation

[dependencies]
rootchain-crypto = "1.0.2"

Usage

Key Generation & Signing

use rootchain_crypto::signing::{Keypair, verify_signature};

// Generate a new keypair from a 32-byte seed
let keypair = Keypair::from_seed(&[0u8; 32]);
let address = keypair.public_address();

// Sign a message
let message = b"finalize block #1000";
let signature = keypair.sign(message);

// Verify the signature
assert!(verify_signature(&address, message, &signature).is_ok());

Blake3 Hashing

use rootchain_crypto::hashing::hash;

let data = b"RootChain block data";
let digest = hash(data); // Returns rootchain_core::types::Hash

Sparse Merkle Tree (State Proofs)

use rootchain_crypto::smt::SparseMerkleTree;

let mut tree = SparseMerkleTree::new();
tree.update(b"account_key", b"account_value");

let root = tree.root();
let proof = tree.proof(b"account_key");

Security

  • Uses ed25519-dalek v2.x with rejection sampling for secure key generation.
  • Uses blake3 v1.5.x for Merkle hashing (faster than SHA-2, quantum-resistant preimage).

License

MIT — See LICENSE for details.