Struct oqs::sig::Sig

source ·
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

source

pub fn new(algorithm: Algorithm) -> Result<Self>

Construct a new algorithm

May fail if the algorithm is not available

source

pub fn algorithm(&self) -> Algorithm

Get the algorithm used by this Sig

source

pub fn version(&self) -> &'static str

Get the version of the implementation

source

pub fn claimed_nist_level(&self) -> u8

Obtain the claimed nist level

source

pub fn is_euf_cma(&self) -> bool

Is this algorithm EUF-CMA?

source

pub fn length_public_key(&self) -> usize

Length of the public key

source

pub fn length_secret_key(&self) -> usize

Length of the secret key

source

pub fn length_signature(&self) -> usize

Maximum length of a signature

source

pub fn secret_key_from_bytes<'a>( &self, buf: &'a [u8] ) -> Option<SecretKeyRef<'a>>

Construct a secret key object from bytes

source

pub fn public_key_from_bytes<'a>( &self, buf: &'a [u8] ) -> Option<PublicKeyRef<'a>>

Construct a public key object from bytes

source

pub fn signature_from_bytes<'a>( &self, buf: &'a [u8] ) -> Option<SignatureRef<'a>>

Construct a signature object from bytes

source

pub fn keypair(&self) -> Result<(PublicKey, SecretKey)>

Generate a new keypair

source

pub fn sign<'a, S: Into<SecretKeyRef<'a>>>( &self, message: &Message, sk: S ) -> Result<Signature>

Sign a message

source

pub fn verify<'a, 'b>( &self, message: &Message, signature: impl Into<SignatureRef<'a>>, pk: impl Into<PublicKeyRef<'b>> ) -> Result<()>

Verify a message

Trait Implementations§

source§

impl Drop for Sig

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl TryFrom<Algorithm> for Sig

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(alg: Algorithm) -> Result<Sig>

Performs the conversion.
source§

impl Send for Sig

source§

impl Sync for Sig

Auto Trait Implementations§

§

impl RefUnwindSafe for Sig

§

impl Unpin for Sig

§

impl UnwindSafe for Sig

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.