pub struct Ed25519KeyPair { /* private fields */ }Expand description
Ed25519 key pair for Solana and other ed25519-based chains.
This key pair uses the ed25519 elliptic curve, which is the standard for Solana and some other blockchain networks.
§Security
- The signing key is stored securely using
ed25519_dalek::SigningKey - The signing key implements
ZeroizeandZeroizeOnDrop, ensuring secret material is automatically zeroed when dropped (the “zeroize” feature is explicitly enabled in the workspace Cargo.toml) Debugoutput does not expose the private key- Uses ed25519-dalek for cryptographic operations
§Example
use txgate_crypto::keypair::{KeyPair, Ed25519KeyPair};
// Generate a new key pair
let keypair = Ed25519KeyPair::generate();
// Or create from existing bytes
let secret_bytes = [0x42u8; 32]; // Use real secret in production!
let keypair = Ed25519KeyPair::from_bytes(secret_bytes)
.expect("valid secret key");
// Sign a message hash
let hash = [0u8; 32]; // Use real hash in production!
let signature = keypair.sign(&hash).expect("signing succeeded");
// Get Solana address
let address = keypair.public_key().solana_address();
println!("Solana address: {address}");Implementations§
Source§impl Ed25519KeyPair
impl Ed25519KeyPair
Sourcepub fn from_secret_key(secret: &SecretKey) -> Result<Self, SignError>
pub fn from_secret_key(secret: &SecretKey) -> Result<Self, SignError>
Create a key pair from a SecretKey.
§Errors
Returns an error if the secret key bytes are not valid.
§Example
use txgate_crypto::keys::SecretKey;
use txgate_crypto::keypair::{KeyPair, Ed25519KeyPair};
let secret = SecretKey::generate();
let keypair = Ed25519KeyPair::from_secret_key(&secret)
.expect("valid secret key");Trait Implementations§
Source§impl Debug for Ed25519KeyPair
impl Debug for Ed25519KeyPair
Source§impl KeyPair for Ed25519KeyPair
impl KeyPair for Ed25519KeyPair
Source§type Signature = Ed25519Signature
type Signature = Ed25519Signature
The signature type produced by this key pair.
Source§type PublicKey = Ed25519PublicKey
type PublicKey = Ed25519PublicKey
The public key type for this key pair.
Source§fn from_bytes(bytes: [u8; 32]) -> Result<Self, SignError>
fn from_bytes(bytes: [u8; 32]) -> Result<Self, SignError>
Create a key pair from raw secret key bytes. Read more
Source§fn public_key(&self) -> &Self::PublicKey
fn public_key(&self) -> &Self::PublicKey
Get the public key.
Auto Trait Implementations§
impl Freeze for Ed25519KeyPair
impl RefUnwindSafe for Ed25519KeyPair
impl Send for Ed25519KeyPair
impl Sync for Ed25519KeyPair
impl Unpin for Ed25519KeyPair
impl UnwindSafe for Ed25519KeyPair
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more