pub struct Signature(/* private fields */);Expand description
A recoverable ECDSA signature.
Implementations§
Source§impl Signature
impl Signature
Sourcepub fn create<T>(
private_key: &PrivateKey,
data: T,
) -> Result<Signature, SignerError>
pub fn create<T>( private_key: &PrivateKey, data: T, ) -> Result<Signature, SignerError>
Create a recoverable signature for the provided data using the private key.
Sourcepub fn create_from_digest(
private_key: &PrivateKey,
digest: Digest,
) -> Result<Signature, SignerError>
pub fn create_from_digest( private_key: &PrivateKey, digest: Digest, ) -> Result<Signature, SignerError>
Create a recoverable signature from a precomputed digest.
Sourcepub fn create_message<T>(
private_key: &PrivateKey,
data: T,
) -> Result<Signature, SignerError>
pub fn create_message<T>( private_key: &PrivateKey, data: T, ) -> Result<Signature, SignerError>
Create a recoverable signature for the provided digest using the private key according to EIP-191.
Sourcepub fn recover<T>(&self, data: T) -> Result<PublicKey, SignerError>
pub fn recover<T>(&self, data: T) -> Result<PublicKey, SignerError>
Recovers the public key which was used to create the signature for the signed data.
Sourcepub fn recover_from_digest(
&self,
digest: &Digest,
) -> Result<PublicKey, SignerError>
pub fn recover_from_digest( &self, digest: &Digest, ) -> Result<PublicKey, SignerError>
Recovers the public key using a precomputed digest.
Sourcepub fn recover_message<T>(&self, data: T) -> Result<PublicKey, SignerError>
pub fn recover_message<T>(&self, data: T) -> Result<PublicKey, SignerError>
Recovers public key which was used to create the signature for the signed message according to EIP-191 standard.
Sourcepub fn verify<T>(
&self,
public_key: PublicKey,
data: T,
) -> Result<(), SignerError>
pub fn verify<T>( &self, public_key: PublicKey, data: T, ) -> Result<(), SignerError>
Verifies the signature using the public key and data.
Sourcepub fn verify_with_digest(
&self,
public_key: PublicKey,
digest: &Digest,
) -> Result<(), SignerError>
pub fn verify_with_digest( &self, public_key: PublicKey, digest: &Digest, ) -> Result<(), SignerError>
Verifies the signature against a precomputed digest.
Sourcepub fn verify_message<T>(
&self,
public_key: PublicKey,
data: T,
) -> Result<(), SignerError>
pub fn verify_message<T>( &self, public_key: PublicKey, data: T, ) -> Result<(), SignerError>
Verifies message using Self::verify method according to EIP-191 standard.
Sourcepub fn validate<T>(&self, data: T) -> Result<PublicKey, SignerError>
pub fn validate<T>(&self, data: T) -> Result<PublicKey, SignerError>
Signature validation with recovery.
Sourcepub fn validate_message<T>(&self, data: T) -> Result<PublicKey, SignerError>
pub fn validate_message<T>(&self, data: T) -> Result<PublicKey, SignerError>
Signature validation: verify the signature with public key recovery from the signature of the message signed according to EIP-191 standard.
Sourcepub fn from_pre_eip155_bytes(bytes: [u8; 65]) -> Option<Signature>
pub fn from_pre_eip155_bytes(bytes: [u8; 65]) -> Option<Signature>
Creates a signature from the bytes in the pre-EIP-155 format (V in {27, 28}).
Sourcepub fn into_pre_eip155_bytes(self) -> [u8; 65]
pub fn into_pre_eip155_bytes(self) -> [u8; 65]
Convert signature into the pre-EIP-155 encoded bytes (V in {27, 28}).
Sourcepub fn as_raw_bytes(&self) -> [u8; 65]
pub fn as_raw_bytes(&self) -> [u8; 65]
Returns internal signature bytes with raw recovery id.
Sourcepub fn into_parts(self) -> (Signature<Secp256k1>, RecoveryId)
pub fn into_parts(self) -> (Signature<Secp256k1>, RecoveryId)
Return the inner signature and recovery id as k256 primitives.
Trait Implementations§
impl Copy for Signature
Source§impl Decode for Signature
Available on crate feature codec only.
impl Decode for Signature
codec only.Source§fn decode<I>(input: &mut I) -> Result<Signature, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<Signature, Error>where
I: Input,
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Source§impl<'de> Deserialize<'de> for Signature
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Signature
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<Signature, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Signature, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Encode for Signature
Available on crate feature codec only.
impl Encode for Signature
codec only.Source§fn encode_to<T>(&self, dest: &mut T)
fn encode_to<T>(&self, dest: &mut T)
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
impl Eq for Signature
Source§impl MaxEncodedLen for Signature
Available on crate feature codec only.
impl MaxEncodedLen for Signature
codec only.Source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Source§impl Serialize for Signature
Available on crate feature serde only.
impl Serialize for Signature
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for Signature
Auto Trait Implementations§
impl Freeze for Signature
impl RefUnwindSafe for Signature
impl Send for Signature
impl Sync for Signature
impl Unpin for Signature
impl UnsafeUnpin for Signature
impl UnwindSafe for Signature
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S> Codec for S
Source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> EncodeLike<&&T> for Twhere
T: Encode,
impl<T> EncodeLike<&T> for Twhere
T: Encode,
impl<T> EncodeLike<&mut T> for Twhere
T: Encode,
impl<T> EncodeLike<Arc<T>> for Twhere
T: Encode,
impl<T> EncodeLike<Box<T>> for Twhere
T: Encode,
impl<T> EncodeLike<Cow<'_, T>> for T
impl<T> EncodeLike<Rc<T>> for Twhere
T: Encode,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
impl<T> JsonSchemaMaybe for T
impl<T> MaybeDebug for Twhere
T: Debug,
impl<T> MaybeRefUnwindSafe for Twhere
T: RefUnwindSafe,
impl<T> StaticTypeInfo for Twhere
T: TypeInfo + 'static,
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.