pub struct Wallet { /* private fields */ }Expand description
An owning secp256k1 wallet.
Construction is explicit (from_bytes / from_hex / random_for_testing).
The inner SigningKey zeroizes on drop automatically. Debug does not
reveal the key material — only the derived address.
Implementations§
Source§impl Wallet
impl Wallet
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Result<Wallet, ClientError>
pub fn from_bytes(bytes: [u8; 32]) -> Result<Wallet, ClientError>
Construct from a 32-byte secret scalar.
§Errors
Returns ClientError::InvalidKey if the bytes are not a valid
secp256k1 scalar (zero or ≥ curve order).
Sourcepub fn from_hex(s: &str) -> Result<Wallet, ClientError>
pub fn from_hex(s: &str) -> Result<Wallet, ClientError>
Construct from a hex private key (with or without 0x prefix).
§Errors
Returns ClientError::InvalidKey on wrong length / non-hex / not a
valid scalar.
Source§impl Wallet
impl Wallet
Sourcepub fn sign_eip712<T>(&self, msg: &T) -> Result<Signature, ClientError>where
T: Eip712,
pub fn sign_eip712<T>(&self, msg: &T) -> Result<Signature, ClientError>where
T: Eip712,
Sign an EIP-712 typed message and produce a 65-byte signature.
The signing is deterministic (RFC-6979 nonces).
§Errors
Returns ClientError::Signature only if the k256 prehash signer
fails, which is extremely rare (essentially never in practice for
valid keys + 32-byte digests).
Sourcepub fn sign_digest(&self, digest: &[u8; 32]) -> Result<Signature, ClientError>
pub fn sign_digest(&self, digest: &[u8; 32]) -> Result<Signature, ClientError>
Sign an arbitrary 32-byte digest with the wallet key.
Lower-level than Wallet::sign_eip712 — use only when you already
have the EIP-712 digest computed externally.
§Errors
See Wallet::sign_eip712.