Expand description
Cryptographic key pair traits and implementations.
This module provides the KeyPair trait for abstracting over different
elliptic curve key pairs, and implementations for specific curves.
§Supported Curves
Secp256k1KeyPair- For Ethereum, Bitcoin, Tron, and RippleEd25519KeyPair- For Solana and other ed25519-based chains
§Example
use txgate_crypto::keypair::{KeyPair, Secp256k1KeyPair};
// Generate a new random key pair
let keypair = Secp256k1KeyPair::generate();
// Get the public key
let pubkey = keypair.public_key();
println!("Compressed: {} bytes", pubkey.compressed().len());
// Get Ethereum address
let eth_address = pubkey.ethereum_address();
println!("Ethereum address: 0x{}", hex::encode(eth_address));
// Sign a message hash
let hash = [0u8; 32]; // In practice, this would be a real hash
let signature = keypair.sign(&hash).expect("signing failed");
println!("Signature: {} bytes", signature.as_ref().len());Structs§
- Ed25519
KeyPair - Ed25519 key pair for Solana and other ed25519-based chains.
- Ed25519
Public Key - Wrapper for ed25519 public keys.
- Ed25519
Signature - Wrapper for ed25519 signatures.
- Secp256k1
KeyPair - secp256k1 key pair for Ethereum, Bitcoin, Tron, and Ripple.
- Secp256k1
Public Key - Wrapper for secp256k1 public keys.
- Secp256k1
Signature - Wrapper for secp256k1 ECDSA signatures.
Traits§
- KeyPair
- Trait for cryptographic key pairs.