Skip to main content

EcdsaP521Sha512

Struct EcdsaP521Sha512 

Source
pub struct EcdsaP521Sha512;
Expand description

ECDSA over P-521 with SHA-512.

Implementations§

Source§

impl EcdsaP521Sha512

Source

pub fn verify_prehash( public_key: &[u8], digest: &[u8], signature: &[u8], ) -> Result<()>

Verify a signature over a digest the caller computed, for signatures made with a hash other than SHA-512.

digest must be one of crate::PREHASH_LENS and at least 64 bytes, so that the hash is at least as strong as the curve; narrower is refused with InvalidLength. Which hash produced it is the caller’s to establish: nothing here can tell.

Source

pub fn public_key_compressed(private_key: &[u8], out: &mut [u8]) -> Result<()>

Compute the public key in SEC1 compressed form (67 bytes).

Source

pub fn normalize_s(signature: &mut [u8]) -> Result<()>

Rewrite a signature to its low-s form, if it is not already.

ECDSA is malleable: (r, s) and (r, n - s) are both valid for the same message, so a signature is not a unique identifier unless one form is chosen. FIPS 186-5 and RFC 6979 accept both, and this library signs and verifies per the standard, so normalization is offered rather than imposed – apply it when a signature doubles as a database key or a transaction id.

Source

pub fn has_low_s(signature: &[u8]) -> Result<bool>

Whether a signature is already in low-s form.

Trait Implementations§

Source§

impl Algorithm for EcdsaP521Sha512

Source§

const ID: &'static str = "ecdsa-p521-sha512"

Stable ontology identifier for this algorithm.
Source§

const NAME: &'static str = "ECDSA P-521 with SHA-512"

Human-facing display name (for example "SHA-256").
Source§

impl SelfTest for EcdsaP521Sha512

Source§

fn self_test() -> Result<()>

Run the algorithm’s known-answer test. Read more
Source§

impl SignatureScheme for EcdsaP521Sha512

Source§

const PUBLIC_KEY_LEN: usize = 133

SEC1 uncompressed: 0x04 || X || Y.

Source§

const SIGNATURE_LEN: usize = 132

Fixed-width r || s.

Source§

const PRIVATE_KEY_LEN: usize = 66

Seed / private key length in bytes.
Source§

fn public_key(private_key: &[u8], out: &mut [u8]) -> Result<()>

Derive the public key from a private key.
Source§

fn sign(private_key: &[u8], message: &[u8], signature: &mut [u8]) -> Result<()>

Sign message, writing exactly Self::SIGNATURE_LEN bytes.
Source§

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

Verify a signature, returning crate::ErrorKind::AuthenticationFailed when it does not check out.

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.