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§
Required Methods§
Sourcefn sign(&self, message: &[u8]) -> Result<Self::Signature, Self::Error>
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).
Sourcefn sign_prehashed(&self, digest: &[u8]) -> Result<Self::Signature, Self::Error>
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.
Sourcefn public_key_bytes(&self) -> Vec<u8> ⓘ
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)
Sourcefn public_key_bytes_uncompressed(&self) -> Vec<u8> ⓘ
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)