Skip to main content

Signer

Trait Signer 

Source
pub trait Signer {
    type Signature;
    type Error;

    // Required methods
    fn sign(&self, message: &[u8]) -> Result<Self::Signature, Self::Error>;
    fn sign_prehashed(
        &self,
        digest: &[u8],
    ) -> Result<Self::Signature, Self::Error>;
    fn public_key_bytes(&self) -> Vec<u8> ;
    fn public_key_bytes_uncompressed(&self) -> Vec<u8> ;
}
Expand description

A type that can produce cryptographic signatures.

Required Associated Types§

Source

type Signature

The signature type produced by this signer.

Source

type Error

The error type returned on failure.

Required Methods§

Source

fn sign(&self, message: &[u8]) -> Result<Self::Signature, Self::Error>

Sign a raw message. The implementation applies chain-specific hashing internally (e.g., Keccak-256 for Ethereum, double-SHA-256 for Bitcoin).

Source

fn sign_prehashed(&self, digest: &[u8]) -> Result<Self::Signature, Self::Error>

Sign a pre-hashed digest directly. The caller is responsible for applying the correct hash function. Returns InvalidHashLength if the digest length doesn’t match the expected hash output size.

Source

fn public_key_bytes(&self) -> Vec<u8>

Return the public key as bytes (compressed format where applicable).

  • ECDSA (secp256k1, P-256): 33 bytes (SEC1 compressed)
  • Ed25519: 32 bytes
  • BIP-340 Schnorr: 32 bytes (x-only)
  • BLS12-381: 48 bytes (compressed G1)
Source

fn public_key_bytes_uncompressed(&self) -> Vec<u8>

Return the public key in uncompressed format.

  • ECDSA (secp256k1, P-256): 65 bytes (04 || x || y)
  • Ed25519 / Schnorr / BLS: same as public_key_bytes() (no uncompressed form)

Implementors§