Skip to content

Commit

Permalink
Eliminate hard-coded BN_N_LIMBS and BN_LIMB_WIDTH dependency. (#327)
Browse files Browse the repository at this point in the history
* make `NUM_FE_WITHOUT_IO_FOR_CRHF` dependent on `NIO_NOVA_FOLD` and `BN_N_LIMBS`

* make `limbs_per_group` calculation always return at least 1
  • Loading branch information
mpenciak authored Feb 26, 2024
1 parent ef7fd7e commit 9c4b1ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub(crate) const NUM_CHALLENGE_BITS: usize = 128;
pub(crate) const BN_LIMB_WIDTH: usize = 64;
pub(crate) const BN_N_LIMBS: usize = 4;
pub(crate) const NUM_FE_WITHOUT_IO_FOR_CRHF: usize = 17;
pub(crate) const NUM_FE_WITHOUT_IO_FOR_CRHF: usize = 9 + NIO_NOVA_FOLD * BN_N_LIMBS;
pub(crate) const NUM_FE_FOR_RO: usize = 9;
pub(crate) const NIO_NOVA_FOLD: usize = 2;

Expand Down
6 changes: 5 additions & 1 deletion src/gadgets/nonnative/bignat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,11 @@ impl<Scalar: PrimeField> BigNat<Scalar> {
let carry_bits = (((max_word.to_f64().unwrap() * 2.0).log2() - self.params.limb_width as f64)
.ceil()
+ 0.1) as usize;
let limbs_per_group = (Scalar::CAPACITY as usize - carry_bits) / self.params.limb_width;
let limbs_per_group = max(
(Scalar::CAPACITY as usize - carry_bits) / self.params.limb_width,
1,
);

let self_grouped = self.group_limbs(limbs_per_group);
let other_grouped = other.group_limbs(limbs_per_group);
self_grouped.equal_when_carried(cs.namespace(|| "grouped"), &other_grouped)
Expand Down

1 comment on commit 9c4b1ec

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Table of Contents

Overview

This benchmark report shows the Arecibo GPU benchmarks.
NVIDIA L4
Intel(R) Xeon(R) CPU @ 2.20GHz
32 vCPUs
125 GB RAM
Workflow run: https://github.com/lurk-lab/arecibo/actions/runs/8050432315

Benchmark Results

RecursiveSNARK-NIVC-2

ref=ef7fd7e ref=9c4b1ec
Prove-NumCons-6540 44.69 ms (✅ 1.00x) 44.26 ms (✅ 1.01x faster)
Verify-NumCons-6540 34.51 ms (✅ 1.00x) 34.38 ms (✅ 1.00x faster)
Prove-NumCons-1028888 321.41 ms (✅ 1.00x) 338.80 ms (✅ 1.05x slower)
Verify-NumCons-1028888 254.23 ms (✅ 1.00x) 266.44 ms (✅ 1.05x slower)

CompressedSNARK-NIVC-Commitments-2

ref=ef7fd7e ref=9c4b1ec
Prove-NumCons-6540 10.69 s (✅ 1.00x) 10.69 s (✅ 1.00x slower)
Verify-NumCons-6540 50.68 ms (✅ 1.00x) 50.64 ms (✅ 1.00x faster)
Prove-NumCons-1028888 53.82 s (✅ 1.00x) 53.42 s (✅ 1.01x faster)
Verify-NumCons-1028888 50.84 ms (✅ 1.00x) 50.54 ms (✅ 1.01x faster)

Made with criterion-table

Please sign in to comment.