Skip to main content

CryptoProvider

Trait CryptoProvider 

Source
pub trait CryptoProvider: Send + Sync {
    // Required methods
    fn verify_ed25519<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        pubkey: &'life1 [u8],
        message: &'life2 [u8],
        signature: &'life3 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<(), CryptoError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn sign_ed25519<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        seed: &'life1 SecureSeed,
        message: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CryptoError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn generate_ed25519_keypair<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(SecureSeed, [u8; 32]), CryptoError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn ed25519_public_key_from_seed<'life0, 'life1, 'async_trait>(
        &'life0 self,
        seed: &'life1 SecureSeed,
    ) -> Pin<Box<dyn Future<Output = Result<[u8; 32], CryptoError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Abstraction for Ed25519 cryptographic operations across target architectures.

All method signatures use primitive Rust types or SecureSeed — no ring-specific types. This ensures domain crates (auths-core, auths-sdk) compile without any ring dependency.

Usage:

use auths_crypto::CryptoProvider;

async fn roundtrip(provider: &dyn CryptoProvider) {
    let (seed, pk) = provider.generate_ed25519_keypair().await.unwrap();
    let sig = provider.sign_ed25519(&seed, b"msg").await.unwrap();
    provider.verify_ed25519(&pk, b"msg", &sig).await.unwrap();
}

Required Methods§

Source

fn verify_ed25519<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, pubkey: &'life1 [u8], message: &'life2 [u8], signature: &'life3 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), CryptoError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Verify an Ed25519 signature against a public key and message.

Source

fn sign_ed25519<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, seed: &'life1 SecureSeed, message: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, CryptoError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Sign a message using a raw 32-byte Ed25519 seed.

The provider materializes the internal keypair from the seed on each call. This trades minor CPU overhead for a pure, ring-free domain layer.

Args:

  • seed: Raw 32-byte Ed25519 private key seed.
  • message: The data to sign.

Usage:

let sig = provider.sign_ed25519(&seed, b"hello").await?;
assert_eq!(sig.len(), 64);
Source

fn generate_ed25519_keypair<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(SecureSeed, [u8; 32]), CryptoError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generate a fresh Ed25519 keypair.

Returns the raw 32-byte seed and 32-byte public key.

Usage:

let (seed, pubkey) = provider.generate_ed25519_keypair().await?;
assert_eq!(pubkey.len(), 32);
Source

fn ed25519_public_key_from_seed<'life0, 'life1, 'async_trait>( &'life0 self, seed: &'life1 SecureSeed, ) -> Pin<Box<dyn Future<Output = Result<[u8; 32], CryptoError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Derive the 32-byte public key from a raw seed.

Args:

  • seed: Raw 32-byte Ed25519 private key seed.

Usage:

let pk = provider.ed25519_public_key_from_seed(&seed).await?;
assert_eq!(pk.len(), 32);

Implementors§