Struct PublicKey
pub struct PublicKey(/* private fields */);
Expand description
This is a public key. Should be distributed.
You can extract a PublicKey
by calling Self::from()
.
Implementations§
§impl PublicKey
impl PublicKey
pub fn verify(&self, msg: &[u8], sign: &[u8], ctx: Option<&[u8]>) -> Result<()>
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<()>
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
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 From<&PrivateKey> for PublicKey
Instantiate a PublicKey
from the PrivateKey
.
impl From<&PrivateKey> for PublicKey
Instantiate a PublicKey
from the PrivateKey
.
§fn from(private_key: &PrivateKey) -> Self
fn from(private_key: &PrivateKey) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for PublicKey
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
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
Mutably borrows from an owned value. Read more