Skip to main content

hyper_exchange/
signer.rs

1use crate::types::ExchangeError;
2
3/// Trait for signing message hashes.
4///
5/// This abstracts over different key management backends (keyring, HD wallet, etc.)
6/// so that the exchange crate does not depend on any specific implementation.
7pub trait Signer: Send + Sync {
8    /// Sign an arbitrary message hash (32 bytes) with the key for the given address.
9    ///
10    /// Returns a 65-byte signature: r (32 bytes) + s (32 bytes) + v (1 byte, recovery id 0 or 1).
11    fn sign_hash(&self, address: &str, hash: &[u8; 32]) -> Result<[u8; 65], ExchangeError>;
12}