rootchain-crypto
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
[]
= "1.0.2"
Usage
Key Generation & Signing
use ;
// Generate a new keypair from a 32-byte seed
let keypair = from_seed;
let address = keypair.public_address;
// Sign a message
let message = b"finalize block #1000";
let signature = keypair.sign;
// Verify the signature
assert!;
Blake3 Hashing
use hash;
let data = b"RootChain block data";
let digest = hash; // Returns rootchain_core::types::Hash
Sparse Merkle Tree (State Proofs)
use SparseMerkleTree;
let mut tree = new;
tree.update;
let root = tree.root;
let proof = tree.proof;
Security
- Uses
ed25519-dalekv2.x with rejection sampling for secure key generation. - Uses
blake3v1.5.x for Merkle hashing (faster than SHA-2, quantum-resistant preimage).
License
MIT — See LICENSE for details.