4 releases (breaking)

Uses new Rust 2021

0.3.0 May 10, 2022
0.2.0 Jan 19, 2022
0.1.0 Nov 19, 2021
0.0.0 Jan 8, 2021

#187 in Cryptography

Download history 2715/week @ 2022-06-11 4080/week @ 2022-06-18 4631/week @ 2022-06-25 3192/week @ 2022-07-02 2293/week @ 2022-07-09 2974/week @ 2022-07-16 2322/week @ 2022-07-23 6558/week @ 2022-07-30 2063/week @ 2022-08-06 1902/week @ 2022-08-13 2764/week @ 2022-08-20 6286/week @ 2022-08-27 3512/week @ 2022-09-03 4343/week @ 2022-09-10 3394/week @ 2022-09-17 2725/week @ 2022-09-24

15,551 downloads per month
Used in 4 crates (via orchard)

MIT/Apache

125KB
2.5K SLoC

A minimal RedDSA implementation for use in Zcash.

Two specializations of RedDSA are used in Zcash: RedJubjub and RedPallas. For each of these, two parameterizations are used, one for BindingSig and one for SpendAuthSig. This library distinguishes these in the type system, using the sealed SigType trait as a type-level enum.

In addition to the Signature, SigningKey, VerificationKey types, the library also provides VerificationKeyBytes, a refinement of a [u8; 32] indicating that bytes represent an encoding of a RedDSA verification key. This allows the VerificationKey type to cache verification checks related to the verification key encoding. For all specializations of RedDSA used in Zcash, encodings of signing and verification keys are 32 bytes.

Examples

Creating a BindingSig, serializing and deserializing it, and verifying the signature:

# use std::convert::TryFrom;
use rand::thread_rng;
use reddsa::*;

let msg = b"Hello!";

// Generate a secret key and sign the message
let sk = SigningKey::<sapling::Binding>::new(thread_rng());
let sig = sk.sign(thread_rng(), msg);

// Types can be converted to raw byte arrays using From/Into
let sig_bytes: [u8; 64] = sig.into();
let pk_bytes: [u8; 32] = VerificationKey::from(&sk).into();

// Deserialize and verify the signature.
let sig: Signature<sapling::Binding> = sig_bytes.into();
assert!(
    VerificationKey::try_from(pk_bytes)
        .and_then(|pk| pk.verify(msg, &sig))
        .is_ok()
);

docs

cargo doc --features "nightly" --open

Dependencies

~2.5MB
~56K SLoC