Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Ginger-Lib #144

Closed
wants to merge 88 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
5924fde
Refined test circuit for Final Darlin
DanieleDiBenedetto Sep 3, 2021
623740d
Added new benches
DanieleDiBenedetto Sep 3, 2021
d3225fa
Added proof and vk size prints + other logs
DanieleDiBenedetto Sep 3, 2021
17b2fad
Added new bench
DanieleDiBenedetto Sep 4, 2021
2296540
added shell script
UlrichHaboeck75 Sep 5, 2021
7d0c102
added todo for FinalDarlin test circuit
UlrichHaboeck75 Sep 7, 2021
1e93d2f
Adjusted to the refactored PC
phoinic Sep 12, 2021
b911473
Fix marlin branch name
phoinic Sep 12, 2021
d56bd60
Degree bound removed from tests
phoinic Sep 12, 2021
6e33192
Upated to the poly-commit refactoring phase 2
phoinic Sep 26, 2021
f130a13
Additional ops for polynomials of PC refactoring
phoinic Oct 25, 2021
5a71322
Added enforce comparison gadget imported from arkworks with Unit Test
doc78 Oct 28, 2021
adba37d
Merged with development
doc78 Oct 28, 2021
648eaa5
Merge remote-tracking branch 'origin/development' into rc/feat/comp_g…
doc78 Oct 28, 2021
47a3d5a
Enabled local path dependencie to algebra and r1cs-core
doc78 Nov 1, 2021
3c522fe
Added CondSelect Gadget for UInt64
doc78 Nov 4, 2021
e10c4a5
Added conditionally_add in FpGadget and UInt64
doc78 Nov 13, 2021
06e8778
Adjusted to pc refactored optimizations
phoinic Nov 14, 2021
252db67
Darlin benchmark restored
phoinic Nov 14, 2021
ba66f12
print-trace for poly-commit removed
phoinic Nov 14, 2021
d927216
Cleaning unused curves
phoinic Nov 14, 2021
a558c29
Reformat code
phoinic Nov 16, 2021
fbce641
Reformat code (2)
phoinic Nov 16, 2021
61fea62
Merged with development
phoinic Nov 18, 2021
1bfed13
enforce_in_field rewritten using new enforce_smaller_or_equal_than_le
doc78 Nov 22, 2021
ca0bd35
Algebra refactored
phoinic Nov 25, 2021
d99c83a
Group trait for polynomial
phoinic Nov 25, 2021
12a32ab
Unused fields models removed and field became a group
phoinic Nov 27, 2021
0aa9131
Fixed field binding
phoinic Nov 27, 2021
8f1858c
Vector of group items
phoinic Nov 28, 2021
773c114
Native vec operations for GroupVec
phoinic Nov 28, 2021
7b99cbd
to_field_vec returned
phoinic Nov 29, 2021
b7f4342
Updates for marlin
phoinic Nov 30, 2021
0f993e5
r1cs and marlin related bugfixes
phoinic Dec 1, 2021
a842e30
Submodules adjusted to refactored state
phoinic Dec 1, 2021
bc7c216
Cargo local settings commented
phoinic Dec 1, 2021
d890be2
Committer key optimization
phoinic Dec 3, 2021
7ef8626
From/To compressed bits for Jacobian
phoinic Dec 3, 2021
b04df86
ToBytes for curves bugfix
phoinic Dec 7, 2021
1c2f932
ToBytes cannonical
phoinic Dec 7, 2021
18cf717
Fix schnorr normalization
phoinic Dec 8, 2021
c65877f
Merge branch 'refactor_ginger_dev' into refactor_ginger_dev_optimizat…
phoinic Dec 8, 2021
298b225
AffineRep serializations
phoinic Dec 8, 2021
430a771
Broken UTs ignored
phoinic Dec 8, 2021
4b571f5
Secp256k1 tests uncommented and marked as ignored
phoinic Dec 9, 2021
be9e813
Merge branch 'refactor_constraint_system' into refactor_ginger_dev_1
phoinic Dec 14, 2021
3a483a9
optimized enforce_smaller_than_or_equal_le(), added negative test
UlrichHaboeck75 Dec 14, 2021
105c22c
modified enforce_smaller_or_equal() to use the k-ary and over runs of…
UlrichHaboeck75 Dec 15, 2021
f997390
simplified `conditionally_select()` for `UInt64`
UlrichHaboeck75 Dec 16, 2021
ee41f74
patched security issue in `is_smaller_than_unchecked()`
UlrichHaboeck75 Dec 16, 2021
2d9cff2
Commented develop patch. Fixed dependencies
doc78 Dec 17, 2021
ee095a0
Added check with non-constant variable compare in UT
doc78 Dec 17, 2021
49c4a8d
Updated dependencies and other fixes
DanieleDiBenedetto Dec 20, 2021
73664a3
Updated dependencies
DanieleDiBenedetto Dec 20, 2021
c46cc86
Merge with development branch
doc78 Dec 20, 2021
12e4767
Merge with current branch
doc78 Dec 20, 2021
dcbb863
Removed duplicated function
doc78 Dec 20, 2021
5147c08
Merge branch 'development' into rc/feat/comp_gadget
DanieleDiBenedetto Dec 20, 2021
b9d4a5f
Revert "modified enforce_smaller_or_equal() to use the k-ary and over…
DanieleDiBenedetto Dec 21, 2021
46b366c
Revert "optimized enforce_smaller_than_or_equal_le(), added negative …
DanieleDiBenedetto Dec 21, 2021
9f1b0be
Reverted conditionally_select in uint64
doc78 Jan 4, 2022
6e33335
Issues from review after refactoring
phoinic Jan 12, 2022
d117c67
UTs restored
phoinic Jan 19, 2022
2394bc5
Added some utility functions to LinearCombination struct
DanieleDiBenedetto Mar 1, 2022
3ee86e2
Refactored LinearCombination. Removed unneeded Group implementations …
DanieleDiBenedetto Mar 2, 2022
7c4edf5
Moved linear_combination.rs outside group submodule
DanieleDiBenedetto Mar 2, 2022
c4011d6
Fixes to algebra
DanieleDiBenedetto Mar 14, 2022
e2d3a3f
Restored doc in the curve module
DanieleDiBenedetto Mar 14, 2022
1129b55
Other fixes + removed pedersen hash and commitment
DanieleDiBenedetto Mar 14, 2022
98f78e1
Refactored exponentiation functions in GroupGadget trait
DanieleDiBenedetto Mar 15, 2022
df0d5e2
Removed any non poseidon-based merkle tree code
DanieleDiBenedetto Mar 15, 2022
79491f7
Removed non field based Schnorr signature
DanieleDiBenedetto Mar 15, 2022
f3b4c9d
Merge branch 'development' into refactor_ginger_dev
DanieleDiBenedetto Mar 15, 2022
b254ee9
Fixed curve test
DanieleDiBenedetto Mar 15, 2022
d8f93c0
Fixed proof-systems crate and aligned it with the most recent changes…
DanieleDiBenedetto Mar 17, 2022
dc062b0
Fix CI
DanieleDiBenedetto Mar 17, 2022
f2371b6
Purged existing scripts from removed curves
DanieleDiBenedetto Mar 18, 2022
cad81d0
Specialized random transformation curve test for TE curves
DanieleDiBenedetto Mar 18, 2022
de59738
Removed unneeded lifetime parameters
DanieleDiBenedetto Mar 21, 2022
083f383
Addressed some comments by Ulrich.
Apr 4, 2022
1185770
Comments from code review + added tests for GroupVec and LinearCombin…
DanieleDiBenedetto Apr 4, 2022
d654def
Minor fixes + re-introduced from_random_bytes function and renamed it…
DanieleDiBenedetto Apr 5, 2022
7c84be6
Commented broken test + addressed minor comments
DanieleDiBenedetto Apr 19, 2022
dcc62b6
Fix CI
DanieleDiBenedetto Apr 21, 2022
3554b50
Added a small TODO related to r1cs_core::LinearCombination
DanieleDiBenedetto Apr 21, 2022
db24959
Merge branch 'rc/feat/comp_gadget' into refactor_ginger_dev
DanieleDiBenedetto May 2, 2022
c283cf8
Fix automerge error
DanieleDiBenedetto May 2, 2022
741a7b4
Removed short_weierstrass_projective
DanieleDiBenedetto May 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ script:
jobs:
include:
- name: bionic_rust-1.51.0_latest-CHECK
env: IMAGE_TAG=bionic_rust-1.51.0_latest TESTS='000,001,003,005,006,008,009,011,012,013,014,015,016,020'
- name: bionic_rust-1.51.0_latest-TEST
env: IMAGE_TAG=bionic_rust-1.51.0_latest TESTS='017,018'
- name: bionic_rust-1.51.0_latest-TEST_INTENSIVE
env: IMAGE_TAG=bionic_rust-1.51.0_latest TESTS='000,001,003,005,006,008,009,012,013,014,015,016,020'
- name: bionic_rust-1.51.0_latest-TEST_BACKEND
env: IMAGE_TAG=bionic_rust-1.51.0_latest TESTS='017'
- name: bionic_rust-1.51.0_latest-TEST_BACKEND_NONNATIVE
env: IMAGE_TAG=bionic_rust-1.51.0_latest TESTS='019'
- name: bionic_rust-1.51.0_latest-TEST_DARLIN
env: IMAGE_TAG=bionic_rust-1.51.0_latest TESTS='018'
- name: bionic_rust-nightly-2021-04-25_latest-CHECK
env: IMAGE_TAG=bionic_rust-nightly-2021-04-25_latest TESTS='002,004,007,010' CARGOARGS='+nightly-2021-04-25'
5 changes: 4 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ Pratyush Mishra
Howard Wu
Daniele Di Benedetto
Marcelo Kaihara
Ulrich Haboeck
Ulrich Haboeck
Luca Giussani
Daniele Di Tullio
Nicholas Mainardi
40 changes: 40 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Build guide

The library compiles on the `1.51.0 stable` toolchain of the Rust compiler. To install Rust, first install `rustup` by following the instructions [here](https://rustup.rs/), or via your platform's package manager. Once `rustup` is installed, install the appropriate Rust toolchain by invoking:
```bash
rustup install 1.51.0
```
After that, use `cargo`, the standard Rust build tool, to build the library:
```bash
git clone https://github.com/HorizenOfficial/ginger-lib.git
cd ginger-lib
cargo build --release
```
This library comes with unit tests for each of the provided crates. Run the tests with:
```bash
cargo test --all-features
```
This library comes with several benchmarks.
Some of the benchmarks in [`algebra`](algebra/benches) crate require the nightly Rust toolchain (we suggest to use `nightly-2021-04-25)`; to install this, run `rustup install nightly-2021-04-25`. Then, to run benchmarks, run the following command:
```bash
cargo +nightly-2021-04-25 bench --all-features
```
Other benchmarks using [Criterion]() crate are present in [`algebra`](algebra/benches), [`primitives`](primitives/benches/crypto_primitives) and [`proof-systems`](proof-systems) crates and can be ran with `stable` Rust.

Compiling with `adcxq`, `adoxq` and `mulxq` instructions can lead to a 30-70% speedup. These are available on most `x86_64` platforms (Broadwell onwards for Intel and Ryzen onwards for AMD). Run the following command:
```bash
RUSTFLAGS="-C target-feature=+bmi2,+adx" cargo test/build/bench --features llvm_asm
```
Tip: If optimising for performance, your mileage may vary with passing `--emit=asm` to `RUSTFLAGS`.

To bench `algebra-benches` with greater accuracy, especially for functions with execution times on the order of nanoseconds, use the `n_fold` feature to run selected functions 1000x per iteration. To run with multiple features, make sure to double quote the features.
```bash
cargo +nightly bench --features "n_fold"
```
__Note:__ Some of the dependencies between the crates in GingerLib are specified via Git rather than via local paths: this is due to a cross-dependency issue between GingerLib's crates and some external crates.
One example of such errors is in crate `proof-systems`: it depends both on `algebra` and on external crates located in [marlin](https://github.com/HorizenLabs/marlin) and [poly-commit](https://github.com/HorizenLabs/poly-commit) depending on `algebra` too; if the version of `algebra` on which these crates depend is not exactly the same, a compilation error will occur:
```bash
error[E0308]: mismatched types [...] note: perhaps two different versions of crate `algebra` are being used?
```
By specifying in all the crates the dependency on `algebra` in Git form, we ensure that all the crates will take the same version; however, if during development `algebra` crate is modified, we would be forced to push the changes to Git first before seeing them applied in local. For this reason, in the root `Cargo.toml`, we pushed instructions allowing to override Git dependencies with (local) path dependencies; unfortunately, this will require to store locally all the crates involved in the cross-dependency issue and to comment/uncomment these lines (if needed) before/after pushing changes.
We are considering to restructure the involved repositories to avoid this issue.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Contributing

Contributions are welcomed! Bug fixes and new features can be initiated through GitHub pull requests. To speed the code review process, please adhere to the following guidelines:

* Follow Horizen repositories' *code of conduct*
* Follow Horizen repositories' *styling guide*
* Please gpg sign your commits
* Please make sure you push your pull requests to the development branch
21 changes: 10 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ debug-assertions = true
debug = true

# Uncomment these lines for local development paths
#
#[patch.'https://github.com/HorizenOfficial/ginger-lib']
#algebra = { path = './algebra' }
#r1cs-core = { path = "./r1cs/core" }
#r1cs-std = { path = "./r1cs/gadgets/std" }
#
#[patch.'https://github.com/HorizenLabs/marlin']
#marlin = { path = '../marlin' }
#
#[patch.'https://github.com/HorizenLabs/poly-commit']
#poly-commit = { path = '../poly-commit' }

# [patch.'https://github.com/HorizenOfficial/ginger-lib']
# algebra = { path = './algebra' }
# r1cs-core = { path = "./r1cs/core" }

# [patch.'https://github.com/HorizenLabs/marlin']
# marlin = { path = '../marlin' }

# [patch.'https://github.com/HorizenLabs/poly-commit']
# poly-commit = { path = '../poly-commit' }
Loading