MCPcopy Index your code
hub / github.com/docknetwork/crypto

github.com/docknetwork/crypto @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
3,505 symbols 11,960 edges 409 files 986 documented · 28%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

TBD

CI Apache-2 Dependencies

Library providing privacy enhancing cryptographic primitives.

Primitives

  1. Sigma protocols to prove knowledge of discrete log, equality, inequality of discrete logs, knowledge of opening of a generalized Pedersen commitment, etc. 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. Implements a keyed-verification variant of these accumulators as well which does not require pairings.
  4. Composite proof system that combines above primitives for use cases like
  5. prove knowledge of a BBS+ signature and the corresponding messages
  6. prove knowledge of a modified PS signature and the corresponding messages
  7. equality of signed messages (from same or different signatures) in zero knowledge
  8. inequality of signed messages with public or committed values in zero knowledge
  9. the (non)membership of a certain signed message(s)in the accumulator
  10. numeric bounds (min, max) on the messages can be proved in zero-knowledge
  11. verifiable encryption of signed messages under BBS+ or PS.
  12. zk-SNARK created from R1CS and WASM generated by Circom with witnesses as BBS+ signed messages (not exclusively though).
  13. Verifiable encryption using SAVER.
  14. Compression and amortization of Sigma protocols. This is PoC implementation.
  15. Secret sharing schemes and DKG. Implements several verifiable secret sharing schemes and DKG from Gennaro and FROST. Also implements protocol to do a distributed DLOG check.
  16. Cocount and PS signatures. Based on the paper Security Analysis of Coconut, an Attribute-Based Credential Scheme with Threshold Issuance
  17. LegoGroth16. LegoGroth16, the LegoSNARK variant of Groth16 zkSNARK proof system
  18. Oblivious Transfer (OT) and Oblivious Transfer Extensions (OTE).
  19. 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.
  20. Keyed-Verification Anonymous Credentials (KVAC). Implements Keyed-Verification Anonymous Credentials (KVAC) schemes.
  21. SyRA. Implements sybil resilient signatures to be used for generating pseudonyms for low-entropy credential attributes.
  22. Verifiable encryption using the paper Verifiable Encryption from MPC-in-the-Head.
  23. Utilities like inner product, hadamard product, polynomial utilities, solving discrete log, Elgamal encryption, etc.

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. The Typescript wrapper also contains abstractions for anonymous credentials like schemas, credentials, presentations, etc.

Extension points exported contracts — how you extend this code

DerivedParams (Interface)
Allows creating a new derived parameter from reference to original parameter [6 implementers]
proof_system/src/derived_params.rs
SchnorrChallengeContributor (Interface)
Trait implemented by Schnorr-based protocols for returning their contribution to the overall challenge. i.e. overall cha [12 …
schnorr_pok/src/pok_generalized_pedersen.rs
MultiMessageSignatureParams (Interface)
Trait implemented by a signature scheme params that can sign multiple messages [4 implementers]
utils/src/signature.rs
Accumulator (Interface)
Trait to hold common functionality among both positive and universal accumulator Methods changing or reading accumulator [3 …
vb_accumulator/src/positive.rs
BatchCiphertext (Interface)
A trait implemented by schemes encrypting a batch of messages [2 implementers]
verifiable_encryption/src/tz_21/encryption.rs
R1CStoQAP (Interface)
Computes instance and witness reductions from R1CS to Quadratic Arithmetic Programs (QAPs). [1 implementers]
legogroth16/src/r1cs_to_qap.rs
LinearForm (Interface)
For a linear form, i.e. for a form `L` and a vector `x` of size `n`, `L(x) = a_0*x_0 + a_1*x_1 + ... + a_n*x_n` for cons [1 …
compressed_sigma/src/transforms.rs
SecretShare (Interface)
(no doc) [2 implementers]
secret_sharing_and_dkg/src/common.rs

Core symbols most depended-on inside this repo

clone
called by 2679
utils/src/pairs.rs
rand
called by 1268
utils/src/misc.rs
map
called by 1198
coconut/src/setup/keygen/common.rs
add
called by 557
proof_system/src/witness.rs
len
called by 471
utils/src/pairs.rs
iter
called by 464
utils/src/pairs.rs
into_iter
called by 437
utils/src/pairs.rs
append
called by 260
utils/src/transcript.rs

Shape

Method 1,862
Function 920
Class 650
Enum 50
Interface 23

Languages

Rust100%
C1%

Modules by API surface

legogroth16/src/circom/tests.rs56 symbols
bulletproofs_plus_plus/src/range_proof.rs49 symbols
vb_accumulator/src/proofs.rs46 symbols
vb_accumulator/src/positive.rs40 symbols
vb_accumulator/src/universal.rs37 symbols
saver/src/encryption.rs36 symbols
vb_accumulator/src/kb_universal_accumulator/accumulator.rs35 symbols
vb_accumulator/src/witness.rs34 symbols
vb_accumulator/src/proofs_keyed_verification.rs32 symbols
delegatable_credentials/src/set_commitment.rs31 symbols
secret_sharing_and_dkg/src/common.rs30 symbols
oblivious_transfer/src/ot_extensions/alsz_ote.rs30 symbols

For agents

$ claude mcp add crypto \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact