Skip to content

Commit 860a986

Browse files
z-techweikengchenPratyush
authored
Move curves to algebra #680 (#701)
* chkpt * style check 2 * style check 3 * docs 1 * md lint test * Update CHANGELOG.md * Update CONTRIBUTING.md * Update curves/Cargo.toml to reference algebra directly Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu> * Update curves/README.md to reference top level directories in algebra Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu> * some symlinks * mv contributing to top level and rm ref to curves * test ci for mnt4-753 * typos * test fix broken algebra tests * 30 min timeout * rm double dir prefix * fix broken algebra tests * mnt6-753 and cp6_782 * typo * directories: change ls to find * set-output deprecated * rm lookup only, use find * shellcheck disable * test with dot slash * rm slash to exclude properly --------- Co-authored-by: Weikeng Chen <w.k@berkeley.edu> Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
1 parent d9da220 commit 860a986

File tree

465 files changed

+19803
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

465 files changed

+19803
-19
lines changed

.github/workflows/ci.yml

+219-19
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ jobs:
1313
name: Check Style
1414
runs-on: ubuntu-latest
1515
steps:
16-
1716
- name: Checkout
18-
uses: actions/checkout@v1
17+
uses: actions/checkout@v4
1918
- name: Install Rust
2019
uses: actions-rs/toolchain@v1
2120
with:
@@ -24,19 +23,20 @@ jobs:
2423
override: true
2524
components: rustfmt
2625

27-
- name: cargo fmt --check
28-
uses: actions-rs/cargo@v1
29-
with:
30-
command: fmt
31-
args: --all -- --check
26+
- name: Algebra - format
27+
run: cargo fmt --all -- --check
28+
- name: Curves - format
29+
run: cargo fmt --all -- --check
30+
working-directory: ./curves
31+
3232

3333
docs:
3434
name: Check Documentation
3535
runs-on: ubuntu-latest
3636
steps:
3737

3838
- name: Checkout
39-
uses: actions/checkout@v1
39+
uses: actions/checkout@v4
4040
- name: Install Rust
4141
uses: actions-rs/toolchain@v1
4242
with:
@@ -45,11 +45,63 @@ jobs:
4545
override: true
4646
components: rustfmt
4747

48-
- name: cargo doc --all --no-deps --document-private-items --all-features
49-
uses: actions-rs/cargo@v1
50-
with:
51-
command: doc
52-
args: --all --no-deps --document-private-items --all-features
48+
- name: Algebra - doc
49+
run: cargo doc --all --no-deps --document-private-items --all-features
50+
- name: Curves - doc
51+
run: cargo doc --all --no-deps --document-private-items --all-features
52+
working-directory: ./curves
53+
54+
check:
55+
name: Check
56+
runs-on: ubuntu-latest
57+
env:
58+
RUSTFLAGS: -Dwarnings
59+
strategy:
60+
matrix:
61+
rust:
62+
- stable
63+
- nightly
64+
steps:
65+
- name: Checkout
66+
uses: actions/checkout@v4
67+
68+
- name: Install Rust (${{ matrix.rust }})
69+
uses: actions-rs/toolchain@v1
70+
with:
71+
profile: minimal
72+
toolchain: ${{ matrix.rust }}
73+
override: true
74+
75+
- uses: actions/cache@v3
76+
with:
77+
path: |
78+
~/.cargo/registry
79+
~/.cargo/git
80+
target
81+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
82+
83+
- name: Algebra - Check examples
84+
run: cargo check --examples --all
85+
- name: Curves - Check examples
86+
run: cargo check --examples --all
87+
working-directory: ./curves
88+
89+
90+
- name: Algebra - Check examples with all features on stable
91+
run: cargo check --examples --all-features --all
92+
if: matrix.rust == 'stable'
93+
- name: Curves - Check examples with all features on stable
94+
run: cargo check --examples --all-features --all
95+
working-directory: ./curves
96+
if: matrix.rust == 'stable'
97+
98+
- name: Algebra - Check benchmarks on nightly
99+
run: cargo check --all-features --examples --workspace --benches
100+
if: matrix.rust == 'nightly'
101+
- name: Curves - Check benchmarks on nightly
102+
run: cargo check --all-features --examples --workspace --benches
103+
working-directory: ./curves
104+
if: matrix.rust == 'nightly'
53105

54106
test:
55107
name: Test
@@ -105,9 +157,9 @@ jobs:
105157
with:
106158
command: test
107159
args: "--workspace \
108-
--all-features \
109-
--exclude ark-poly-benches \
110-
--exclude ark-algebra-test-templates"
160+
--all-features \
161+
--exclude ark-poly-benches \
162+
--exclude ark-algebra-test-templates"
111163

112164
- name: Test assembly on nightly
113165
env:
@@ -116,11 +168,159 @@ jobs:
116168
with:
117169
command: test
118170
args: "--workspace \
119-
--package ark-test-curves \
120-
--all-features
121-
"
171+
--package ark-test-curves \
172+
--all-features
173+
"
122174
if: matrix.rust == 'nightly'
123175

176+
directories: # Job that list subdirectories
177+
name: List directories for parallelizing tests
178+
runs-on: ubuntu-latest
179+
outputs:
180+
dir: ${{ steps.set-dirs.outputs.dir }} # generate output name dir by using inner step output
181+
steps:
182+
- uses: actions/checkout@v4
183+
- id: set-dirs # Give it an id to handle to get step outputs in the outputs key above
184+
run: |
185+
# shellcheck disable=SC2086
186+
echo "dir=$(find . -mindepth 1 -maxdepth 1 -type d | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
187+
working-directory: ./curves
188+
# Define step output named dir base on ls command transformed to JSON thanks to jq
189+
190+
test-curves:
191+
name: Test
192+
runs-on: ubuntu-latest
193+
needs: [directories] # Depends on previous job
194+
strategy:
195+
matrix:
196+
dir: ${{fromJson(needs.directories.outputs.dir)}} # List matrix strategy from directories dynamically
197+
exclude:
198+
- dir: ./scripts
199+
- dir: ./curve-constraint-tests
200+
- dir: ./mnt4_753
201+
- dir: ./mnt6_753
202+
- dir: ./cp6_782
203+
steps:
204+
- name: Checkout
205+
uses: actions/checkout@v4
206+
- name: Run tests
207+
run: |
208+
cd ${{matrix.dir}}
209+
cargo test --all-features
210+
working-directory: ./curves
211+
212+
test-mnt4-753:
213+
name: Test (mnt4_753/)
214+
runs-on: macos-latest
215+
timeout-minutes: 60
216+
steps:
217+
- name: Checkout
218+
uses: actions/checkout@v4
219+
220+
- name: Check if source code updated
221+
uses: dorny/paths-filter@v2.11.1
222+
id: check-diff
223+
with:
224+
filters: |
225+
mnt4_753_is_updated:
226+
- 'curves/mnt4_753/**'
227+
228+
- name: Generate lockfile
229+
run: cargo generate-lockfile
230+
working-directory: ./curves
231+
232+
- name: Check if deps updated
233+
id: deps-updated
234+
uses: actions/cache@v3
235+
with:
236+
path: |
237+
~/.cargo/registry
238+
~/.cargo/git
239+
target
240+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/curves/Cargo.lock') }}
241+
242+
- name: Conditionally run the tests
243+
# if source code updated OR dependencies updated
244+
if: ${{ steps.check-diff.outputs.mnt4_753_is_updated == 'true' || steps.deps-updated.outputs.cache-hit != 'true' }}
245+
run: |
246+
cd mnt4_753/
247+
cargo test --all-features
248+
working-directory: ./curves
249+
250+
test-mnt6-753:
251+
name: Test (mnt6_753/)
252+
runs-on: macos-latest
253+
timeout-minutes: 60
254+
steps:
255+
- name: Checkout
256+
uses: actions/checkout@v4
257+
258+
- name: Check if source code updated
259+
uses: dorny/paths-filter@v2.11.1
260+
id: check-diff
261+
with:
262+
filters: |
263+
mnt6_753_is_updated:
264+
- 'mnt6_753/**'
265+
266+
- name: Generate lockfile
267+
run: cargo generate-lockfile
268+
269+
- name: Check if deps updated
270+
id: deps-updated
271+
uses: actions/cache@v3
272+
with:
273+
path: |
274+
~/.cargo/registry
275+
~/.cargo/git
276+
target
277+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/curves/Cargo.lock') }}
278+
279+
- name: Conditionally run the tests
280+
# if source code updated OR dependencies updated
281+
if: ${{ steps.check-diff.outputs.mnt6_753_is_updated == 'true' || steps.deps-updated.outputs.cache-hit != 'true' }}
282+
run: |
283+
cd mnt6_753/
284+
cargo test --all-features
285+
working-directory: ./curves
286+
287+
test-cp6_782:
288+
name: Test (cp6_782/)
289+
runs-on: ubuntu-latest
290+
timeout-minutes: 60
291+
steps:
292+
- name: Checkout
293+
uses: actions/checkout@v4
294+
295+
- name: Check if source code updated
296+
uses: dorny/paths-filter@v2.11.1
297+
id: check-diff
298+
with:
299+
filters: |
300+
cp6_782_is_updated:
301+
- 'cp6_782/**'
302+
303+
- name: Generate lockfile
304+
run: cargo generate-lockfile
305+
306+
- name: Check if deps updated
307+
id: deps-updated
308+
uses: actions/cache@v3
309+
with:
310+
path: |
311+
~/.cargo/registry
312+
~/.cargo/git
313+
target
314+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/curves/Cargo.lock') }}
315+
316+
- name: Conditionally run the tests
317+
# if source code updated OR dependencies updated
318+
if: ${{ steps.check-diff.outputs.cp6_782_is_updated == 'true' || steps.deps-updated.outputs.cache-hit != 'true' }}
319+
run: |
320+
cd cp6_782/
321+
cargo test --all-features
322+
working-directory: ./curves
323+
124324
test_assembly:
125325
name: Test assembly
126326
runs-on: ubuntu-latest

CONTRIBUTING.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Contributing
2+
3+
Thank you for considering making contributions to `algebra`!
4+
5+
Contributing to this repository can be done in several forms, such as participating in discussion or proposing code changes.
6+
To ensure a smooth workflow for all contributors, the following general procedure for contributing has been established:
7+
8+
1) Either open or find an issue you'd like to help with
9+
2) Participate in thoughtful discussion on that issue
10+
3) If you would like to contribute:
11+
* If the issue is a feature proposal, ensure that the proposal has been accepted
12+
* Ensure that nobody else has already begun working on this issue.
13+
If they have, please try to contact them to collaborate
14+
* If nobody has been assigned for the issue and you would like to work on it, make a comment on the issue to inform the community of your intentions to begin work. (So we can avoid duplication of efforts)
15+
* We suggest using standard GitHub best practices for contributing: fork the repository, branch from the HEAD of `master`, make some commits on your branch, and submit a PR from the branch to `master`.
16+
More detail on this is below
17+
* Be sure to include a relevant changelog entry in the Pending section of CHANGELOG.md (see file for log format)
18+
* If the change is breaking, we may add migration instructions.
19+
20+
Note that for very small or clear problems (such as typos), or well isolated improvements, it is not required to an open issue to submit a PR.
21+
But be aware that for more complex problems/features touching multiple parts of the codebase, if a PR is opened before an adequate design discussion has taken place in a GitHub issue, that PR runs a larger likelihood of being rejected.
22+
23+
Looking for a good place to start contributing? How about checking out some good first issues
24+
25+
## Branch Structure
26+
27+
`algebra` has its default branch as `master`, which is where PRs are merged into. Releases will be periodically made, on no set schedule.
28+
All other branches should be assumed to be miscellaneous feature development branches.
29+
30+
All downstream users of the library should be using tagged versions of the library pulled from cargo.
31+
32+
## How to work on a fork
33+
34+
Please skip this section if you're familiar with contributing to opensource GitHub projects.
35+
36+
First fork the repository from the GitHub UI, and clone it locally.
37+
Then in the repository, you want to add the repository you forked from as a new remote. You do this as:
38+
39+
```bash
40+
git remote add upstream git@github.com:arkworks-rs/algebra.git
41+
```
42+
43+
Then the way you make code contributions is to first think of a branch name that describes your change.
44+
Then do the following:
45+
46+
```bash
47+
git checkout master
48+
git pull upstream master
49+
git checkout -b $NEW_BRANCH_NAME
50+
```
51+
52+
and then work as normal on that branch, and pull request to upstream master when you're done =)
53+
54+
## Updating documentation
55+
56+
All PRs should aim to leave the code more documented than it started with.
57+
Please don't assume that its easy to infer what the code is doing,
58+
as that is usually not the case for these complex protocols.
59+
(Even when you already understand the paper!)
60+
61+
Its often very useful to describe what is the high level view of what a code block is doing,
62+
and either refer to the relevant section of a paper or include a short proof/argument for why it makes sense before the actual logic.
63+
64+
## Performance improvements
65+
66+
All performance improvements should be accompanied with benchmarks improving, or otherwise have it be clear that things have improved.
67+
For some areas of the codebase, performance roughly follows the number of field multiplications, but there are also many areas where
68+
hard to predict low level system effects such as cache locality and superscalar operations become important for performance.
69+
Thus performance can often become very non-intuitive / diverge from minimizing the number of arithmetic operations.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ resolver = "2"
2020
version = "0.4.2"
2121
authors = [ "arkworks contributors" ]
2222
homepage = "https://arkworks.rs"
23+
exclude = ["curves/**"]
2324
repository = "https://github.com/arkworks-rs/algebra"
2425
categories = ["cryptography"]
2526
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT", "doc/katex-header.html"]

0 commit comments

Comments
 (0)