Skip to content

Commit

Permalink
make 32-bit backend the default
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Jul 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 10664c2 commit cc9aa27
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -22,11 +22,11 @@ jobs:
name: Test Suite
runs-on: buildjet-16vcpu-ubuntu-2204
# We want to run the tests twice, once with the
# default backend (u64) and one with the u32_backend,
# default backend (u32) and one with the u64_backend,
# in both cases with the r1cs feature enabled.
strategy:
matrix:
backend: ["r1cs", "r1cs,u32_backend"]
backend: ["r1cs", "r1cs,u64_backend"]
steps:
- uses: actions/checkout@v4
- name: Install rust toolchain
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ arkworks = [
"hashbrown",
]
r1cs = ["arkworks", "ark-groth16", "ark-r1cs-std", "ark-relations", "ark-snark"]
u32_backend = []
u64_backend = ["arkworks"]

[dev-dependencies]
proptest = "1"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ website](https://protocol.penumbra.zone/main/crypto/decaf377.html).
* `std`: default, for use in `std` environments,
* `alloc`: default, for use in `alloc` environments,
* `arkworks`: default, uses Arkworks crates for elliptic curve operations,
* `u32_backend`: uses 32-bit finite field arithmetic (default is 64-bit),
* `u64_backend`: uses 64-bit finite field arithmetic (default is 32-bit),
* `r1cs`: enables rank-1 constraint system gadgets,
* `parallel`: enables the use of parallelism.

8 changes: 4 additions & 4 deletions src/fields/fp.rs
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@ pub mod arkworks;
mod ops;
mod u32;

#[cfg(not(feature = "u32_backend"))]
#[cfg(feature = "u64_backend")]
mod u64;

cfg_if! {
if #[cfg(feature = "u32_backend")] {
pub type Fp = u32::Fp;
} else {
if #[cfg(feature = "u64_backend")] {
pub type Fp = u64::Fp;
} else {
pub type Fp = u32::Fp;
}
}

8 changes: 4 additions & 4 deletions src/fields/fq.rs
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@ pub mod arkworks;
mod ops;
mod u32;

#[cfg(not(feature = "u32_backend"))]
#[cfg(feature = "u64_backend")]
mod u64;

cfg_if! {
if #[cfg(feature = "u32_backend")] {
pub type Fq = u32::Fq;
} else {
if #[cfg(feature = "u64_backend")] {
pub type Fq = u64::Fq;
} else {
pub type Fq = u32::Fq;
}
}

8 changes: 4 additions & 4 deletions src/fields/fr.rs
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@ pub mod arkworks;
mod ops;
pub mod u32;

#[cfg(not(feature = "u32_backend"))]
#[cfg(feature = "u64_backend")]
pub mod u64;

cfg_if! {
if #[cfg(feature = "u32_backend")] {
pub type Fr = u32::Fr;
} else {
if #[cfg(feature = "u64_backend")] {
pub type Fr = u64::Fr;
} else {
pub type Fr = u32::Fr;
}
}

0 comments on commit cc9aa27

Please sign in to comment.