Crate cardano_crypto

Crate cardano_crypto 

Source
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 support
  • alloc - Allocation support for no_std
  • vrf - VRF implementations (includes dsign, hash)
  • kes - KES implementations (includes dsign, hash)
  • dsign - Digital signature algorithms (includes hash)
  • hash - Hash functions
  • cbor - CBOR serialization
  • serde - Serde serialization for keys/signatures
  • metrics - Performance metrics collection
  • logging - 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;hash
pub use hash::Blake2b256;hash
pub use hash::Blake2b512;hash
pub use hash::HashAlgorithm;hash
pub use dsign::ed25519::Ed25519Signature;dsign
pub use dsign::ed25519::Ed25519SigningKey;dsign
pub use dsign::ed25519::Ed25519VerificationKey;dsign
pub use dsign::DsignAlgorithm;dsign
pub use dsign::DsignKeyPair;dsign
pub use dsign::DsignSignature;dsign
pub use dsign::DsignSigningKey;dsign
pub use dsign::DsignVerificationKey;dsign
pub use dsign::Ed25519;dsign
pub use dsign::SignedDsign;dsign
pub use vrf::CertifiedVrf;vrf
pub use vrf::OutputVrf;vrf
pub use vrf::VrfAlgorithm;vrf
pub use vrf::VrfDraft03;vrf
pub use vrf::VrfDraft13;vrf
pub use vrf::VrfKeyPair;vrf
pub use vrf::VrfProof;vrf
pub use vrf::VrfSigningKey;vrf
pub use vrf::VrfVerificationKey;vrf
pub use kes::CompactSum0Kes;kes
pub use kes::CompactSum1Kes;kes
pub use kes::CompactSum2Kes;kes
pub use kes::CompactSum3Kes;kes
pub use kes::CompactSum4Kes;kes
pub use kes::CompactSum5Kes;kes
pub use kes::CompactSum6Kes;kes
pub use kes::CompactSum7Kes;kes
pub use kes::KesAlgorithm;kes
pub use kes::KesError;kes
pub use kes::KesKeyPair;kes
pub use kes::KesSignature;kes
pub use kes::KesSigningKey;kes
pub use kes::KesVerificationKey;kes
pub use kes::Period;kes
pub use kes::SignKeyWithPeriodKes;kes
pub use kes::SignedKes;kes
pub use kes::SingleKes;kes
pub use kes::Sum0Kes;kes
pub use kes::Sum1Kes;kes
pub use kes::Sum2Kes;kes
pub use kes::Sum3Kes;kes
pub use kes::Sum4Kes;kes
pub use kes::Sum5Kes;kes
pub use kes::Sum6Kes;kes
pub use kes::Sum7Kes;kes
pub use cbor::decode_bytes;cbor
pub use cbor::decode_hash;cbor
pub use cbor::decode_output_vrf;cbor
pub use cbor::decode_proof_vrf;cbor
pub use cbor::decode_signature;cbor
pub use cbor::decode_signature_dsign;cbor
pub use cbor::decode_signature_kes;cbor
pub use cbor::decode_signing_key_dsign;cbor
pub use cbor::decode_signing_key_kes;cbor
pub use cbor::decode_signing_key_vrf;cbor
pub use cbor::decode_verification_key;cbor
pub use cbor::decode_verification_key_dsign;cbor
pub use cbor::decode_verification_key_kes;cbor
pub use cbor::decode_verification_key_vrf;cbor
pub use cbor::encode_bytes;cbor
pub use cbor::encode_hash;cbor
pub use cbor::encode_output_vrf;cbor
pub use cbor::encode_proof_vrf;cbor
pub use cbor::encode_signature;cbor
pub use cbor::encode_signature_dsign;cbor
pub use cbor::encode_signature_kes;cbor
pub use cbor::encode_signing_key_dsign;cbor
pub use cbor::encode_signing_key_kes;cbor
pub use cbor::encode_signing_key_vrf;cbor
pub use cbor::encode_verification_key;cbor
pub use cbor::encode_verification_key_dsign;cbor
pub use cbor::encode_verification_key_kes;cbor
pub use cbor::encode_verification_key_vrf;cbor
pub use cbor::encoded_hash_blake2b224_size;cbor
pub use cbor::encoded_hash_blake2b256_size;cbor
pub use cbor::encoded_output_vrf_size;cbor
pub use cbor::encoded_proof_vrf_draft03_size;cbor
pub use cbor::encoded_proof_vrf_draft13_size;cbor
pub use cbor::encoded_signature_dsign_size;cbor
pub use cbor::encoded_signature_size;cbor
pub use cbor::encoded_signature_sum6kes_size;cbor
pub use cbor::encoded_signing_key_dsign_size;cbor
pub use cbor::encoded_signing_key_sum6kes_size;cbor
pub use cbor::encoded_signing_key_vrf_size;cbor
pub use cbor::encoded_size_bytes;cbor
pub use cbor::encoded_verification_key_dsign_size;cbor
pub use cbor::encoded_verification_key_kes_size;cbor
pub use cbor::encoded_verification_key_size;cbor
pub use cbor::encoded_verification_key_vrf_size;cbor
pub use cbor::CborError;cbor
pub use cbor::FromCbor;cbor
pub use cbor::ToCbor;cbor
pub use seed::derive_seed;seed
pub use seed::expand_seed;seed
pub use seed::SecureSeed;seed
pub use seed::Seed;seed
pub use seed::SeedError;seed
pub use seed::SEED_SIZE;seed
pub use key::bech32;
pub use key::text_envelope;
pub use key::hash::hash_payment_verification_key;hash
pub use key::hash::hash_pool_verification_key;hash
pub use key::hash::hash_raw;hash
pub use key::hash::hash_stake_verification_key;hash
pub use key::hash::hash_verification_key;hash
pub use key::hash::hash_vrf_verification_key;hash
pub use key::hash::CommitteeColdKeyHash;hash
pub use key::hash::CommitteeHotKeyHash;hash
pub use key::hash::DRepKeyHash;hash
pub use key::hash::GenesisDelegateKeyHash;hash
pub use key::hash::GenesisKeyHash;hash
pub use key::hash::KeyHash;hash
pub use key::hash::PaymentKeyHash;hash
pub use key::hash::PoolKeyHash;hash
pub use key::hash::StakeKeyHash;hash
pub use key::hash::VrfKeyHash;hash
pub use key::hash::KEY_HASH_SIZE;hash
pub use key::kes_period::is_kes_expired;kes
pub use key::kes_period::is_valid_period;kes
pub use key::kes_period::kes_expiry_slot;kes
pub use key::kes_period::kes_period_info;kes
pub use key::kes_period::period_from_slot;kes
pub use key::kes_period::slot_from_period;kes
pub use key::kes_period::KESPeriod;kes
pub use key::kes_period::KESPeriodInfo;kes
pub use key::kes_period::KES_MAX_PERIOD_SUM6;kes
pub use key::kes_period::KES_SLOTS_PER_PERIOD_MAINNET;kes
pub use key::kes_period::KES_SLOTS_PER_PERIOD_TESTNET;kes

Modules§

cborcbor
CBOR serialization support for Cardano cryptographic types
common
Common cryptographic utilities shared across implementations
dsigndsign
Digital signature algorithms (DSIGN)
hashhash
Hash functions used in Cardano cryptography
keskes
Key Evolving Signatures (KES)
key
Key types, serialization, and utilities matching cardano-api Key types and serialization matching cardano-api
seedseed
Seed management and derivation utilities
vrfvrf
Verifiable Random Functions (VRF)

Constants§

NAME
Crate name
VERSION
Crate version