Expand description
§Cardano Crypto
Pure Rust implementation of Cardano cryptographic primitives.
This crate provides a unified interface for all Cardano cryptographic operations:
- VRF (Verifiable Random Functions) - IETF Draft-03 and Draft-13
- KES (Key Evolving Signatures) - Forward-secure signature schemes
- DSIGN (Digital Signatures) - Ed25519 and variants
- Hash - Blake2b, SHA-2, and other Cardano hash functions
- Seed - Deterministic key derivation
- CBOR - Optional serialization support
§Feature Flags
This crate uses feature flags to allow selective compilation:
std(default) - Standard library supportalloc- Allocation support for no_stdvrf- VRF implementations (includesdsign,hash)kes- KES implementations (includesdsign,hash)dsign- Digital signature algorithms (includeshash)hash- Hash functionscbor- CBOR serializationserde- Serde serialization for keys/signaturesmetrics- Performance metrics collectionlogging- Debug logging support
§Examples
§VRF Proof Generation
ⓘ
use cardano_crypto::vrf::{VrfDraft03, VrfKeyPair};
let seed = [0u8; 32];
let keypair = VrfKeyPair::from_seed(&seed);
let proof = keypair.prove(b"message")?;
let output = proof.verify(&keypair.public_key(), b"message")?;§KES Signing
ⓘ
use cardano_crypto::kes::{Sum6Kes, KesAlgorithm};
let seed = [0u8; 32];
let signing_key = Sum6Kes::gen_key_from_seed(&seed)?;
let signature = Sum6Kes::sign(&signing_key, 0, b"message")?;§Digital Signatures
ⓘ
use cardano_crypto::dsign::{Ed25519, DsignAlgorithm};
let seed = [0u8; 32];
let signing_key = Ed25519::gen_key(&seed);
let signature = Ed25519::sign(&signing_key, b"message");§Crate metadata
use cardano_crypto::{NAME, VERSION};
assert_eq!(NAME, "cardano-crypto");
// VERSION comes from Cargo.toml at build time and should be present
assert!(VERSION.len() > 0);Re-exports§
pub use hash::Blake2b224;hashpub use hash::Blake2b256;hashpub use hash::Blake2b512;hashpub use hash::HashAlgorithm;hashpub use dsign::ed25519::Ed25519Signature;dsignpub use dsign::ed25519::Ed25519SigningKey;dsignpub use dsign::ed25519::Ed25519VerificationKey;dsignpub use dsign::DsignAlgorithm;dsignpub use dsign::DsignKeyPair;dsignpub use dsign::DsignSignature;dsignpub use dsign::DsignSigningKey;dsignpub use dsign::DsignVerificationKey;dsignpub use dsign::Ed25519;dsignpub use dsign::SignedDsign;dsignpub use vrf::CertifiedVrf;vrfpub use vrf::OutputVrf;vrfpub use vrf::VrfAlgorithm;vrfpub use vrf::VrfDraft03;vrfpub use vrf::VrfDraft13;vrfpub use vrf::VrfKeyPair;vrfpub use vrf::VrfProof;vrfpub use vrf::VrfSigningKey;vrfpub use vrf::VrfVerificationKey;vrfpub use kes::CompactSum0Kes;kespub use kes::CompactSum1Kes;kespub use kes::CompactSum2Kes;kespub use kes::CompactSum3Kes;kespub use kes::CompactSum4Kes;kespub use kes::CompactSum5Kes;kespub use kes::CompactSum6Kes;kespub use kes::CompactSum7Kes;kespub use kes::KesAlgorithm;kespub use kes::KesError;kespub use kes::KesKeyPair;kespub use kes::KesSignature;kespub use kes::KesSigningKey;kespub use kes::KesVerificationKey;kespub use kes::Period;kespub use kes::SignKeyWithPeriodKes;kespub use kes::SignedKes;kespub use kes::SingleKes;kespub use kes::Sum0Kes;kespub use kes::Sum1Kes;kespub use kes::Sum2Kes;kespub use kes::Sum3Kes;kespub use kes::Sum4Kes;kespub use kes::Sum5Kes;kespub use kes::Sum6Kes;kespub use kes::Sum7Kes;kespub use cbor::decode_bytes;cborpub use cbor::decode_hash;cborpub use cbor::decode_output_vrf;cborpub use cbor::decode_proof_vrf;cborpub use cbor::decode_signature;cborpub use cbor::decode_signature_dsign;cborpub use cbor::decode_signature_kes;cborpub use cbor::decode_signing_key_dsign;cborpub use cbor::decode_signing_key_kes;cborpub use cbor::decode_signing_key_vrf;cborpub use cbor::decode_verification_key;cborpub use cbor::decode_verification_key_dsign;cborpub use cbor::decode_verification_key_kes;cborpub use cbor::decode_verification_key_vrf;cborpub use cbor::encode_bytes;cborpub use cbor::encode_hash;cborpub use cbor::encode_output_vrf;cborpub use cbor::encode_proof_vrf;cborpub use cbor::encode_signature;cborpub use cbor::encode_signature_dsign;cborpub use cbor::encode_signature_kes;cborpub use cbor::encode_signing_key_dsign;cborpub use cbor::encode_signing_key_kes;cborpub use cbor::encode_signing_key_vrf;cborpub use cbor::encode_verification_key;cborpub use cbor::encode_verification_key_dsign;cborpub use cbor::encode_verification_key_kes;cborpub use cbor::encode_verification_key_vrf;cborpub use cbor::encoded_hash_blake2b224_size;cborpub use cbor::encoded_hash_blake2b256_size;cborpub use cbor::encoded_output_vrf_size;cborpub use cbor::encoded_proof_vrf_draft03_size;cborpub use cbor::encoded_proof_vrf_draft13_size;cborpub use cbor::encoded_signature_dsign_size;cborpub use cbor::encoded_signature_size;cborpub use cbor::encoded_signature_sum6kes_size;cborpub use cbor::encoded_signing_key_dsign_size;cborpub use cbor::encoded_signing_key_sum6kes_size;cborpub use cbor::encoded_signing_key_vrf_size;cborpub use cbor::encoded_size_bytes;cborpub use cbor::encoded_verification_key_dsign_size;cborpub use cbor::encoded_verification_key_kes_size;cborpub use cbor::encoded_verification_key_size;cborpub use cbor::encoded_verification_key_vrf_size;cborpub use cbor::CborError;cborpub use cbor::FromCbor;cborpub use cbor::ToCbor;cborpub use seed::derive_seed;seedpub use seed::expand_seed;seedpub use seed::SecureSeed;seedpub use seed::Seed;seedpub use seed::SeedError;seedpub use seed::SEED_SIZE;seedpub use key::bech32;pub use key::text_envelope;pub use key::hash::hash_payment_verification_key;hashpub use key::hash::hash_pool_verification_key;hashpub use key::hash::hash_raw;hashpub use key::hash::hash_stake_verification_key;hashpub use key::hash::hash_verification_key;hashpub use key::hash::hash_vrf_verification_key;hashpub use key::hash::CommitteeColdKeyHash;hashpub use key::hash::CommitteeHotKeyHash;hashpub use key::hash::DRepKeyHash;hashpub use key::hash::GenesisDelegateKeyHash;hashpub use key::hash::GenesisKeyHash;hashpub use key::hash::KeyHash;hashpub use key::hash::PaymentKeyHash;hashpub use key::hash::PoolKeyHash;hashpub use key::hash::StakeKeyHash;hashpub use key::hash::VrfKeyHash;hashpub use key::hash::KEY_HASH_SIZE;hashpub use key::kes_period::is_kes_expired;kespub use key::kes_period::is_valid_period;kespub use key::kes_period::kes_expiry_slot;kespub use key::kes_period::kes_period_info;kespub use key::kes_period::period_from_slot;kespub use key::kes_period::slot_from_period;kespub use key::kes_period::KESPeriod;kespub use key::kes_period::KESPeriodInfo;kespub use key::kes_period::KES_MAX_PERIOD_SUM6;kespub use key::kes_period::KES_SLOTS_PER_PERIOD_MAINNET;kespub use key::kes_period::KES_SLOTS_PER_PERIOD_TESTNET;kes
Modules§
- cbor
cbor - CBOR serialization support for Cardano cryptographic types
- common
- Common cryptographic utilities shared across implementations
- dsign
dsign - Digital signature algorithms (DSIGN)
- hash
hash - Hash functions used in Cardano cryptography
- kes
kes - Key Evolving Signatures (KES)
- key
- Key types, serialization, and utilities matching cardano-api Key types and serialization matching cardano-api
- seed
seed - Seed management and derivation utilities
- vrf
vrf - Verifiable Random Functions (VRF)