polysig_driver::signers::ecdsa

Struct EcdsaSigner

Source
pub struct EcdsaSigner<'a> { /* private fields */ }
Available on crate feature ecdsa only.
Expand description

Create a signer for ECDSA signatures.

Implementations§

Source§

impl<'a> EcdsaSigner<'a>

Source

pub fn new(signing_key: Cow<'a, SigningKey>) -> Self

Create a new signer.

Source

pub fn from_slice(signing_key: &[u8]) -> Result<SigningKey>

Initialize a signing key from a byte slice.

Source

pub fn random() -> SigningKey

Generate a random private signing key.

Source

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.

Source

pub fn sign_prehash_recoverable( &self, prehash: &[u8], ) -> Result<(Signature, RecoveryId)>

Sign the given message prehash, returning a signature and recovery ID.

Source

pub fn sign(&self, message: &[u8]) -> Signature

Sign a message.

Source

pub fn verifying_key(&self) -> &VerifyingKey

Verifying key for this signer.

Source

pub fn verify(&self, message: &[u8], signature: &Signature) -> Result<()>

Verify a message.

Source

pub fn verify_prehash( &self, prehash: &[u8], signature: &Signature, ) -> Result<()>

Verify a prehash message.

Source

pub fn sign_eth(&self, message: &[u8]) -> Result<(Signature, RecoveryId)>

Sign a message for Ethereum first hashing the message with the Keccak256 digest.

Source

pub fn sign_eth_message<B: AsRef<[u8]>>( &self, message: B, ) -> Result<(Signature, RecoveryId)>

Sign an Ethereum message.

Source

pub fn recover( message: &[u8], signature: RecoverableSignature, ) -> Result<VerifyingKey>

Recover the public key from a signature and recovery identifier.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for EcdsaSigner<'a>

§

impl<'a> RefUnwindSafe for EcdsaSigner<'a>

§

impl<'a> Send for EcdsaSigner<'a>

§

impl<'a> Sync for EcdsaSigner<'a>

§

impl<'a> Unpin for EcdsaSigner<'a>

§

impl<'a> UnwindSafe for EcdsaSigner<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V