Crate picnic_bindings
source ·Expand description
Bindings for Picnic: Post-Quantum Signatures
The Picnic signature scheme is a family of digital signature schemes secure against attacks by quantum computers. This crate provides bindings that implements the traits from the signature crate.
More information on Picnic is available on the project website: https://microsoft.github.io/Picnic/
Serialization and deserialization is implemented via the serde
crate. By enabling the
serialization
feature, all public structs implement the Serialize
and Deserialize
traits.
Usage
Key generation, signing and verification can be implemented as follows:
use picnic_bindings::{PicnicL1FSSigningKey, Signer, Verifier};
let (signing_key, verification_key) = PicnicL1FSSigningKey::random().expect("Key generation failed");
let msg = "some message".as_bytes();
let signature = signing_key.sign(msg);
verification_key.verify(msg, &signature).expect("Verification failed");
Keys and signatures support conversions to and from &[u8]
. The following code example
demonstrates the necessary steps for SigningKey:
use picnic_bindings::{PicnicL1FSSigningKey};
use std::convert::TryFrom;
let (signing_key, verification_key) = PicnicL1FSSigningKey::random().expect("Key generation failed");
let signing_key_2 = PicnicL1FSSigningKey::try_from(signing_key.as_ref()).expect("Deserialization failed");
assert_eq!(signing_key, signing_key_2);
Alternatively:
use picnic_bindings::{DynamicSigningKey, PicnicL1FS, Parameters, Signer, Verifier};
let (signing_key, verification_key) = DynamicSigningKey::random(PicnicL1FS::PARAM).expect("Key generation failed");
let msg = "some message".as_bytes();
let signature = signing_key.sign(msg);
verification_key.verify(msg, &signature).expect("Verification failed");
In case a signature as only available as &[u8]
and taking ownership is not desired, the
RawVerifier trait offers a method to verify the signature without first converting it into an
instance of DynamicSignature.
use picnic_bindings::{PicnicL1FSSigningKey, Signer, RawVerifier};
let (signing_key, verification_key) = PicnicL1FSSigningKey::random().expect("Key generation failed");
let msg = "some message".as_bytes();
let signature = signing_key.sign(msg);
// assume that this is the actual signature
let signature = signature.as_ref();
verification_key.verify_raw(msg, signature).expect("Verification failed");
Re-exports
pub use signature;
Structs
Vec
Traits
&[u8]
Self
(e.g. a cryptographic key
or connection to an HSM), returning a digital signature.Self
(e.g. a public key)