pub struct Ed25519Signer { /* private fields */ }Expand description
Ed25519 signer for Solana and other ed25519-based chains.
This signer wraps an Ed25519KeyPair and provides
a high-level signing interface suitable for blockchain transactions.
§Signature Format
Signatures are returned as 64 bytes: the standard ed25519 signature format.
§Security
- The underlying key pair uses secure key material handling
- Uses ed25519-dalek for cryptographic operations
§Example
use txgate_crypto::signer::{Signer, Ed25519Signer, Chain};
// Generate a new signer
let signer = Ed25519Signer::generate();
// Get the Solana address
let address = signer.address(Chain::Solana).expect("valid");
println!("Solana address: {address}");
// Sign a hash
let hash = [0u8; 32];
let signature = signer.sign(&hash).expect("signing failed");
assert_eq!(signature.len(), 64);Implementations§
Source§impl Ed25519Signer
impl Ed25519Signer
Sourcepub fn new(key_pair: Ed25519KeyPair) -> Self
pub fn new(key_pair: Ed25519KeyPair) -> Self
Sourcepub fn generate() -> Self
pub fn generate() -> Self
Create a new signer with a randomly generated key.
Uses a cryptographically secure random number generator.
§Example
use txgate_crypto::signer::Ed25519Signer;
let signer = Ed25519Signer::generate();Sourcepub fn from_bytes(bytes: [u8; 32]) -> Result<Self, SignError>
pub fn from_bytes(bytes: [u8; 32]) -> Result<Self, SignError>
Create a signer from raw secret key bytes.
§Arguments
bytes- The 32-byte secret key material.
§Errors
Returns an error if the bytes don’t represent a valid ed25519 secret key.
§Example
use txgate_crypto::signer::Ed25519Signer;
let secret = [0x42u8; 32];
let signer = Ed25519Signer::from_bytes(secret).expect("valid key");Sourcepub const fn key_pair(&self) -> &Ed25519KeyPair
pub const fn key_pair(&self) -> &Ed25519KeyPair
Get a reference to the underlying key pair.
This is useful when you need access to the full key pair functionality.
Trait Implementations§
Source§impl Debug for Ed25519Signer
impl Debug for Ed25519Signer
Auto Trait Implementations§
impl Freeze for Ed25519Signer
impl RefUnwindSafe for Ed25519Signer
impl Send for Ed25519Signer
impl Sync for Ed25519Signer
impl Unpin for Ed25519Signer
impl UnwindSafe for Ed25519Signer
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