Skip to main content

Ed25519Signer

Struct Ed25519Signer 

Source
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

Source

pub fn new(key_pair: Ed25519KeyPair) -> Self

Create a new signer from a key pair.

§Arguments
  • key_pair - The ed25519 key pair to use for signing.
§Example
use txgate_crypto::keypair::{KeyPair, Ed25519KeyPair};
use txgate_crypto::signer::Ed25519Signer;

let key_pair = Ed25519KeyPair::generate();
let signer = Ed25519Signer::new(key_pair);
Source

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();
Source

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");
Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Signer for Ed25519Signer

Source§

fn sign(&self, hash: &[u8; 32]) -> Result<Vec<u8>, SignError>

Sign a 32-byte message hash. Read more
Source§

fn public_key(&self) -> &[u8]

Get the public key bytes. Read more
Source§

fn address(&self, chain: Chain) -> Result<String, SignError>

Derive the blockchain address for a specific chain. Read more
Source§

fn curve(&self) -> CurveType

Get the curve type used by this signer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V