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

Signature stored in a Vec
Verification key
Signature errors.
Picnic3L1 parameters
Picnic3L3 parameters
Picnic3L5 parameters
PicnicL1FS parameters
PicnicL1Full parameters
PicnicL1UR parameters
PicnicL3FS parameters
PicnicL3Full parameters
PicnicL3UR parameters
PicnicL5FS parameters
PicnicL5Full parameters
PicnicL5UR parameters
Signing key generic over the parameters
Verification key generic over the parameters

Traits

Trait to describe Picnic parameters
Trait that allows to directly verify a signature from a &[u8]
Sign the provided message bytestring using Self (e.g. a cryptographic key or connection to an HSM), returning a digital signature.
Verify the provided message bytestring using Self (e.g. a public key)

Type Definitions

Signing key for Picnic3L1
Verification key for Picnic3L1
Signing key for Picnic3L3
Verification key for Picnic3L3
Signing key for Picnic3L5
Verification key for Picnic3L5
Signing key for PicnicL1FS
Verification key for PicnicL1FS
Signing key for PicnicL1Full
Verification key for PicnicL1Full
Signing key for PicnicL1UR
Verification key for PicnicL1UR
Signing key for PicnicL3FS
Verification key for PicnicL3FS
Signing key for PicnicL3Full
Verification key for PicnicL3Full
Signing key for PicnicL3UR
Verification key for PicnicL3UR
Signing key for PicnicL5FS
Verification key for PicnicL5FS
Signing key for PicnicL5Full
Verification key for PicnicL5Full
Signing key for PicnicL5UR
Verification key for PicnicL5UR