pub struct EcdsaSigner<'a> { /* private fields */ }
ecdsa
only.Expand description
Create a signer for ECDSA signatures.
Implementations§
Source§impl<'a> EcdsaSigner<'a>
impl<'a> EcdsaSigner<'a>
Sourcepub fn new(signing_key: Cow<'a, SigningKey>) -> Self
pub fn new(signing_key: Cow<'a, SigningKey>) -> Self
Create a new signer.
Sourcepub fn from_slice(signing_key: &[u8]) -> Result<SigningKey>
pub fn from_slice(signing_key: &[u8]) -> Result<SigningKey>
Initialize a signing key from a byte slice.
Sourcepub fn random() -> SigningKey
pub fn random() -> SigningKey
Generate a random private signing key.
Sourcepub fn sign_recoverable(
&self,
message: &[u8],
) -> Result<(Signature, RecoveryId)>
pub fn sign_recoverable( &self, message: &[u8], ) -> Result<(Signature, RecoveryId)>
Sign the given message, hashing it with the curve’s default digest function, and returning a signature and recovery ID.
Sourcepub fn sign_prehash_recoverable(
&self,
prehash: &[u8],
) -> Result<(Signature, RecoveryId)>
pub fn sign_prehash_recoverable( &self, prehash: &[u8], ) -> Result<(Signature, RecoveryId)>
Sign the given message prehash, returning a signature and recovery ID.
Sourcepub fn verifying_key(&self) -> &VerifyingKey
pub fn verifying_key(&self) -> &VerifyingKey
Verifying key for this signer.
Sourcepub fn verify_prehash(
&self,
prehash: &[u8],
signature: &Signature,
) -> Result<()>
pub fn verify_prehash( &self, prehash: &[u8], signature: &Signature, ) -> Result<()>
Verify a prehash message.
Sourcepub fn sign_eth(&self, message: &[u8]) -> Result<(Signature, RecoveryId)>
pub fn sign_eth(&self, message: &[u8]) -> Result<(Signature, RecoveryId)>
Sign a message for Ethereum first hashing the message with the Keccak256 digest.
Sourcepub fn sign_eth_message<B: AsRef<[u8]>>(
&self,
message: B,
) -> Result<(Signature, RecoveryId)>
pub fn sign_eth_message<B: AsRef<[u8]>>( &self, message: B, ) -> Result<(Signature, RecoveryId)>
Sign an Ethereum message.
Sourcepub fn recover(
message: &[u8],
signature: RecoverableSignature,
) -> Result<VerifyingKey>
pub fn recover( message: &[u8], signature: RecoverableSignature, ) -> Result<VerifyingKey>
Recover the public key from a signature and recovery identifier.
Sourcepub fn hash_message<T: AsRef<[u8]>>(message: T) -> impl Digest
pub fn hash_message<T: AsRef<[u8]>>(message: T) -> impl Digest
Hash a message according to EIP-191 (version 0x01
).
The final message is a UTF-8 string, encoded as follows:
"\x19Ethereum Signed Message:\n" + message.length + message
This message is then hashed using Keccak-256.