Struct ed448_rust::PublicKey[]

pub struct PublicKey(_);

This is a public key. Should be distributed.

You can extract a PublicKey by calling Self::from().

Implementations

impl PublicKey

#[must_use]pub fn as_byte(&self) -> [u8; 57]

Convert the public key to an easily exportable format.

pub fn verify(&self, msg: &[u8], sign: &[u8], ctx: Option<&[u8]>) -> Result<()>

Verify signature with public key.

Example

use ed448_rust::{PublicKey, Ed448Error};
let message = b"Signed message to verify";
let public_key = retrieve_pubkey();
let signature = retrieve_signature();
match public_key.verify(message, &signature, None) {
    Ok(()) => {
        // Signature OK, use the message
    }
    Err(Ed448Error::InvalidSignature) => {
        // The verification of the signature is invalid
    }
    Err(Ed448Error::ContextTooLong) => {
        // The used context is more than 255 bytes length
    }
    Err(Ed448Error::WrongSignatureLength) => {
        // The signature is not 144 bytes length
    }
    Err(_) => unreachable!()
}

Errors

pub fn verify_ph(
    &self,
    msg: &[u8],
    sign: &[u8],
    ctx: Option<&[u8]>
) -> Result<()>

Verify signature with public key. Message is pre-hashed before checked.

See PublicKey::verify for more information.

Errors

Trait Implementations

impl Clone for PublicKey

impl Debug for PublicKey

impl From<&'_ [u8; 57]> for PublicKey

impl From<&'_ PrivateKey> for PublicKey

Instantiate a PublicKey from the PrivateKey.

impl From<[u8; 57]> for PublicKey

impl TryFrom<&'_ [u8]> for PublicKey

type Error = Ed448Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.