Skip to main content

Crate hush_core

Crate hush_core 

Source
Expand description

§hush-core

Cryptographic primitives for the clawdstrike attestation system.

This crate provides:

  • Ed25519 signing and verification
  • SHA-256 and Keccak-256 hashing
  • Merkle tree construction and proof verification
  • Canonical JSON (RFC 8785)
  • Receipt types and signing

§Quick Start

use hush_core::{sha256, keccak256, Keypair};

// Hash some data
let hash = sha256(b"hello world");
assert_eq!(hash.as_bytes().len(), 32);

// Keccak-256 (Ethereum-compatible)
let eth_hash = keccak256(b"hello world");
assert_eq!(eth_hash.as_bytes().len(), 32);

// Sign and verify
let keypair = Keypair::generate();
let message = b"important message";
let signature = keypair.sign(message);
assert!(keypair.public_key().verify(message, &signature));

§Merkle Trees

use hush_core::MerkleTree;

let leaves = vec![b"leaf1".to_vec(), b"leaf2".to_vec(), b"leaf3".to_vec()];
let tree = MerkleTree::from_leaves(&leaves).unwrap();

// Generate and verify inclusion proof
let proof = tree.inclusion_proof(1).unwrap();
assert!(proof.verify(&leaves[1], &tree.root()));

Re-exports§

pub use canonical::canonicalize as canonicalize_json;
pub use duration::parse_human_duration;
pub use error::Error;
pub use error::Result;
pub use hashing::keccak256;
pub use hashing::keccak256_hex;
pub use hashing::sha256;
pub use hashing::sha256_hex;
pub use hashing::Hash;
pub use merkle::MerkleProof;
pub use merkle::MerkleTree;
pub use receipt::Provenance;
pub use receipt::Receipt;
pub use receipt::SignedReceipt;
pub use receipt::Verdict;
pub use signing::Keypair;
pub use signing::PublicKey;
pub use signing::Signature;
pub use signing::Signer;
pub use tpm::TpmSealedBlob;
pub use tpm::TpmSealedSeedSigner;

Modules§

canonical
Canonical JSON for hashing/signatures (RFC 8785 JCS)
duration
error
Error types for hush-core operations
hashing
Cryptographic hashing (SHA-256 and Keccak-256)
merkle
RFC 6962-compatible Merkle tree (Certificate Transparency style).
prelude
Commonly used types
receipt
Receipt types and signing for attestation
signing
Ed25519 signing and verification
tpm
TPM2 sealing helpers (best-effort).