Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: increase MSRV to 1.83 #328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repository = "https://github.com/filecoin-project/bellman"
version = "0.26.0"
readme = "README.md"
edition = "2021"
rust-version = "1.70"
rust-version = "1.83"

[dependencies]
bellpepper-core = { version = "0.2" }
Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fn main() {
println!("cargo::rustc-check-cfg=cfg(nightly)");
cfg_if_nightly();
gpu_kernel();
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.70.0
1.83.0
5 changes: 1 addition & 4 deletions src/gadgets/blake2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ fn blake2s_compression<Scalar: PrimeField, CS: ConstraintSystem<Scalar>>(
)?;

if f {
v[14] = v[14].xor(
cs.namespace(|| "third xor"),
&UInt32::constant(u32::max_value()),
)?;
v[14] = v[14].xor(cs.namespace(|| "third xor"), &UInt32::constant(u32::MAX))?;
}

{
Expand Down
4 changes: 2 additions & 2 deletions src/gadgets/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ where
let ch = UInt32::sha256_ch(cs.namespace(|| "ch"), &new_e, &f, &g)?;

// temp1 := h + S1 + ch + k[i] + w[i]
let temp1 = vec![
let temp1 = [
h.clone(),
s1,
ch,
Expand All @@ -187,7 +187,7 @@ where
let maj = UInt32::sha256_maj(cs.namespace(|| "maj"), &new_a, &b, &c)?;

// temp2 := S0 + maj
let temp2 = vec![s0, maj];
let temp2 = [s0, maj];

/*
h := g
Expand Down
1 change: 1 addition & 0 deletions src/gadgets/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{ConstraintSystem, Index, LinearCombination, SynthesisError, Variable

#[derive(Debug)]
enum NamedObject {
#[allow(dead_code)]
Constraint(usize),
Var(Variable),
Namespace,
Expand Down
2 changes: 1 addition & 1 deletion src/gadgets/uint32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl UInt32 {

// Compute the maximum value of the sum so we allocate enough bits for
// the result
let mut max_value = (operands.len() as u64) * (u64::from(u32::max_value()));
let mut max_value = (operands.len() as u64) * (u64::from(u32::MAX));

// Keep track of the resulting value
let mut result_value = Some(0u64);
Expand Down
4 changes: 2 additions & 2 deletions src/groth16/aggregate/accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ where
/// exponentiation when verifying if all checks are verified.
/// It is a tuple:
/// - a miller loop result that is to be multiplied by other miller loop results
/// before going into a final exponentiation result
/// before going into a final exponentiation result
/// - a right side result which is already in the right subgroup Gt which is to
/// be compared to the left side when "final_exponentiatiat"-ed
/// be compared to the left side when "final_exponentiatiat"-ed
#[derive(Debug)]
struct PairingCheck<E>
where
Expand Down
14 changes: 8 additions & 6 deletions src/groth16/aggregate/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
/// The first one is a commitment scheme that commits to a single vector $a$ of
/// length n in the second base group $G_1$ (for example):
/// * it requires a structured SRS $v_1$ of the form $(h,h^u,h^{u^2}, ...
/// ,g^{h^{n-1}})$ with $h \in G_2$ being a random generator of $G_2$ and $u$ a
/// random scalar (coming from a power of tau ceremony for example)
/// ,g^{h^{n-1}})$ with $h \in G_2$ being a random generator of $G_2$ and $u$ a
/// random scalar (coming from a power of tau ceremony for example)
/// * it requires a second structured SRS $v_2$ of the form $(h,h^v,h^{v^2},
/// ...$ with $v$ being a random scalar different than u (coming from another
/// power of tau ceremony for example)
/// ...$ with $v$ being a random scalar different than u (coming from another
/// power of tau ceremony for example)
///
/// The Commitment is a tuple $(\prod_{i=0}^{n-1} e(a_i,v_{1,i}),
/// \prod_{i=0}^{n-1} e(a_i,v_{2,i}))$
///
Expand All @@ -16,8 +17,9 @@
/// though:
/// * $v_1$ and $v_2$ stay the same
/// * An additional tuple $w_1 = (g^{u^n},g^{u^{n+1}},...g^{u^{2n-1}})$ and $w_2 =
/// (g^{v^n},g^{v^{n+1},...,g^{v^{2n-1}})$ where $g$ is a random generator of
/// $G_1$
/// (g^{v^n},g^{v^{n+1},...,g^{v^{2n-1}})$ where $g$ is a random generator of
/// $G_1$
///
/// The commitment scheme returns a tuple:
/// * $\prod_{i=0}^{n-1} e(a_i,v_{1,i})e(w_{1,i},b_i)$
/// * $\prod_{i=0}^{n-1} e(a_i,v_{2,i})e(w_{2,i},b_i)$
Expand Down
6 changes: 1 addition & 5 deletions src/groth16/aggregate/inner_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ pub(crate) fn pairing_miller_affine<E: MultiMillerLoop>(
));
}
let prepared: Vec<E::G2Prepared> = right.par_iter().map(|&p| p.into()).collect();
let pairs_ref: Vec<_> = left
.iter()
.zip(prepared.iter())
.map(|(a, b)| (a, b))
.collect();
let pairs_ref: Vec<_> = left.iter().zip(prepared.iter()).collect();

Ok(E::multi_miller_loop(&pairs_ref))
}
Expand Down
4 changes: 2 additions & 2 deletions src/groth16/aggregate/msm/fixed_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ where
T::AffineRepr: Send,
{
let in_window = 1 << window;
let outerc = (scalar_size + window - 1) / window;
let outerc = scalar_size.div_ceil(window);
let last_in_window = 1 << (scalar_size - (outerc - 1) * window);

let mut multiples_of_g = vec![vec![T::identity(); in_window]; outerc];
Expand Down Expand Up @@ -93,7 +93,7 @@ where
T: PrimeCurve,
T::Scalar: PrimeFieldBits,
{
let outerc = (scalar_size + window - 1) / window;
let outerc = scalar_size.div_ceil(window);
assert!(outerc <= table.len());

v.par_iter()
Expand Down
4 changes: 2 additions & 2 deletions src/groth16/aggregate/poly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<F: Field> DensePolynomial<F> {
}
}

impl<'a, 'b, F: Field> Sub<&'a DensePolynomial<F>> for &'b DensePolynomial<F> {
impl<'a, F: Field> Sub<&'a DensePolynomial<F>> for &DensePolynomial<F> {
type Output = DensePolynomial<F>;

fn sub(self, other: &'a DensePolynomial<F>) -> DensePolynomial<F> {
Expand Down Expand Up @@ -109,7 +109,7 @@ impl<'a, 'b, F: Field> Sub<&'a DensePolynomial<F>> for &'b DensePolynomial<F> {
}
}

impl<'a, 'b, F: Field> Div<&'a DensePolynomial<F>> for &'b DensePolynomial<F> {
impl<'a, F: Field> Div<&'a DensePolynomial<F>> for &DensePolynomial<F> {
type Output = DensePolynomial<F>;

fn div(self, divisor: &'a DensePolynomial<F>) -> DensePolynomial<F> {
Expand Down
3 changes: 2 additions & 1 deletion src/groth16/aggregate/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,15 @@ where
})
}

pub fn aggregate_proofs_and_instances<E: Engine + std::fmt::Debug>(
pub fn aggregate_proofs_and_instances<E>(
srs: &ProverSRSInputAggregation<E>,
transcript_include: &[u8],
statements: &[Vec<E::Fr>],
proofs: &[Proof<E>],
version: AggregateVersion,
) -> Result<AggregateProofAndInstance<E>, SynthesisError>
where
E: Engine + std::fmt::Debug,
E: MultiMillerLoop + std::fmt::Debug,
E::Fr: Serialize,
<E::Fr as PrimeField>::Repr: Send + Sync,
Expand Down
12 changes: 5 additions & 7 deletions src/groth16/aggregate/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ where
/// verification of related instances i.e. when instances are given by
/// [a1, ... , an, b1, ... , bn], [b1, ... , bn, c1, ..., cn], [c1, ..., cn, d1, ..., dn] etc
#[allow(clippy::too_many_arguments)]
pub fn verify_aggregate_proof_and_aggregate_instances<
E: Engine + std::fmt::Debug,
R: rand::RngCore + Send,
>(
pub fn verify_aggregate_proof_and_aggregate_instances<E, R>(
ip_verifier_srs: &VerifierSRS<E>,
pvk: &PreparedVerifyingKey<E>,
rng: R,
Expand All @@ -218,6 +215,7 @@ pub fn verify_aggregate_proof_and_aggregate_instances<
version: AggregateVersion,
) -> Result<bool, SynthesisError>
where
E: Engine + std::fmt::Debug,
E: MultiMillerLoop + std::fmt::Debug,
E::Fr: Serialize,
<E as Engine>::Gt: Compress + Serialize,
Expand Down Expand Up @@ -533,10 +531,10 @@ fn verify_tipp_mipp<E, R>(
/// * T,U: the final commitment values of A and B
/// * Z the final product between A and B.
/// * Challenges are returned in inverse order as well to avoid
/// repeating the operation multiple times later on.
/// repeating the operation multiple times later on.
/// * There are T,U,Z vectors as well for the MIPP relationship. Both TIPP and
/// MIPP share the same challenges however, enabling to re-use common operations
/// between them, such as the KZG proof for commitment keys.
/// MIPP share the same challenges however, enabling to re-use common operations
/// between them, such as the KZG proof for commitment keys.
#[allow(clippy::type_complexity)]
fn gipa_verify_tipp_mipp<E>(
proof: &AggregateProof<E>,
Expand Down
2 changes: 1 addition & 1 deletion src/groth16/mapped_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where
pub checked: bool,
}

impl<'a, E> ParameterSource<E> for &'a MappedParameters<E>
impl<E> ParameterSource<E> for &MappedParameters<E>
where
E: MultiMillerLoop,
{
Expand Down
8 changes: 3 additions & 5 deletions src/groth16/multiscalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ pub enum ScalarList<'a, G: PrimeCurveAffine, F: Fn(usize) -> <G::Scalar as Prime
Getter(F, usize),
}

impl<'a, G: PrimeCurveAffine, F: Fn(usize) -> <G::Scalar as PrimeField>::Repr>
ScalarList<'a, G, F>
{
impl<G: PrimeCurveAffine, F: Fn(usize) -> <G::Scalar as PrimeField>::Repr> ScalarList<'_, G, F> {
pub fn len(&self) -> usize {
match self {
ScalarList::Slice(s) => s.len(),
Expand Down Expand Up @@ -173,7 +171,7 @@ pub fn multiscalar<G: PrimeCurveAffine>(
let mut result = G::Curve::identity();

// nbits must be evenly divided by window_size!
let num_windows = (nbits + precomp_table.window_size() - 1) / precomp_table.window_size();
let num_windows = nbits.div_ceil(precomp_table.window_size());
let mut idx;

// This version prefetches the next window and computes on the previous window.
Expand Down Expand Up @@ -238,7 +236,7 @@ where
chunk_size = 1; // fallback for tests and tiny inputs
}

let num_parts = (num_points + chunk_size - 1) / chunk_size;
let num_parts = num_points.div_ceil(chunk_size);

(0..num_parts)
.into_par_iter()
Expand Down
2 changes: 1 addition & 1 deletion src/groth16/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ where
}
}

impl<'a, E> ParameterSource<E> for &'a Parameters<E>
impl<E> ParameterSource<E> for &Parameters<E>
where
E: MultiMillerLoop,
{
Expand Down
2 changes: 1 addition & 1 deletion src/groth16/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn deserialize_proof<'de, D: Deserializer<'de>, E: Engine>(d: D) -> Result<Proof
_ph: PhantomData<E>,
}

impl<'de, E: Engine> Visitor<'de> for BytesVisitor<E> {
impl<E: Engine> Visitor<'_> for BytesVisitor<E> {
type Value = Proof<E>;

fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
6 changes: 2 additions & 4 deletions src/groth16/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ use super::{multiscalar, PreparedVerifyingKey, Proof, VerifyingKey};
use crate::{le_bytes_to_u64s, SynthesisError};

/// Generate a prepared verifying key, required to verify a proofs.
pub fn prepare_verifying_key<E: Engine + MultiMillerLoop>(
vk: &VerifyingKey<E>,
) -> PreparedVerifyingKey<E>
pub fn prepare_verifying_key<E>(vk: &VerifyingKey<E>) -> PreparedVerifyingKey<E>
where
E: MultiMillerLoop,
E: Engine + MultiMillerLoop,
{
let neg_gamma = -vk.gamma_g2;
let neg_delta = -vk.delta_g2;
Expand Down
2 changes: 2 additions & 0 deletions src/util_cs/metric_cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ struct OrderedVariable(Variable);

#[derive(Debug)]
enum NamedObject {
#[allow(dead_code)]
Constraint(usize),
#[allow(dead_code)]
Var(Variable),
Namespace,
}
Expand Down
5 changes: 2 additions & 3 deletions tests/groth16_aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct MimcDemo<'a, Scalar: PrimeField> {
constants: &'a [Scalar],
}

impl<'a, Scalar: PrimeField> Circuit<Scalar> for MimcDemo<'a, Scalar> {
impl<Scalar: PrimeField> Circuit<Scalar> for MimcDemo<'_, Scalar> {
fn synthesize<CS: ConstraintSystem<Scalar>>(self, cs: &mut CS) -> Result<(), SynthesisError> {
assert_eq!(self.constants.len(), MIMC_ROUNDS);

Expand Down Expand Up @@ -158,8 +158,7 @@ impl<Scalar: PrimeField> Circuit<Scalar> for TestCircuit<Scalar> {
let input_variables: Vec<_> = self
.public_inputs
.iter()
.enumerate()
.map(|(_i, input)| -> Result<AllocatedNum<_>, SynthesisError> {
.map(|input| -> Result<AllocatedNum<_>, SynthesisError> {
let num = AllocatedNum::alloc(&mut cs, || {
input.ok_or(SynthesisError::AssignmentMissing)
})?;
Expand Down
2 changes: 1 addition & 1 deletion tests/mimc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct MimcDemo<'a, Scalar: PrimeField> {
/// Our demo circuit implements this `Circuit` trait which
/// is used during paramgen and proving in order to
/// synthesize the constraint system.
impl<'a, Scalar: PrimeField> Circuit<Scalar> for MimcDemo<'a, Scalar> {
impl<Scalar: PrimeField> Circuit<Scalar> for MimcDemo<'_, Scalar> {
fn synthesize<CS: ConstraintSystem<Scalar>>(self, cs: &mut CS) -> Result<(), SynthesisError> {
assert_eq!(self.constants.len(), MIMC_ROUNDS);

Expand Down