pub struct Signature { /* private fields */ }Expand description
An Ethereum ECDSA signature.
Implementations§
Source§impl Signature
impl Signature
Sourcepub fn decode_rlp_vrs(
buf: &mut &[u8],
decode_parity: impl FnOnce(&mut &[u8]) -> Result<bool>,
) -> Result<Self, Error>
Available on crate feature rlp only.
pub fn decode_rlp_vrs( buf: &mut &[u8], decode_parity: impl FnOnce(&mut &[u8]) -> Result<bool>, ) -> Result<Self, Error>
rlp only.Decode an RLP-encoded VRS signature. Accepts decode_parity closure which allows to
customize parity decoding and possibly extract additional data from it (e.g chain_id for
legacy signature).
Source§impl Signature
impl Signature
Sourcepub const fn new(r: U256, s: U256, y_parity: bool) -> Self
pub const fn new(r: U256, s: U256, y_parity: bool) -> Self
Instantiate a new signature from r, s, and v values.
Sourcepub fn from_raw(bytes: &[u8]) -> Result<Self, SignatureError>
pub fn from_raw(bytes: &[u8]) -> Result<Self, SignatureError>
Parses a 65-byte long raw signature.
The first 32 bytes is the r value, the second 32 bytes the s value, and the final byte
is the v value in ‘Electrum’ notation.
Sourcepub fn from_raw_array(bytes: &[u8; 65]) -> Result<Self, SignatureError>
pub fn from_raw_array(bytes: &[u8; 65]) -> Result<Self, SignatureError>
Parses a 65-byte long raw signature.
See from_raw.
Sourcepub fn from_bytes_and_parity(bytes: &[u8], parity: bool) -> Self
pub fn from_bytes_and_parity(bytes: &[u8], parity: bool) -> Self
Parses a signature from a byte slice, with a v value
§Panics
If the slice is not at least 64 bytes long.
Sourcepub fn as_bytes(&self) -> [u8; 65]
pub fn as_bytes(&self) -> [u8; 65]
Returns the byte-array representation of this signature.
The first 32 bytes are the r value, the second 32 bytes the s value
and the final byte is the v value in ‘Electrum’ notation.
Sourcepub fn as_rsy(&self) -> [u8; 65]
pub fn as_rsy(&self) -> [u8; 65]
Returns the byte-array representation of this signature as (r, s, y_parity).
The first 32 bytes are the r value, the second 32 bytes the s value,
and the final byte is the y_parity value as-is (0 or 1).
See as_erc2098 for the compact ERC-2098 representation.
Sourcepub fn from_erc2098(bytes: &[u8]) -> Self
pub fn from_erc2098(bytes: &[u8]) -> Self
Decode the signature from the ERC-2098 compact representation.
The first 32 bytes are the r value, and the next 32 bytes are the s value with yParity
in the top bit of the s value, as described in ERC-2098.
See https://eips.ethereum.org/EIPS/eip-2098
§Panics
If the slice is not at least 64 bytes long.
Sourcepub fn as_erc2098(&self) -> [u8; 64]
pub fn as_erc2098(&self) -> [u8; 64]
Returns the ERC-2098 compact representation of this signature.
The first 32 bytes are the r value, and the next 32 bytes are the s value with yParity
in the top bit of the s value, as described in ERC-2098.
Sourcepub fn with_parity(self, v: bool) -> Self
pub fn with_parity(self, v: bool) -> Self
Sets the recovery ID by normalizing a v value.
Sourcepub fn to_k256(self) -> Result<Signature, Error>
Available on crate feature k256 only.
pub fn to_k256(self) -> Result<Signature, Error>
k256 only.Returns the inner ECDSA signature.
Sourcepub fn from_signature_and_parity(sig: Signature, v: bool) -> Self
Available on crate feature k256 only.
pub fn from_signature_and_parity(sig: Signature, v: bool) -> Self
k256 only.Instantiate from a signature and recovery id
Sourcepub fn from_scalars_and_parity(r: B256, s: B256, parity: bool) -> Self
pub fn from_scalars_and_parity(r: B256, s: B256, parity: bool) -> Self
Creates a Signature from the serialized r and s scalar values, which
comprise the ECDSA signature, alongside a v value, used to determine the recovery ID.
Sourcepub fn normalize_s(&self) -> Option<Self>
pub fn normalize_s(&self) -> Option<Self>
Normalizes the signature into “low S” form as described in BIP 0062: Dealing with Malleability.
If s is already normalized, returns None.
Sourcepub fn normalized_s(self) -> Self
pub fn normalized_s(self) -> Self
Normalizes the signature into “low S” form as described in BIP 0062: Dealing with Malleability.
If s is already normalized, returns self.
Sourcepub fn recid(&self) -> RecoveryId
Available on crate feature k256 only.
pub fn recid(&self) -> RecoveryId
k256 only.Returns the recovery ID.
Sourcepub fn recover_address_from_msg<T: AsRef<[u8]>>(
&self,
msg: T,
) -> Result<Address, SignatureError>
Available on crate feature k256 only.
pub fn recover_address_from_msg<T: AsRef<[u8]>>( &self, msg: T, ) -> Result<Address, SignatureError>
k256 only.Sourcepub fn recover_address_from_prehash(
&self,
prehash: &B256,
) -> Result<Address, SignatureError>
Available on crate feature k256 only.
pub fn recover_address_from_prehash( &self, prehash: &B256, ) -> Result<Address, SignatureError>
k256 only.Recovers an Address from this signature and the given prehashed message.
Sourcepub fn recover_from_msg<T: AsRef<[u8]>>(
&self,
msg: T,
) -> Result<VerifyingKey, SignatureError>
Available on crate feature k256 only.
pub fn recover_from_msg<T: AsRef<[u8]>>( &self, msg: T, ) -> Result<VerifyingKey, SignatureError>
k256 only.Recovers a VerifyingKey from this signature and the given message by first prefixing and
hashing the message according to EIP-191.
Sourcepub fn recover_from_prehash(
&self,
prehash: &B256,
) -> Result<VerifyingKey, SignatureError>
Available on crate feature k256 only.
pub fn recover_from_prehash( &self, prehash: &B256, ) -> Result<VerifyingKey, SignatureError>
k256 only.Recovers a VerifyingKey from this signature and the given prehashed message.
Sourcepub fn rlp_rs_len(&self) -> usize
Available on crate feature rlp only.
pub fn rlp_rs_len(&self) -> usize
rlp only.Length of RLP RS field encoding
Sourcepub fn write_rlp_rs(&self, out: &mut dyn BufMut)
Available on crate feature rlp only.
pub fn write_rlp_rs(&self, out: &mut dyn BufMut)
rlp only.Write R and S to an RLP buffer in progress.
Sourcepub fn write_rlp_vrs(&self, out: &mut dyn BufMut, v: impl Encodable)
Available on crate feature rlp only.
pub fn write_rlp_vrs(&self, out: &mut dyn BufMut, v: impl Encodable)
rlp only.Write the VRS to the output.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Signature
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Signature
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Arbitrary for Signature
Available on crate feature arbitrary only.
impl Arbitrary for Signature
arbitrary only.Source§type Parameters = ()
type Parameters = ()
arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default.Source§type Strategy = Map<<(Uint<256, 4>, Uint<256, 4>, bool) as Arbitrary>::Strategy, fn((Uint<256, 4>, Uint<256, 4>, bool)) -> Signature>
type Strategy = Map<<(Uint<256, 4>, Uint<256, 4>, bool) as Arbitrary>::Strategy, fn((Uint<256, 4>, Uint<256, 4>, bool)) -> Signature>
Strategy used to generate values of type Self.Source§fn arbitrary_with((): Self::Parameters) -> Self::Strategy
fn arbitrary_with((): Self::Parameters) -> Self::Strategy
Source§impl<'__expr> AsExpression<Binary> for &'__expr Signature
impl<'__expr> AsExpression<Binary> for &'__expr Signature
Source§type Expression = Bound<Binary, &'__expr Signature>
type Expression = Bound<Binary, &'__expr Signature>
Source§fn as_expression(self) -> <Self as AsExpression<Binary>>::Expression
fn as_expression(self) -> <Self as AsExpression<Binary>>::Expression
Source§impl AsExpression<Binary> for Signature
impl AsExpression<Binary> for Signature
Source§type Expression = Bound<Binary, Signature>
type Expression = Bound<Binary, Signature>
Source§fn as_expression(self) -> <Self as AsExpression<Binary>>::Expression
fn as_expression(self) -> <Self as AsExpression<Binary>>::Expression
Source§impl<'__expr> AsExpression<Nullable<Binary>> for &'__expr Signature
impl<'__expr> AsExpression<Nullable<Binary>> for &'__expr Signature
Source§fn as_expression(self) -> <Self as AsExpression<Nullable<Binary>>>::Expression
fn as_expression(self) -> <Self as AsExpression<Nullable<Binary>>>::Expression
Source§impl AsExpression<Nullable<Binary>> for Signature
impl AsExpression<Nullable<Binary>> for Signature
Source§fn as_expression(self) -> <Self as AsExpression<Nullable<Binary>>>::Expression
fn as_expression(self) -> <Self as AsExpression<Nullable<Binary>>>::Expression
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<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<(Signature<Secp256k1>, RecoveryId)> for Signature
Available on crate feature k256 only.
impl From<(Signature<Secp256k1>, RecoveryId)> for Signature
k256 only.Source§fn from(value: (Signature, RecoveryId)) -> Self
fn from(value: (Signature, RecoveryId)) -> Self
impl Copy for Signature
impl Eq for Signature
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 UnwindSafe for Signature
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WindowExpressionMethods for T
impl<T> WindowExpressionMethods for T
Source§fn over(self) -> Self::Outputwhere
Self: OverDsl,
fn over(self) -> Self::Outputwhere
Self: OverDsl,
Source§fn window_filter<P>(self, f: P) -> Self::Output
fn window_filter<P>(self, f: P) -> Self::Output
Source§fn partition_by<E>(self, expr: E) -> Self::Outputwhere
Self: PartitionByDsl<E>,
fn partition_by<E>(self, expr: E) -> Self::Outputwhere
Self: PartitionByDsl<E>,
Source§fn window_order<E>(self, expr: E) -> Self::Outputwhere
Self: OrderWindowDsl<E>,
fn window_order<E>(self, expr: E) -> Self::Outputwhere
Self: OrderWindowDsl<E>,
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 72 bytes