pub struct Signature<P: ParameterSet> { /* private fields */ }Expand description
Represents a signature using the specified parameter set.
§Usage
use parameter_sets::ML_DSA_44 as P;
let msg: &[u8] = b"Hello, world!";
let signature = sk.sign(msg);
// There are different ways to obtain a byte representation of the
// signature.
let signature_encoding = signature.to_bytes();
let encoded_signature_via_SignatureEncoding: &[u8] = &signature_encoding;
let encoded_signature_via_AsBytes = signature.as_bytes();
assert_eq!(encoded_signature_via_SignatureEncoding, encoded_signature_via_AsBytes);
let encoded_signature = encoded_signature_via_AsBytes;
let recv_sig: Signature<P> = encoded_signature.try_into()
.expect("Failed to parse the received signature");
assert_eq!(recv_sig, signature);
// Equivalently, using the FromBytes trait
let decoded_signature = Signature::<P>::from_bytes(encoded_signature)
.expect("Failed to decode the received signature");
assert_eq!(decoded_signature, signature);If the crate is built without the rand feature, then the sign method
(which takes only the msg as an argument) will not be available. In that
case, you must generate your own random bytes and use the signing methods
provided by the SeededSigner trait.
Trait Implementations§
Source§impl<P: ParameterSet> ContextSigner<Signature<P>> for SigningKey<P>
Available on crate feature rand only.
impl<P: ParameterSet> ContextSigner<Signature<P>> for SigningKey<P>
Available on crate feature
rand only.Source§fn try_sign_with_ctx(
&self,
msg: &[u8],
ctx: &[u8],
) -> Result<Signature<P>, Error>
fn try_sign_with_ctx( &self, msg: &[u8], ctx: &[u8], ) -> Result<Signature<P>, Error>
Attempt to sign the given message, returning a digital signature on
success, or an error if something went wrong. Read more
Source§fn sign_with_context(&self, msg: &[u8], ctx: &[u8]) -> S
fn sign_with_context(&self, msg: &[u8], ctx: &[u8]) -> S
Sign the given message and return a digital signature
impl<P: Eq + ParameterSet> Eq for Signature<P>
Source§impl<P: ParameterSet> From<Signature<P>> for GenericArray<u8, <P as SignatureLen>::LEN>
impl<P: ParameterSet> From<Signature<P>> for GenericArray<u8, <P as SignatureLen>::LEN>
Source§impl<P: PartialEq + ParameterSet> PartialEq for Signature<P>
impl<P: PartialEq + ParameterSet> PartialEq for Signature<P>
Source§impl<P: ParameterSet> SeededContextSigner<Signature<P>> for SigningKey<P>
impl<P: ParameterSet> SeededContextSigner<Signature<P>> for SigningKey<P>
Source§impl<P: ParameterSet> SeededSigner<Signature<P>> for SigningKey<P>
impl<P: ParameterSet> SeededSigner<Signature<P>> for SigningKey<P>
Source§fn try_sign_with_seed(
&self,
seed: &[u8],
msg: &[u8],
) -> Result<Signature<P>, Error>
fn try_sign_with_seed( &self, seed: &[u8], msg: &[u8], ) -> Result<Signature<P>, Error>
Attempt to sign the given message, returning a digital signature on
success, or an error if something went wrong. Read more
Source§fn sign_with_seed(&self, seed: &[u8], msg: &[u8]) -> S
fn sign_with_seed(&self, seed: &[u8], msg: &[u8]) -> S
Sign the given message and return a digital signature
Source§impl<P: ParameterSet> SignatureEncoding for Signature<P>
impl<P: ParameterSet> SignatureEncoding for Signature<P>
Source§type Repr = GenericArray<u8, <P as SignatureLen>::LEN>
type Repr = GenericArray<u8, <P as SignatureLen>::LEN>
Byte representation of a signature.
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Get the length of this signature when encoded.
Source§impl<P: ParameterSet> Signer<Signature<P>> for SigningKey<P>
Available on crate feature rand only.
impl<P: ParameterSet> Signer<Signature<P>> for SigningKey<P>
Available on crate feature
rand only.impl<P: PartialEq + ParameterSet> StructuralPartialEq for Signature<P>
Auto Trait Implementations§
impl<P> Freeze for Signature<P>
impl<P> RefUnwindSafe for Signature<P>
impl<P> Send for Signature<P>
impl<P> Sync for Signature<P>
impl<P> Unpin for Signature<P>
impl<P> UnsafeUnpin for Signature<P>
impl<P> UnwindSafe for Signature<P>
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