PLONK Build Status codecov GitHub issues GitHub

This is a pure Rust implementation of the PLONK proving system over BLS12-381

This code is highly experimental, use at your own risk.

This library contains a modularised implementation of KZG10 as the default polynomial commitment scheme.

Example

The following example shows how to setup the SRS and verify whether a value is a boolean ```rust

// Common View - This is information that the prover and verifier will share // This step is usually performed with a ceremony or MPC let publicparameters = SRS::setup(999, &mut rand::threadrng());

// Provers View let (proof, publicinputs) = { let mut composer: StandardComposer = adddummy_composer(7);

// Add Statement you want to prove
let var_one = composer.add_input(Scalar::from(1));
let var_four = composer.add_input(Scalar::from(4));
composer.bool_gate(var_one);
composer.bool_gate(var_four); // Verification will fail due to this being four

// Trim the SRS to the size of the circuit
// The main reason this may fail, is if the circuit size is larger than max_degree poly you can commit to.
let (ck, _) = public_parameters.trim(composer.circuit_size().next_power_of_two()).unwrap();

// Create a new Evaluation Domain
let domain = EvaluationDomain::new(composer.circuit_size()).unwrap();

// Initialise Transcript
let mut transcript = Transcript::new(b"");

// Preprocess circuit
let preprocessed_circuit = composer.preprocess(&ck, &mut transcript, &domain);

// Return Proof along with any public inputs
// In a real program, the Prover and verifier will know the public inputs
(
    composer.prove(&ck, &preprocessed_circuit, &mut transcript),
    composer.public_inputs,
);

};

// Verifiers View // let ok = { // Verifier processes the same statement, but with random input values let mut composer: StandardComposer = adddummycomposer(7); let vara = composer.addinput(Scalar::from(Scalar::zero())); let varb = composer.addinput(Scalar::from(Scalar::zero())); composer.boolgate(varb); composer.boolgate(vara);

// Trim the SRS
let (ck, vk) = public_parameters.trim(composer.circuit_size().next_power_of_two()).unwrap();

// Create a new Evaluation Domain
let domain = EvaluationDomain::new(composer.circuit_size()).unwrap();

// Initialise transcript
let mut transcript = Transcript::new(b"");

// Preprocess circuit
let preprocessed_circuit = composer.preprocess(&ck, &mut transcript, &domain);

// Verify proof
proof.verify(&preprocessed_circuit, &mut transcript, &vk, &public_inputs)

}; assert_eq!(ok, true); ```

Documentation

WIP

Performance

WIP

Acknowledgements

About

Implementation designed by the dusk team