Giter VIP home page Giter VIP logo

plonky's People

Contributors

bpfarmer avatar dlubarov avatar gilescope avatar mrneither avatar unzvfu avatar wborgeaud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

plonky's Issues

Vectorise modular multiplication

There are several ways to vectorise modular multiplication (see Section 4 of this article for example). In some cases we may be able to write high-level code from which the compiler will generate SSE or AVX instructions; in other cases we may have to write the assembly ourselves.

Generate baseline performance measurements for current field arithmetic implementations

In order to measure performance improvements, and protect against performance regressions (while refactoring, for example, see #68), we should measure the performance of the current field arithmetic implementations in a way that makes it easy to compare to future performance measurements. The (already in use) Criterion crate seems to cover this functionality, at least for micro-benchmarks such as field operations.

Refactor existing modular arithmetic code

There is currently a fair amount of copy-pasta between the different base field implementations (e.g. here, here and here). This should be factored out, so as to more clearly and conveniently accommodate the coming implementations and specialisations.

NB: Need to be careful to maintain the performance advantages that some of those implementations have from inlining and specialisation.

This issue depends on the completion of #76 and #77.

Refactor the underlying representation of the two Tweedle curves

The two Tweedle curves have almost identical implementations. There should be a cleaner way to express that; I'm thinking something like a 'Montgomery256' trait that provides Montgomery representation and arithmetic for moduli up to 256 bits.

This issue follows on from #68.

Fast modular squaring

For sufficiently large numbers, squaring a number can be made up to ~40% faster than simply multiplying it with itself (for example, see here). We should investigate whether we can obtain some performance benefit for numbers of the size used in Plonky.

Note that the existing Montgomery modmul implementation is CIOS (i.e. interleaves multiplication and reduction). To implement fast squaring we first need Montogomery REDC and we lose the (mild) performance benefits of CIOS layout.
We can combine the fast squaring method with modular reduction with the CIOS layout in a fairly straight forward manner. This is mentioned (but not explained) in Acar's thesis, Section 2.3. Another useful reference is this post by the Goff developers (that also includes a cute trick to skip some additions for some moduli).

Improved carry-chain management

Carry chains in field arithmetic are a significant source of data dependency which can cause pipeline stalls and bubbles. In some cases instead of handling carries at their source we can accumulate and defer treatment until later. We should identify places where this is possible. Possibly most applicable in the context of #72.

Benchmarking panics when generating the recursion circuit

Hi! I wanted to try plonky but I am unable to run the benchmarks properly. The "Generating inner proof" part takes forever to finish, and the part "generating the recursion circuit" always panics and fails with the following error (running on Ubuntu18.04 with 8GB RAM, Intel i7-9750H 2.6GHz):

Generating inner circuit
Finished in 156.286423678s

Generating inner witness
Finished in 0.366971488s

Generating inner proof
Finished in 2920.980774765s

Verifying inner proof
Finished in 75.733380387s

Generating recursion circuit...
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 4', /home/workspace/plonky/src/plonk_recursion.rs:460:19

I saw you were mentioning on https://www.plonk.cafe/t/plonky-recursive-proofs-based-on-plonk-and-halo/63 that you were obtaining benchmarks of 10 sec for verifier circuit of size 2^14, how did you get those results? I saw also that the test test_proof_trivial_recursive() in tests/prove_and_verify_recursive.rs was flawky and hence disabled, would that be linked to it? Thanks!

I get errors when I run the tests

I run the test_proof_trivial_recursive() test on the master branch, but get syntactic errors as follows:

cargo test --color=always --no-run --package plonky --test prove_and_verify_recursive test_proof_trivial_recursive -- --exact
Compiling plonky v0.1.0
warning: unused import: std::collections::HashSet
--> src/field/field.rs:3:5
|
3 | use std::collections::HashSet;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

error[E0277]: arrays only have std trait implementations for lengths 0..=32
--> src/bigint/bigint_arithmetic.rs:53:50
|
53 | debug_assert!(!borrow, "a < b: {:?} < {:?}", a, b);
| ^ the trait std::array::LengthAtMost32 is not implemented for [u64; N]
|
= note: required because of the requirements on the impl of std::fmt::Debug for [u64; N]
= note: required by std::fmt::Debug::fmt
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: arrays only have std trait implementations for lengths 0..=32
--> src/bigint/bigint_arithmetic.rs:53:53
|
53 | debug_assert!(!borrow, "a < b: {:?} < {:?}", a, b);
| ^ the trait std::array::LengthAtMost32 is not implemented for [u64; N]
|
= note: required because of the requirements on the impl of std::fmt::Debug for [u64; N]
= note: required by std::fmt::Debug::fmt
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound &mut [{integer}; N]: std::iter::IntoIterator is not satisfied
--> src/bigint/bigint_arithmetic.rs:108:23
|
108 | for limb_i in &mut limbs {
| ^^^^^^^^^^ the trait std::iter::IntoIterator is not implemented for &mut [{integer}; N]
|
= help: the following implementations were found:
<&'a [T; N] as std::iter::IntoIterator>
<&'a [T] as std::iter::IntoIterator>
<&'a mut [T; N] as std::iter::IntoIterator>
<&'a mut [T] as std::iter::IntoIterator>
= note: required by std::iter::IntoIterator::into_iter

error[E0369]: binary operation != cannot be applied to type [u64; N]
--> src/bigint/bigint_inverse.rs:18:13
|
18 | while u != one && v != one {
| - ^^ --- [u64; N]
| |
| [u64; N]

error[E0369]: binary operation != cannot be applied to type [u64; N]
--> src/bigint/bigint_inverse.rs:18:25
|
18 | while u != one && v != one {
| - ^^ --- [u64; N]
| |
| [u64; N]

error[E0369]: binary operation == cannot be applied to type [u64; N]
--> src/bigint/bigint_inverse.rs:50:10
|
50 | if u == one {
| - ^^ --- [u64; N]
| |
| [u64; N]

error: aborting due to 6 previous errors; 1 warning emitted

Some errors have detailed explanations: E0277, E0369.
For more information about an error, try rustc --explain E0277.
error: could not compile plonky.

Faster reduction of 2^b + c moduli

The base field moduli used with elliptic curves are often chosen to be of the form 2^b + c for some small c; this is the case for the Tweedledee/Tweedledum curves, for example. We can exploit this form of modulus to speed up the reduction algorithm.

Non-reduced representation of base field elements

It can be advantageous to leave a few bits of space in the representation of an element of a base field and to allow a certain number of overflows into that space during calculations. This can reduce branching, carry-chain dependencies, and, most importantly, the number of modular reductions in arithmetic operations.

Test suite for finite field arithmetic

Before embarking on refactoring (#68), we need a more thorough test suite for finite field arithmetic. Many of the existing tests only test internal consistency, and that only wrt randomly generated inputs. A more thorough test suite will read in a fixed set of independently generated inputs and outputs (so the tests are repeatable) that have been more deliberately chosen (so we know we hit boundary cases).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.