16 breaking releases

0.17.0 Mar 4, 2024
0.16.0 Oct 2, 2023
0.15.0 Sep 7, 2023
0.14.0 Jun 23, 2023
0.3.0 Nov 5, 2021

#320 in Cryptography

Download history 41/week @ 2023-12-22 5/week @ 2023-12-29 19/week @ 2024-01-05 26/week @ 2024-01-12 18/week @ 2024-01-19 10/week @ 2024-01-26 16/week @ 2024-02-02 36/week @ 2024-02-09 43/week @ 2024-02-16 43/week @ 2024-02-23 214/week @ 2024-03-01 89/week @ 2024-03-08 59/week @ 2024-03-15 79/week @ 2024-03-22 91/week @ 2024-03-29 42/week @ 2024-04-05

275 downloads per month
Used in 16 crates

Apache-2.0

105KB
2.5K SLoC

TBD

CI Apache-2 Dependencies

Library providing privacy enhancing cryptographic primitives.

Primitives

  1. Schnorr proof of knowledge protocol to prove knowledge of discrete log and inequality of discrete logs. This is a good reference.
  2. BBS and BBS+ signatures for anonymous credentials. BBS+ is based on the paper Anonymous Attestation Using the Strong Diffie Hellman Assumption Revisited and BBS is based on the paper Revisiting BBS Signatures. Also implements the threshold variants of these based on the paper Threshold BBS+ Signatures for Distributed Anonymous Credential Issuance
  3. Dynamic accumulators, both positive and universal. Based on the papers Dynamic Universal Accumulator with Batch Update over Bilinear Groups and Efficient Constructions of Pairing Based Accumulators
  4. Composite proof system that combines above primitives for use cases like
    • prove knowledge of a BBS+ signature and the corresponding messages
    • prove knowledge of a modified PS signature and the corresponding messages
    • equality of signed messages (from same or different signatures) in zero knowledge
    • the (non)membership of a certain signed message(s)in the accumulator
    • numeric bounds (min, max) on the messages can be proved in zero-knowledge
    • verifiable encryption of signed messages under BBS+.
    • zk-SNARK created from R1CS and WASM generated by Circom with witnesses as BBS+ signed messages (not exclusively though).
  5. Verifiable encryption using SAVER.
  6. Compression and amortization of Sigma protocols. This is PoC implementation.
  7. Secret sharing schemes and DKG. Implements verifiable secret sharing schemes and DKG from Gennaro and FROST.
  8. Cocount and PS signatures. Based on the paper Security Analysis of Coconut, an Attribute-Based Credential Scheme with Threshold Issuance
  9. LegoGroth16. LegoGroth16, the LegoSNARK variant of Groth16 zkSNARK proof system
  10. Oblivious Transfer (OT) and Oblivious Transfer Extensions (OTE).
  11. Short group signatures. BB signature and weak-BB signature and their proofs of knowledge based on the papers Short Signatures Without Random Oracles and Scalable Revocation Scheme for Anonymous Credentials Based on n-times Unlinkable Proofs.

Composite proof system

The proof system that uses above-mentioned primitives.

Build

cargo build or cargo build --release

By default, it uses standard library and rayon for parallelization

To build with standard library but without parallelization, use cargo build --no-default-features --features=std

For no_std support, build as cargo build --no-default-features --features=wasmer-sys

For WASM, build as cargo build --no-default-features --features=wasmer-js --target wasm32-unknown-unknown

Test

cargo test

The above maybe slower as it runs the tests in debug mode and some tests work on large inputs. For running tests faster, run cargo test --release

Benchmarking

Criterion benchmarks here

Some tests also print time consumed by the operations, run cargo test --release -- --nocapture [test name]

WASM wrapper

A WASM wrapper has been created over this repo here. The wrapper is then used to create this Typescript library which is more ergonomic than using the wrapper as the wrapper contains free floating functions.

Dependencies

~7–17MB
~202K SLoC