Commit Graph

170 Commits

Author SHA1 Message Date
Srinath Setty
e76e6bc0f8 Reorganize various Spartan SNARKs and make the direct interface more generic (#195)
* reorganize different variants of spartan and make direct snark more generic

* cargo fmt
2023-07-06 19:51:00 -07:00
Srinath Setty
4087cab1a5 update README.md and version (#194)
* update README.md and version

* move multiexp code to provider/mod.rs

* update README.md

* small edits

* small edits
2023-07-06 13:58:55 -07:00
JunheeLee
ba06404736 Fix comment typo (#192) 2023-07-06 10:33:38 -07:00
François Garillot
0664244482 refactor: Refactor Keccak256Transcript and update tests (#191)
* refactor: change the order of Keccak Squeeze's input

- Redefine the input sequence for the `compute_updated_state` within the `squeeze` method in `Keccak256Transcript`.
- Modify the expected hash outcomes in the `test_keccak_transcript_with` function in `keccak.rs`.

* refactor: Refactor Keccak256Transcript

- Replaced the transcript vector with a `Keccak256` instance, improving data handling and memory usage.
- Refactored `compute_updated_state` to work directly on a given `Keccak256` instance, reducing unnecessary object creation.
- this change roughly amounts to putting the transcript at the start of squeeze's input array

* refactor: simplify hasher_lo, hasher_hi

* test: Enhance Keccak transcript with backward compatibility test

- Introduces new helper functions to assist with the backward-compatibility intesting process (`compute_updated_state_for_testing`, `squeeze_for_testing`)
- Adds a new test `test_keccak_transcript_incremental_vs_explicit` that checks for consistency between incremental and independent explicit transcript computations
2023-07-06 10:32:44 -07:00
François Garillot
4b077bcab1 Add Grumpkin cycle implementation (#181)
* bn256+grumpkin from halo2curves

* chore: Integrate halo2curves more extensively

- Extend existing tests with additional test cases using the new curve types

* fix: Assign correct orders to bn256 and grumpkin scalar fields

- Swap scalar orders between grumpkin and bn256 in `impl_traits!` implementation

* test: Finish improving test integration with halo2curves

- Enhances test coverage for `pasta_curves` and `halo2curves`
- Cleans up commented code in `test_ivc_nontrivial` and `test_ivc_nontrivial_with_compression` tests
- Updates relevant test cases in `src/lib.rs` to include new curve tests

* chore: Remove commented-out/uneeded code in bn254_grumpkin.rs

* test: reproduce test_from_label for bn254_grumpkin

- Implement the `from_label_serial` function in bn254_grumpkin provider
- Add a test to compare parallel and serial implementations of `from_label` function

* refactor: Clean up to_coordinate & summarize changes

* refactor: rename bn254_grumpkin -> bn256_grumpkin

* test: Expand testing for public params digest using bn256 and grumpkin

* chore: Update halo2curves dependency in Cargo.toml

- Updated the `halo2curves` dependency in `Cargo.toml` to the latest version `0.1.0` from a specific git branch.

* refactor: Refactor multi-exponentiation methods across providers

- Updated bn256_grumpkin.rs to use the cpu_best_multiexp function from pasta provider instead of its native function.
- Modified visibility of cpu_best_multiexp function in pasta.rs from private to crate level.

* chore: set up dependencies to import the correct getrandom feature on Wasm

---------

Co-authored-by: Leo Alt <leo@ethereum.org>
2023-07-05 16:10:05 -07:00
François Garillot
905ec2d5a1 Add a Sha256 bench (#188)
* add sha256 bench

* feat: Refactor sha256 benchmark and update dependencies

- Refactored the `sha256.rs` benchmarking file by replacing the former `hex_literal::hex` usage with a newly created `decode_hex` function.
- Updated the "Test vectors" section to work with the new `decode_hex` function to compute digests in `Sha256Circuit` instances.
- adapted to new APIs for RecursiveSNARK
- Amended the `Cargo.toml` file to include the `sha2` package dependency, version `0.10.7`.
- added the bench target

* cargo fmt

---------

Co-authored-by: Srinath Setty <srinath@microsoft.com>
2023-06-28 16:18:07 -07:00
Srinath Setty
bfbd786570 remove a padded witness (#187) 2023-06-21 17:05:20 -07:00
François Garillot
1e6bf942e2 [refactorings] Leftovers (pot-pourri?) (#184)
* test: compute_path

* refactor: path computation

- Improve path concatenation by utilizing built-in `join` method

* refactor: replace `PartialEq` with derived instance

- Derive `PartialEq` for `SatisfyingAssignment` struct
- Remove redundant manual implementation of `PartialEq`

Cargo-expand generates:
```
        #[automatically_derived]
        impl<G: ::core::cmp::PartialEq + Group> ::core::cmp::PartialEq
        for SatisfyingAssignment<G>
        where
            G::Scalar: PrimeField,
            G::Scalar: ::core::cmp::PartialEq,
            G::Scalar: ::core::cmp::PartialEq,
            G::Scalar: ::core::cmp::PartialEq,
            G::Scalar: ::core::cmp::PartialEq,
            G::Scalar: ::core::cmp::PartialEq,
        {
            #[inline]
            fn eq(&self, other: &SatisfyingAssignment<G>) -> bool {
                self.a_aux_density == other.a_aux_density
                    && self.b_input_density == other.b_input_density
                    && self.b_aux_density == other.b_aux_density && self.a == other.a
                    && self.b == other.b && self.c == other.c
                    && self.input_assignment == other.input_assignment
                    && self.aux_assignment == other.aux_assignment
            }
        }
```

* refactor: avoid default for PhantomData Unit type

* refactor: replace fold with sum where applicable

- Simplify code by replacing `fold` with `sum` in various instances

* refactor: decompression method in sumcheck.rs

* refactor: test functions to use slice instead of vector conversion

* refactor: use more references in functions

- Update parameter types to use references instead of owned values in various functions that do not need them
- Replace cloning instances with references
2023-06-19 16:11:42 -07:00
François Garillot
ff0370f506 Add the ability to profile the benchmarks w/ a flamegraph feature (#183)
* feat: Integrate flamegraph profiling in benchmarks

- Introduce "flamegraph" feature flag for optional profiling integration
- Add benchmark profiling support in `compressed_snark` and `recursive_snark` groups
- Update Cargo.toml with `pprof` and `cfg-if` dependencies

* ci: Build benches to make sure they don't bit-rot

- Integrate bench build step into GitHub Actions workflow
2023-06-19 15:52:39 -07:00
Chiro Hiro
af886d6ce7 Improve performance of recursive (#163)
* Improve performance of recursive

* Fix the test after rebase

* Fix CI/CD warnings

* Update benchmark to work with new interface of RecursiveSNARK

* Fix example to make sure step 1 is correct

* refactor: Removes unneeded pass-by value in verification

- Update function arguments to use borrowing instead of passing ownership

* Resolve the conflict with upstream branch

* refactor: Avoid extra input cloning in RecursiveSNARK::new

* Update criterion to 0.5.1 to prevent the panic with its plot

* Fix benchmark issue with new recursive_snark instance

* Fix CI/CD warning with

* refactor: Make mutation easier to observe

- Utilize mutable references to Points for better memory management

* chore: Downgrade clippy dependency for compatibility

---------

Co-authored-by: François Garillot <francois@garillot.net>
2023-06-19 12:52:57 -07:00
François Garillot
031738de51 Remove Zlib compression in public parameter computation (#182)
* test: add test for pp computation

* bench: add a digest computation bench

* refactor: Optimize digest computation and update tests

- Remove flate2 dependency from codebase
- Replace ZlibEncoder with bincode::serialize in compute_digest function
- Update test_pp_digest expected results to align with compute_digest changes

Bench results:
```
compute_digest          time:   [1.4451 s 1.4571 s 1.4689 s]
                        change: [-29.357% -27.854% -26.573%] (p = 0.00 < 0.05)
                        Performance has improved.
```
2023-06-12 16:46:02 -07:00
François Garillot
bef42262d6 [test, chore]: Fix clippy and genericize one more test (#180)
* genericize test_tiny_r1cs

* chore: remove redundant clone in scalar_mul

Makes clippy happy
2023-06-09 09:53:23 -07:00
Michele Orrù
7193483628 Update README.md with release flag (#173) 2023-05-26 13:48:15 -07:00
François Garillot
261fd19057 chore: Update neptune dependency (#172)
- Update neptune dependency to version 10.0.0
2023-05-26 13:43:56 -07:00
François Garillot
54f758eef3 [test-only] More genericity in tests (#171)
* refactor: make circuit tests generic wrt curves

- Improve modularity by introducing generic `test_recursive_circuit_with` function in `src/circuit.rs`
- Refactor `test_recursive_circuit` to utilize the new function
- Implement type constraints for `test_recursive_circuit_with` function

* refactor: make bellperson tests generic in type of group

- Introduce `test_alloc_bit_with` function utilizing generic types
- Adapt existing `test_alloc_bit` function to use the new `test_alloc_bit_with` function with correct types

* refactor: make the nifs test generic in the type of group

* refactor: make the ivc tests generic in the type of curve

* refactor: simplify generics in tests

* make the keccak tests generic

* make the poseidon tests generic

* make the spartan tests generic
2023-05-26 13:43:35 -07:00
Srinath Setty
58fc746c0b release candidate (#169) 2023-05-18 11:19:15 -07:00
Srinath Setty
afd7403336 Fix cross-curve check and then eliminate an unnecessary instance on the primary curve (#167)
* add a cross-curve consistency check

* eliminate the unused instance in RecursiveSNARK
2023-05-18 10:45:08 -07:00
Srinath Setty
b28aaf70a8 hash of public parameters in the transcript (#168) 2023-05-18 10:19:44 -07:00
Leo
f16fa1e401 make ecc tests generic (#165) 2023-05-10 13:52:05 -07:00
Samuel Burnham
cddd707fad chore: update to ff/group 0.13 (#166)
* chore: update to ff/group 0.13 and associated dependencies

Updates:
- zkcrypto/ff, zkcrypto/group to 0.13,
- bellperson to 0.25,
- pasta_curves to 0.5.1, and removes the fil_pasta_curves fork
- pasta-msm should no longer need a fork (WIP)

Adapts source in function, mostly for const usage and API updates.

* expose the portable feature of pasta-MSM

* update pointer to pasta-msm

* Clippy

---------

Co-authored-by: François Garillot <francois@garillot.net>
2023-05-10 12:15:17 -07:00
Srinath Setty
b76d7aa7ea batch sum-checks (#161) 2023-04-10 11:31:04 -07:00
Srinath Setty
21d4092b86 serde for types (#160) 2023-04-03 18:54:00 -07:00
Srinath Setty
83f2e079a8 support proving step circuits with final snark (#159) 2023-04-03 18:33:38 -07:00
Srinath Setty
3b3ae70db3 A more optimal preprocessing SNARK (#158)
* a more optimal preprocessing SNARK

* update version

* cleanup; address clippy
2023-03-31 18:54:32 -07:00
Srinath Setty
4aab459050 Batch polynomial evaluations (#154)
* Ability to collect evaluation claims

* defer polynomial evaluation claims

* address cargo clippy
2023-03-27 17:59:52 -07:00
Srinath Setty
7b1bb44e45 spark-based commitments to R1CS matrices (#152)
* spark-based commitments to R1CS matrices

* small fixes
2023-03-20 18:16:06 -07:00
Srinath Setty
eb97499907 Fix padding logic (#151)
* fix padding

* update version
2023-03-13 10:45:35 -07:00
Srinath Setty
cbbc1c6127 Generalize TranscriptRepr implementation for slices (#150)
* generalize the slice implementation

* bump the version
2023-03-10 09:27:48 -08:00
Srinath Setty
0e86f9acc3 simplify commitmentengine (#149) 2023-03-09 14:33:33 -08:00
JunheeLee
6ba204401f minor typo fix (#147)
* typo fix

* Comment typos fix

* Update README.md

* Comment typo fix
2023-03-09 14:08:50 -08:00
Srinath Setty
03710dbb97 Simplify TranscriptEngine usage (#148)
* simplify transcript engine usage

* update version
2023-03-09 13:31:23 -08:00
Srinath Setty
1e4995274b Separate prover and verifier keys in CompressedSNARK (#145)
* checkpoint

* simplify further

* checkpoint

* gens --> ck

* update benches

* address clippy

* cleanup

* update version
2023-03-02 18:36:13 -08:00
Srinath Setty
01ae6446a9 pass only one multilinear polynomial to EE (#144)
* pass only one multilinear polynomial to EE

* update version
2023-03-01 16:31:00 -08:00
Srinath Setty
d53b3e0fc1 simplify trait requirements (#143)
* simplify trait requirements

* update version
2023-02-28 18:21:25 -08:00
Nalin
621fda5c9e Feature to enable Neptune GPU Poseidon (#141)
* enable neptune gpu hashing

* Disable clippy on GPU
2023-02-22 10:12:13 -08:00
Srinath Setty
b5874df449 Small optimizations (#142) 2023-02-13 11:04:35 -08:00
Srinath Setty
c4b07f0925 allow the provider to provide byte representation of a scalar (#140) 2023-02-10 12:36:51 -08:00
Srinath Setty
8faffd38ea Make code generic over a TranscriptEngine (#139) 2023-02-09 18:33:48 -08:00
Srinath Setty
b97786d291 move IPA-specific methods to the provider (#138) 2023-02-06 18:07:14 -08:00
Srinath Setty
0315bd1198 fix wasm build (#137) 2023-02-03 13:34:01 -08:00
Srinath Setty
603c1e2a85 traits for a vector commitment engine and a polynomial evaluation engine (#136)
make spartan generic over the evaluation engine

update version

disable Wasm CI check
2023-02-02 16:21:24 -08:00
Srinath Setty
e7f8d11455 use thiserror (#135) 2023-01-31 18:31:34 -08:00
Srinath Setty
0ae8d15953 add Wasm build to CI (#134) 2023-01-31 16:44:58 -08:00
Srinath Setty
4163665f52 release candidate (#133) 2023-01-31 16:28:11 -08:00
Samuel Burnham
b2adab610a Clippy formatting (#131)
* Clippy with Rust 1.67

* Clippy/Rustfmt with Rust 1.66.1
2023-01-31 14:53:15 -08:00
Srinath Setty
74501936c3 parallel and batch_normalize (#129)
use a macro to remove redundant code

add a test case
2023-01-31 11:03:38 -08:00
Srinath Setty
746af53e08 use serde feature to compute the digest of the shape (#132) 2023-01-31 10:32:49 -08:00
Samuel Burnham
13964b6f16 Add serde proof serialization (#123)
* Bump commit.

* Bump commit.

* (WIP) Add serde support

* Minor fixes

* Use neptune const generics

* Use git patches

* Impl serde for CompressedSNARK

* Update dependencies, revert to typenum

* Formatting

* Update bellperson-nonnative patch

* Cleanup

* Remove bellperson-nonnative fork

* Switch back to fil_pasta_curves

* Update forked dependencies

* Cleanup

* Remove unnecessary patch

* Update to lurk-pasta-msm

---------

Co-authored-by: porcuquine <porcuquine@users.noreply.github.com>
2023-01-31 10:01:08 -08:00
Srinath Setty
0b2b984fd1 release version (#130) 2023-01-30 12:36:11 -08:00
Samuel Burnham
55f6736866 Add Wasm support (#125)
* Add Wasm support

* Use SeedableRng for Wasm randomness

* Fix tests

* Formatting
2023-01-30 11:31:36 -08:00