Skip to content

Commit

Permalink
Merge branch 'master' into clean_h2_ff
Browse files Browse the repository at this point in the history
  • Loading branch information
¨Jeff committed Sep 27, 2023
2 parents 93bd53c + c92be0e commit 4025748
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 214 deletions.
43 changes: 22 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- nightly
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust (${{ matrix.rust }})
uses: actions-rs/toolchain@v1
Expand All @@ -72,7 +72,7 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
RUSTFLAGS: -Dwarnings
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust nightly
uses: actions-rs/toolchain@v1
Expand All @@ -137,7 +137,7 @@ jobs:
toolchain: nightly
override: true

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand All @@ -160,7 +160,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install Rust
uses: actions-rs/toolchain@v1
Expand All @@ -169,7 +169,7 @@ jobs:
target: aarch64-unknown-none
override: true

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand Down Expand Up @@ -215,14 +215,15 @@ jobs:
- ed_on_bls12_377
steps:
- name: Checkout curves
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: arkworks-rs/curves
path: curves

- name: Checkout algebra
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: algebra
path: ark-algebra

- name: Install Rust
uses: actions-rs/toolchain@v1
Expand All @@ -233,19 +234,19 @@ jobs:

- name: Patch cargo.toml
run: |
if grep -q "\[patch.crates-io\]" Cargo.toml ; then
MATCH=$(awk '/\[patch.crates-io\]/{ print NR; exit }' Cargo.toml);
sed -i "$MATCH,\$d" Cargo.toml
if grep -q "\[patch.crates-io\]" curves/Cargo.toml ; then
MATCH=$(awk '/\[patch.crates-io\]/{ print NR; exit }' curves/Cargo.toml);
sed -i "$MATCH,\$d" curves/Cargo.toml
fi
{
echo "[patch.crates-io]";
echo "ark-ff = { path = 'algebra/ff' }";
echo "ark-serialize = { path = 'algebra/serialize' }";
echo "ark-ff-macros = { path = 'algebra/ff-macros' }";
echo "ark-ff-asm = { path = 'algebra/ff-asm' }";
echo "ark-ec = { path = 'algebra/ec' }";
echo "ark-algebra-bench-templates = { path = 'algebra/bench-templates' }"
echo "ark-algebra-test-templates = { path = 'algebra/test-templates' }"
echo "ark-ff = { path = '../ark-algebra/ff' }";
echo "ark-serialize = { path = '../ark-algebra/serialize' }";
echo "ark-ff-macros = { path = '../ark-algebra/ff-macros' }";
echo "ark-ff-asm = { path = '../ark-algebra/ff-asm' }";
echo "ark-ec = { path = '../ark-algebra/ec' }";
echo "ark-algebra-bench-templates = { path = '../ark-algebra/bench-templates' }"
echo "ark-algebra-test-templates = { path = '../ark-algebra/test-templates' }"
echo "ark-bls12-377 = { git = 'https://github.com/arkworks-rs/curves' }"
echo "ark-bls12-381 = { git = 'https://github.com/arkworks-rs/curves' }"
echo "ark-bn254 = { git = 'https://github.com/arkworks-rs/curves' }"
Expand All @@ -256,7 +257,7 @@ jobs:
echo "ark-ed-on-bls12-377 = { git = 'https://github.com/arkworks-rs/curves' }"
echo "ark-std = { git = 'https://github.com/arkworks-rs/std' }"
echo "ark-r1cs-std = { git = 'https://github.com/arkworks-rs/r1cs-std' }"
} >> Cargo.toml
} >> curves/Cargo.toml
- name: Test on ${{ matrix.curve }}
run: "cd ${{ matrix.curve }} && cargo test --all-features"
run: "cd curves/${{ matrix.curve }} && cargo test --all-features"
56 changes: 55 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[workspace]

members = [
"serialize",
"serialize-derive",
Expand All @@ -15,6 +14,61 @@ members = [
"test-curves",
"test-templates",
]
resolver = "2"

[workspace.package]
version = "0.4.2"
authors = [ "arkworks contributors" ]
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT", "doc/katex-header.html"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.70"

[workspace.metadata.docs.rs]
rustdoc-args = [ "--html-in-header katex-header.html" ]

[workspace.dependencies]
ark-ec = { version = "0.4.2", path = "./ec", default-features = false }
ark-ff = { version = "0.4.2", path = "./ff", default-features = false }
ark-ff-asm = { version = "0.4.2", path = "./ff-asm" }
ark-ff-macros = { version = "0.4.2", path = "./ff-macros" }
ark-poly = { version = "0.4.2", path = "./poly", default-features = false }
ark-serialize = { version = "0.4.2", path = "./serialize", default-features = false }
ark-serialize-derive = { version = "0.4.2", path = "./serialize-derive" }
ark-std = { version = "0.4.0", default-features = false }

ark-algebra-bench-templates = { version = "0.4.2", path = "./bench-templates", default-features = false }
ark-algebra-test-templates = { version = "0.4.2", path = "./test-templates", default-features = false }
ark-test-curves = { version = "0.4.2", path = "./test-curves", default-features = false }

num-traits = { version = "0.2", default-features = false }
num-bigint = { version = "0.4", default-features = false }
num-integer = { version = "0.1", default-features = false }

criterion = "0.5.0"
derivative = "2"
digest = { version = "0.10", default-features = false }
hashbrown = "0.14"
hex = "0.4"
itertools = { version = "0.11", default-features = false }
libtest-mimic = "0.6.0"
paste = "1.0"
rayon = "1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
sha2 = { version = "0.10", default-features = false }
sha3 = { version = "0.10", default-features = false }
blake2 = { version = "0.10", default-features = false }
zeroize = { version = "1", default-features = false }


proc-macro2 = "1.0"
quote = "1.0"
syn = "1.0"

resolver = "2"

Expand Down
34 changes: 18 additions & 16 deletions bench-templates/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
[package]
name = "ark-algebra-bench-templates"
version = "0.4.2"
authors = [ "arkworks contributors" ]
description = "A benchmark library for finite fields and elliptic curves"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
documentation = "https://docs.rs/algebra/"
keywords = ["cryptography", "finite-fields", "elliptic-curves", "pairing"]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.63"
documentation = "https://docs.rs/ark-algebra-bench-templates/"
version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true
include.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
rustdocflags.workspace = true


################################# Dependencies ################################

[dependencies]
criterion = { version = "0.5.1", features = [ "html_reports" ] }
ark-std = { version = "0.4.0", default-features = false }
ark-ec = { version = "0.4.2", path = "../ec", default-features = false }
ark-ff = { version = "0.4.2", path = "../ff", default-features = false }
ark-serialize = { version = "0.4.2", path = "../serialize", default-features = false }
paste = { version = "1.0" }
criterion = { workspace = true, features = [ "html_reports" ] }
ark-std.workspace = true
ark-ec.workspace = true
ark-ff.workspace = true
ark-serialize.workspace = true
paste.workspace = true

[features]
asm = [ "ark-ff/asm" ]
Expand Down
55 changes: 28 additions & 27 deletions ec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
[package]
name = "ark-ec"
version = "0.4.2"
authors = [ "arkworks contributors" ]
description = "A library for elliptic curves and pairings"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
documentation = "https://docs.rs/ark-ec/"
version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true
include.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
rustdocflags.workspace = true
keywords = ["cryptography", "elliptic-curves", "pairing"]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "doc", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.63"

[dependencies]
ark-std = { version = "0.4.0", default-features = false }
ark-serialize = { version = "0.4.2", path = "../serialize", default-features = false }
ark-ff = { version = "0.4.2", path = "../ff", default-features = false }
ark-poly = { version = "0.4.2", path = "../poly", default-features = false }
derivative = { version = "2", features = ["use_core"] }
num-traits = { version = "0.2", default-features = false }
rayon = { version = "1", optional = true }
zeroize = { version = "1", default-features = false, features = ["zeroize_derive"] }
hashbrown = "0.14.0"
itertools = { version = "0.11", default-features = false }
num-bigint = { version = "0.4.3", default-features = false }
ark-std.workspace = true
ark-serialize.workspace = true
ark-ff.workspace = true
ark-poly.workspace = true
derivative = { workspace = true, features = ["use_core"] }
num-bigint.workspace = true
num-traits.workspace = true
rayon = { workspace = true, optional = true }
zeroize = { workspace = true, features = ["zeroize_derive"] }
hashbrown.workspace = true
itertools.workspace = true

[dev-dependencies]
ark-test-curves = { version = "0.4.2", path = "../test-curves", default-features = false, features = ["bls12_381_curve"] }
sha2 = { version = "0.10", default-features = false }
libtest-mimic = "0.6.0"
serde = "1.0.110"
serde_json = "1.0.53"
serde_derive = "1.0.110"
hex = "0.4"
ark-test-curves = { workspace = true, features = ["bls12_381_curve"] }
sha2.workspace = true
libtest-mimic.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_derive.workspace = true
hex.workspace = true

[features]
default = []
Expand Down
17 changes: 9 additions & 8 deletions ec/src/scalar_mul/variable_base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn msm_bigint<V: VariableBaseMSM>(
}

// From: https://github.com/arkworks-rs/gemini/blob/main/src/kzg/msm/variable_base.rs#L20
fn make_digits(a: &impl BigInteger, w: usize, num_bits: usize) -> Vec<i64> {
fn make_digits(a: &impl BigInteger, w: usize, num_bits: usize) -> impl Iterator<Item = i64> + '_ {
let scalar = a.as_ref();
let radix: u64 = 1 << w;
let window_mask: u64 = radix - 1;
Expand All @@ -258,8 +258,8 @@ fn make_digits(a: &impl BigInteger, w: usize, num_bits: usize) -> Vec<i64> {
num_bits
};
let digits_count = (num_bits + w - 1) / w;
let mut digits = vec![0i64; digits_count];
for (i, digit) in digits.iter_mut().enumerate() {

(0..digits_count).into_iter().map(move |i| {
// Construct a buffer of bits of the scalar, starting at `bit_offset`.
let bit_offset = i * w;
let u64_idx = bit_offset / 64;
Expand All @@ -279,10 +279,11 @@ fn make_digits(a: &impl BigInteger, w: usize, num_bits: usize) -> Vec<i64> {

// Recenter coefficients from [0,2^w) to [-2^w/2, 2^w/2)
carry = (coef + radix / 2) >> w;
*digit = (coef as i64) - (carry << w) as i64;
}
let mut digit = (coef as i64) - (carry << w) as i64;

digits[digits_count - 1] += (carry << w) as i64;

digits
if i == digits_count - 1 {
digit += (carry << w) as i64;
}
digit
})
}
23 changes: 12 additions & 11 deletions ff-asm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
[package]
name = "ark-ff-asm"
version = "0.4.2"
authors = [ "arkworks contributors" ]
description = "A library for generating x86-64 assembly for finite field multiplication"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/algebra"
documentation = "https://docs.rs/ark-ff-asm/"
version.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
categories.workspace = true
include.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true
rustdocflags.workspace = true
keywords = ["cryptography", "finite-fields", "assembly" ]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.60"

[dependencies]
quote = "1.0.0"
syn = { version = "1.0.0", features = ["full", "parsing", "extra-traits"]}
quote.workspace = true
syn = { workspace = true, features = ["full", "parsing", "extra-traits"]}

[lib]
proc-macro = true
Loading

0 comments on commit 4025748

Please sign in to comment.