MCPcopy Index your code
hub / github.com/asn-d6/curdleproofs

github.com/asn-d6/curdleproofs @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
123 symbols 351 edges 16 files 22 documented · 18% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Curdleproofs

Curdleproofs is a zero-knowledge shuffle argument inspired by BG12.

Zero-knowledge shuffle arguments can have multiple use cases: - Secret leader election protocols - Message shuffling in mixnets - Universally verifiable electronic voting protocols

Documentation

The user-facing documentation for this library can be found here.

In this library, we provide high-level protocol documentation for the core [curdleproofs] shuffle argument and its sub-arguments:

  • [same_scalar_argument]
  • [same_permutation_argument]
  • [grand_product_argument]
  • [inner_product_argument]
  • [same_multiscalar_argument]

There are also notes on the optimizations deployed to speed up the verifier.

For all the details and the security proofs, please see the Curdleproofs paper.

Performance

The following table gives the proof size as well as timings for proving and verifying Curdleproofs on an Intel i7-8550U CPU @ 1.80GHz over the BLS12-381 curve:

Shuffled Elements Proving (ms) Verification (ms) Shuffling (ms): Proof Size (bytes)
60 177 22 28 3968
124 304 27 57 4448
252 560 35 121 4928

(The number of shuffled elements above is disturbingly close to a power of two but not quite, because we reserve four elements for zero-knowledge blinders.)

Example

The following example shows how to create and verify a shuffle proof that shuffles 28 elements:

# // The #-commented lines are hidden in Rustdoc but not in raw
# // markdown rendering, and contain boilerplate code so that the
# // code in the README.md is actually run as part of the test suite.
#
# use ark_std::rand::prelude::SliceRandom;
# use ark_std::UniformRand;
# use ark_bls12_381::Fr;
# use ark_bls12_381::G1Affine;
# use ark_bls12_381::G1Projective;
# use ark_std::rand::{rngs::StdRng, SeedableRng};
# use ark_ec::CurveGroup;
# use core::iter;
#
# use curdleproofs::N_BLINDERS;
# use curdleproofs::curdleproofs::{CurdleproofsProof, generate_crs};
# use curdleproofs::util::shuffle_permute_and_commit_input;
#
# fn main() {
let mut rng = StdRng::seed_from_u64(0u64);

// Number of elements we are shuffling
let ell = 28;

// Construct the CRS
let crs = generate_crs(ell);

// Generate some witnesses: the permutation and the randomizer
let mut permutation: Vec<u32> = (0..ell as u32).collect();
permutation.shuffle(&mut rng);
let k = Fr::rand(&mut rng);

// Generate some shuffle input vectors
let vec_R: Vec<G1Affine> = iter::repeat_with(|| G1Projective::rand(&mut rng).into_affine())
    .take(ell)
    .collect();
let vec_S: Vec<G1Affine> = iter::repeat_with(|| G1Projective::rand(&mut rng).into_affine())
    .take(ell)
    .collect();

// Shuffle and permute inputs to generate output vectors and permutation commitments
let (vec_T, vec_U, M, vec_m_blinders) =
    shuffle_permute_and_commit_input(&crs, &vec_R, &vec_S, &permutation, &k, &mut rng);

// Generate a shuffle proof
let shuffle_proof = CurdleproofsProof::new(
    &crs,
    vec_R.clone(),
    vec_S.clone(),
    vec_T.clone(),
    vec_U.clone(),
    M,
    permutation,
    k,
    vec_m_blinders,
    &mut rng,
);

// Verify the shuffle proof
assert!(shuffle_proof
        .verify(&crs, &vec_R, &vec_S, &vec_T, &vec_U, &M, &mut rng)
        .is_ok());
# }

Building & Running

This library can be compiled with cargo build and requires rust nightly.

You can run the tests using cargo test --release and the benchmarks using cargo bench.

Extension points exported contracts — how you extend this code

CurdleproofsTranscript (Interface)
A Transcript with some methods for feeding it and for obtaining challenges as field elements [1 implementers]
src/transcript.rs

Core symbols most depended-on inside this repo

mul
called by 52
src/commitments.rs
msm
called by 43
src/util.rs
append_list
called by 24
src/transcript.rs
get_and_append_challenge
called by 23
src/transcript.rs
append
called by 14
src/transcript.rs
generate_blinders
called by 13
src/util.rs
accumulate_check
called by 10
src/msm_accumulator.rs
msm_from_projective
called by 10
src/util.rs

Shape

Function 61
Method 44
Class 16
Enum 1
Interface 1

Languages

Rust100%

Modules by API surface

src/whisk.rs37 symbols
src/crs.rs12 symbols
src/util.rs10 symbols
src/inner_product_argument.rs9 symbols
src/curdleproofs.rs8 symbols
src/same_multiscalar_argument.rs7 symbols
tests/crs.rs6 symbols
src/same_permutation_argument.rs6 symbols
src/grand_product_argument.rs6 symbols
src/transcript.rs5 symbols
src/msm_accumulator.rs5 symbols
src/commitments.rs5 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

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

⬇ download graph artifact