Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
varunthakore authored Oct 16, 2023
2 parents 61b1f27 + c3d32cf commit 6e15e78
Show file tree
Hide file tree
Showing 23 changed files with 338 additions and 22 deletions.
24 changes: 21 additions & 3 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@
# clippy doesn't currently allow for specifiying project-wide lints in a
# configuration file. This is a similar workaround to the ones presented here:
# <https://github.com/EmbarkStudios/rust-ecosystem/issues/59>
# TODO: add support for --all-features
xclippy = [
"clippy", "--all-targets", "--",
"clippy", "--workspace", "--all-targets", "--",
"-Wclippy::all",
"-Wclippy::match_same_arms",
"-Wclippy::cast_lossless",
"-Wclippy::dbg_macro",
"-Wclippy::disallowed_methods",
]
"-Wclippy::derive_partial_eq_without_eq",
"-Wclippy::enum_glob_use",
"-Wclippy::filter_map_next",
"-Wclippy::flat_map_option",
"-Wclippy::inefficient_to_string",
"-Wclippy::large_types_passed_by_value",
"-Wclippy::manual_assert",
"-Wclippy::manual_ok_or",
"-Wclippy::map_flatten",
"-Wclippy::map_unwrap_or",
"-Wclippy::needless_borrow",
"-Wclippy::checked_conversions",
"-Wclippy::trait_duplication_in_bounds",
"-Wrust_2018_idioms",
"-Wtrivial_numeric_casts",
"-Wunused_lifetimes",
]
4 changes: 2 additions & 2 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ failure-output = "immediate-final"
status-level = "skip"
# Do not cancel the test run on the first failure.
fail-fast = false
# Mark tests as slow after 5mins, kill them after 50
slow-timeout = { period = "300s", terminate-after = 10 }
# Mark tests as slow after 5mins, kill them after 10
slow-timeout = { period = "300s", terminate-after = 2 }
19 changes: 19 additions & 0 deletions .github/workflows/licenses-audits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: cargo-deny

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

env:
CARGO_TERM_COLOR: always

jobs:
cargo-deny:
name: cargo-deny (advisories, licenses, bans, ...)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: cargo test
# TODO: --all-features
run: |
cargo nextest run --release --profile ci
cargo nextest run --profile ci --cargo-profile dev-ci
- name: Doctests
run: |
cargo test --doc
Expand Down
12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[workspace]
resolver = "2"
members = [
"crates/bellpepper-emulated",
"crates/bellpepper-ed25519",
"crates/emulated",
"crates/ed25519",
"crates/bellpepper-sha512",
]

Expand All @@ -14,3 +14,11 @@ repository = "https://github.com/lurk-lab/bellpepper-gadgets"
bellpepper-core = { version="0.2.0", default-features = false }
bellpepper = { version="0.2.0", default-features = false }
ff = "0.13.0"

[profile.dev-ci]
inherits = "dev"
# By compiling dependencies with optimizations, performing tests gets much faster.
opt-level = 3
lto = "thin"
incremental = false
codegen-units = 16
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository.workspace = true
bellpepper-core = { workspace = true }
bellpepper = { workspace = true }
ff = { workspace = true }
bellpepper-emulated = { version = "0.2.0", path = "../bellpepper-emulated" }
bellpepper-emulated = { version = "0.2.0", path = "../emulated" }
num-bigint = { version = "0.4.3", features = ["rand"] }
num-integer = "0.1.45"
num-traits = "0.2.15"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,11 @@ where
where
CS: ConstraintSystem<F>,
{
if self.overflow + 2 > Self::max_overflow() {
panic!(
assert!(self.overflow + 2 <= Self::max_overflow(),
"Not enough bits in native field to accomodate a subtraction operation which is performed during reduce: {} > {}",
self.overflow + 2,
Self::max_overflow(),
);
}

self.enforce_width_conditional(&mut cs.namespace(|| "ensure bitwidths in input"))?;
if self.overflow == 0 {
Expand Down Expand Up @@ -528,13 +526,12 @@ where
}

fn mul_precondition(a: &Self, b: &Self) -> Result<usize, OverflowError> {
if 2 * P::bits_per_limb() > F::CAPACITY as usize {
panic!(
"Not enough bits in native field to accomodate a product of limbs: {} < {}",
F::CAPACITY,
2 * P::bits_per_limb(),
);
}
assert!(
2 * P::bits_per_limb() <= F::CAPACITY as usize,
"Not enough bits in native field to accomodate a product of limbs: {} < {}",
F::CAPACITY,
2 * P::bits_per_limb(),
);
let reduce_right = a.overflow < b.overflow;
let max_carry_bits = (a.len().min(b.len()) as f32).log2().ceil() as usize;
let next_overflow = P::bits_per_limb() + a.overflow + b.overflow + max_carry_bits;
Expand Down Expand Up @@ -793,9 +790,7 @@ where
}

let pseudo_mersenne_params = P::pseudo_mersenne_params().unwrap();
if P::num_limbs() * P::bits_per_limb() < pseudo_mersenne_params.e as usize {
panic!("The number of bits available is too small to accommodate the non-native field elements");
}
assert!(P::num_limbs() * P::bits_per_limb() >= pseudo_mersenne_params.e as usize, "The number of bits available is too small to accommodate the non-native field elements");

let mut acc = chunks[0].clone();

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 6e15e78

Please sign in to comment.