Struct RecoveryId
pub struct RecoveryId(/* private fields */);Expand description
Recovery IDs, a.k.a. “recid”.
This is an integer value 0, 1, 2, or 3 included along with a
signature which is used during the recovery process to select the correct
public key from the signature.
It consists of two bits of information:
- low bit (0/1): was the y-coordinate of the affine point resulting from the fixed-base multiplication 𝑘×𝑮 odd? This part of the algorithm functions similar to point decompression.
- hi bit (3/4): did the affine x-coordinate of 𝑘×𝑮 overflow the order of
the scalar field, requiring a reduction when computing
r?
Implementations§
§impl RecoveryId
impl RecoveryId
pub const fn new(is_y_odd: bool, is_x_reduced: bool) -> RecoveryId
pub const fn new(is_y_odd: bool, is_x_reduced: bool) -> RecoveryId
Create a new RecoveryId from the following 1-bit arguments:
is_y_odd: is the affine y-coordinate of 𝑘×𝑮 odd?is_x_reduced: did the affine x-coordinate of 𝑘×𝑮 overflow the curve order?
pub const fn is_x_reduced(self) -> bool
pub const fn is_x_reduced(self) -> bool
Did the affine x-coordinate of 𝑘×𝑮 overflow the curve order?
pub const fn from_byte(byte: u8) -> Option<RecoveryId>
pub const fn from_byte(byte: u8) -> Option<RecoveryId>
Convert a u8 into a RecoveryId.
pub const fn to_byte(self) -> u8
pub const fn to_byte(self) -> u8
Convert this RecoveryId into a u8.
§impl RecoveryId
impl RecoveryId
pub fn trial_recovery_from_msg<C>(
verifying_key: &VerifyingKey<C>,
msg: &[u8],
signature: &Signature<C>,
) -> Result<RecoveryId, Error>where
C: DigestPrimitive + PrimeCurve + CurveArithmetic,
<C as CurveArithmetic>::AffinePoint: DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
<C as Curve>::FieldBytesSize: ModulusSize,
<<C as Curve>::FieldBytesSize as Add>::Output: ArrayLength<u8>,
pub fn trial_recovery_from_msg<C>(
verifying_key: &VerifyingKey<C>,
msg: &[u8],
signature: &Signature<C>,
) -> Result<RecoveryId, Error>where
C: DigestPrimitive + PrimeCurve + CurveArithmetic,
<C as CurveArithmetic>::AffinePoint: DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
<C as Curve>::FieldBytesSize: ModulusSize,
<<C as Curve>::FieldBytesSize as Add>::Output: ArrayLength<u8>,
Given a public key, message, and signature, use trial recovery to determine if a suitable recovery ID exists, or return an error otherwise.
pub fn trial_recovery_from_digest<C, D>(
verifying_key: &VerifyingKey<C>,
digest: D,
signature: &Signature<C>,
) -> Result<RecoveryId, Error>where
C: PrimeCurve + CurveArithmetic,
D: Digest,
<C as CurveArithmetic>::AffinePoint: DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
<C as Curve>::FieldBytesSize: ModulusSize,
<<C as Curve>::FieldBytesSize as Add>::Output: ArrayLength<u8>,
pub fn trial_recovery_from_digest<C, D>(
verifying_key: &VerifyingKey<C>,
digest: D,
signature: &Signature<C>,
) -> Result<RecoveryId, Error>where
C: PrimeCurve + CurveArithmetic,
D: Digest,
<C as CurveArithmetic>::AffinePoint: DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
<C as Curve>::FieldBytesSize: ModulusSize,
<<C as Curve>::FieldBytesSize as Add>::Output: ArrayLength<u8>,
Given a public key, message digest, and signature, use trial recovery to determine if a suitable recovery ID exists, or return an error otherwise.
pub fn trial_recovery_from_prehash<C>(
verifying_key: &VerifyingKey<C>,
prehash: &[u8],
signature: &Signature<C>,
) -> Result<RecoveryId, Error>where
C: PrimeCurve + CurveArithmetic,
<C as CurveArithmetic>::AffinePoint: DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
<C as Curve>::FieldBytesSize: ModulusSize,
<<C as Curve>::FieldBytesSize as Add>::Output: ArrayLength<u8>,
pub fn trial_recovery_from_prehash<C>(
verifying_key: &VerifyingKey<C>,
prehash: &[u8],
signature: &Signature<C>,
) -> Result<RecoveryId, Error>where
C: PrimeCurve + CurveArithmetic,
<C as CurveArithmetic>::AffinePoint: DecompressPoint<C> + FromEncodedPoint<C> + ToEncodedPoint<C> + VerifyPrimitive<C>,
<C as Curve>::FieldBytesSize: ModulusSize,
<<C as Curve>::FieldBytesSize as Add>::Output: ArrayLength<u8>,
Given a public key, message digest, and signature, use trial recovery to determine if a suitable recovery ID exists, or return an error otherwise.
Trait Implementations§
§impl Clone for RecoveryId
impl Clone for RecoveryId
§fn clone(&self) -> RecoveryId
fn clone(&self) -> RecoveryId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for RecoveryId
impl Debug for RecoveryId
§impl Ord for RecoveryId
impl Ord for RecoveryId
§impl PartialEq for RecoveryId
impl PartialEq for RecoveryId
§impl PartialOrd for RecoveryId
impl PartialOrd for RecoveryId
§impl TryFrom<u8> for RecoveryId
impl TryFrom<u8> for RecoveryId
impl Copy for RecoveryId
impl Eq for RecoveryId
impl StructuralPartialEq for RecoveryId
Auto Trait Implementations§
impl Freeze for RecoveryId
impl RefUnwindSafe for RecoveryId
impl Send for RecoveryId
impl Sync for RecoveryId
impl Unpin for RecoveryId
impl UnwindSafe for RecoveryId
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
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 more