Struct ed448_rust::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
Ed448Error::InvalidSignature
if the signature is not valid, either the public key or the signature used are not the right, or the message has been altered.Ed448Error::ContextTooLong
if the optional context is more than 255 byte length.Ed448Error::WrongSignatureLength
if the signature is notSIG_LENGTH
byte.
pub fn verify_ph(
&self,
msg: &[u8],
sign: &[u8],
ctx: Option<&[u8]>
) -> Result<()>
&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
Ed448Error::InvalidSignature
if the signature is not valid, either the public key or the signature used are not the right, or the message has been altered.Ed448Error::ContextTooLong
if the optional context is more than 255 byte length.Ed448Error::WrongSignatureLength
if the signature is notSIG_LENGTH
byte.
Trait Implementations
impl Clone for PublicKey
fn clone(&self) -> PublicKey
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for PublicKey
impl From<&'_ [u8; 57]> for PublicKey
impl From<&'_ PrivateKey> for PublicKey
Instantiate a PublicKey
from the PrivateKey
.
fn from(private_key: &PrivateKey) -> Self
impl From<[u8; 57]> for PublicKey
impl TryFrom<&'_ [u8]> for PublicKey
Auto Trait Implementations
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,