pub struct Sig { /* private fields */ }
Expand description
Signature scheme
Example
use oqs;
oqs::init();
let scheme = oqs::sig::Sig::new(oqs::sig::Algorithm::Dilithium2).unwrap();
let message = [0u8; 100];
let (pk, sk) = scheme.keypair().unwrap();
let signature = scheme.sign(&message, &sk).unwrap();
assert!(scheme.verify(&message, &signature, &pk).is_ok());
Implementations§
source§impl Sig
impl Sig
sourcepub fn new(algorithm: Algorithm) -> Result<Self>
pub fn new(algorithm: Algorithm) -> Result<Self>
Construct a new algorithm
May fail if the algorithm is not available
sourcepub fn claimed_nist_level(&self) -> u8
pub fn claimed_nist_level(&self) -> u8
Obtain the claimed nist level
sourcepub fn is_euf_cma(&self) -> bool
pub fn is_euf_cma(&self) -> bool
Is this algorithm EUF-CMA?
sourcepub fn length_public_key(&self) -> usize
pub fn length_public_key(&self) -> usize
Length of the public key
sourcepub fn length_secret_key(&self) -> usize
pub fn length_secret_key(&self) -> usize
Length of the secret key
sourcepub fn length_signature(&self) -> usize
pub fn length_signature(&self) -> usize
Maximum length of a signature
sourcepub fn secret_key_from_bytes<'a>(
&self,
buf: &'a [u8]
) -> Option<SecretKeyRef<'a>>
pub fn secret_key_from_bytes<'a>( &self, buf: &'a [u8] ) -> Option<SecretKeyRef<'a>>
Construct a secret key object from bytes
sourcepub fn public_key_from_bytes<'a>(
&self,
buf: &'a [u8]
) -> Option<PublicKeyRef<'a>>
pub fn public_key_from_bytes<'a>( &self, buf: &'a [u8] ) -> Option<PublicKeyRef<'a>>
Construct a public key object from bytes
sourcepub fn signature_from_bytes<'a>(
&self,
buf: &'a [u8]
) -> Option<SignatureRef<'a>>
pub fn signature_from_bytes<'a>( &self, buf: &'a [u8] ) -> Option<SignatureRef<'a>>
Construct a signature object from bytes
sourcepub fn sign<'a, S: Into<SecretKeyRef<'a>>>(
&self,
message: &Message,
sk: S
) -> Result<Signature>
pub fn sign<'a, S: Into<SecretKeyRef<'a>>>( &self, message: &Message, sk: S ) -> Result<Signature>
Sign a message
sourcepub fn verify<'a, 'b>(
&self,
message: &Message,
signature: impl Into<SignatureRef<'a>>,
pk: impl Into<PublicKeyRef<'b>>
) -> Result<()>
pub fn verify<'a, 'b>( &self, message: &Message, signature: impl Into<SignatureRef<'a>>, pk: impl Into<PublicKeyRef<'b>> ) -> Result<()>
Verify a message
Trait Implementations§
Auto Trait Implementations§
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