Skip to content

Commit aa4d981

Browse files
[chore] Bump version to 0.5.0 and fix clippy (#19)
Sync with upstream for v0.5.0
2 parents 00975be + 568d8e5 commit aa4d981

File tree

10 files changed

+41
-45
lines changed

10 files changed

+41
-45
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "halo2curves-axiom"
3-
version = "0.4.4"
3+
version = "0.5.0"
44
authors = ["Privacy Scaling Explorations team", "Taiko Labs", "Intrinsic Technologies"]
55
license = "MIT/Apache-2.0"
66
edition = "2021"

src/derive/curve.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,11 @@ macro_rules! new_curve_impl {
305305
}
306306

307307
paste::paste! {
308-
#[allow(unused_imports)]
309-
use ::serde::de::Error as _;
310308
impl<'de> ::serde::Deserialize<'de> for $name {
311309
fn deserialize<D: ::serde::Deserializer<'de>>(
312310
deserializer: D,
313311
) -> Result<Self, D::Error> {
312+
use ::serde::de::Error as _;
314313
let bytes = if deserializer.is_human_readable() {
315314
::hex::serde::deserialize(deserializer)?
316315
} else {
@@ -335,12 +334,11 @@ macro_rules! new_curve_impl {
335334
}
336335

337336
paste::paste! {
338-
#[allow(unused_imports)]
339-
use ::serde::de::Error as _;
340337
impl<'de> ::serde::Deserialize<'de> for $name_affine {
341338
fn deserialize<D: ::serde::Deserializer<'de>>(
342339
deserializer: D,
343340
) -> Result<Self, D::Error> {
341+
use ::serde::de::Error as _;
344342
let bytes = if deserializer.is_human_readable() {
345343
::hex::serde::deserialize(deserializer)?
346344
} else {
@@ -532,6 +530,7 @@ macro_rules! new_curve_impl {
532530
}
533531

534532

533+
#[allow(clippy::redundant_closure_call)]
535534
fn hash_to_curve<'a>(domain_prefix: &'a str) -> Box<dyn Fn(&[u8]) -> Self + 'a> {
536535
$hash_to_curve($curve_id, domain_prefix)
537536
}

src/derive/field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ macro_rules! field_common {
6363
$crate::ff_ext::jacobi::jacobi::<5>(&self.0, &$modulus.0)
6464
}
6565

66-
#[allow(dead_code)]
66+
#[cfg(feature = "asm")]
6767
const fn montgomery_form(val: [u64; 4], r: $field) -> $field {
6868
// Converts a 4 64-bit limb value into its congruent field representation.
6969
// If `val` representes a 256 bit value then `r` should be R^2,

src/ff_ext/inverse.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ impl<const B: usize, const L: usize> Add for &CInt<B, L> {
5757
type Output = CInt<B, L>;
5858
fn add(self, other: Self) -> Self::Output {
5959
let (mut data, mut carry) = ([0; L], 0);
60-
for i in 0..L {
60+
for (i, d) in data.iter_mut().enumerate().take(L) {
6161
let sum = self.0[i] + other.0[i] + carry;
62-
data[i] = sum & CInt::<B, L>::MASK;
62+
*d = sum & CInt::<B, L>::MASK;
6363
carry = sum >> B;
6464
}
65-
Self::Output { 0: data }
65+
CInt::<B, L>(data)
6666
}
6767
}
6868

@@ -91,12 +91,12 @@ impl<const B: usize, const L: usize> Sub for &CInt<B, L> {
9191
// addition algorithm, where the carry flag is initialized with 1 and
9292
// the chunks of the second argument are bitwise inverted
9393
let (mut data, mut carry) = ([0; L], 1);
94-
for i in 0..L {
94+
for (i, d) in data.iter_mut().enumerate().take(L) {
9595
let sum = self.0[i] + (other.0[i] ^ CInt::<B, L>::MASK) + carry;
96-
data[i] = sum & CInt::<B, L>::MASK;
96+
*d = sum & CInt::<B, L>::MASK;
9797
carry = sum >> B;
9898
}
99-
Self::Output { 0: data }
99+
CInt::<B, L>(data)
100100
}
101101
}
102102

@@ -120,12 +120,12 @@ impl<const B: usize, const L: usize> Neg for &CInt<B, L> {
120120
// For the two's complement code the additive negation is the result
121121
// of adding 1 to the bitwise inverted argument's representation
122122
let (mut data, mut carry) = ([0; L], 1);
123-
for i in 0..L {
123+
for (i, d) in data.iter_mut().enumerate().take(L) {
124124
let sum = (self.0[i] ^ CInt::<B, L>::MASK) + carry;
125-
data[i] = sum & CInt::<B, L>::MASK;
125+
*d = sum & CInt::<B, L>::MASK;
126126
carry = sum >> B;
127127
}
128-
Self::Output { 0: data }
128+
CInt::<B, L>(data)
129129
}
130130
}
131131

@@ -150,7 +150,7 @@ impl<const B: usize, const L: usize> Mul for &CInt<B, L> {
150150
carry = (sum >> B) as u64;
151151
}
152152
}
153-
Self::Output { 0: data }
153+
CInt::<B, L>(data)
154154
}
155155
}
156156

@@ -189,12 +189,12 @@ impl<const B: usize, const L: usize> Mul<i64> for &CInt<B, L> {
189189
} else {
190190
(other, 0, 0)
191191
};
192-
for i in 0..L {
192+
for (i, d) in data.iter_mut().enumerate().take(L) {
193193
let sum = (carry as u128) + ((self.0[i] ^ mask) as u128) * (other as u128);
194-
data[i] = sum as u64 & CInt::<B, L>::MASK;
194+
*d = sum as u64 & CInt::<B, L>::MASK;
195195
carry = (sum >> B) as u64;
196196
}
197-
Self::Output { 0: data }
197+
CInt::<B, L>(data)
198198
}
199199
}
200200

src/ff_ext/jacobi.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ impl<const L: usize> Shr<u32> for &LInt<L> {
7474
"Cannot shift by 0 or more than 63 bits!"
7575
);
7676
let (mut data, right) = ([0; L], u64::BITS - bits);
77-
for i in 0..(L - 1) {
78-
data[i] = (self.0[i] >> bits) | (self.0[i + 1] << right);
77+
78+
for (i, d) in data.iter_mut().enumerate().take(L - 1) {
79+
*d = (self.0[i] >> bits) | (self.0[i + 1] << right);
7980
}
8081
data[L - 1] = self.0[L - 1] >> bits;
8182
if self.is_negative() {
8283
data[L - 1] |= u64::MAX << right;
8384
}
84-
Self::Output { 0: data }
85+
LInt::<L>(data)
8586
}
8687
}
8788

@@ -96,10 +97,10 @@ impl<const L: usize> Add for &LInt<L> {
9697
type Output = LInt<L>;
9798
fn add(self, other: Self) -> Self::Output {
9899
let (mut data, mut carry) = ([0; L], false);
99-
for i in 0..L {
100-
(data[i], carry) = Self::Output::sum(self.0[i], other.0[i], carry);
100+
for (i, d) in data.iter_mut().enumerate().take(L) {
101+
(*d, carry) = Self::Output::sum(self.0[i], other.0[i], carry);
101102
}
102-
Self::Output { 0: data }
103+
LInt::<L>(data)
103104
}
104105
}
105106

@@ -128,10 +129,10 @@ impl<const L: usize> Sub for &LInt<L> {
128129
// addition algorithm, where the carry flag is initialized with "true"
129130
// and the chunks of the second argument are bitwise inverted
130131
let (mut data, mut carry) = ([0; L], true);
131-
for i in 0..L {
132-
(data[i], carry) = Self::Output::sum(self.0[i], !other.0[i], carry);
132+
for (i, d) in data.iter_mut().enumerate().take(L) {
133+
(*d, carry) = Self::Output::sum(self.0[i], !other.0[i], carry);
133134
}
134-
Self::Output { 0: data }
135+
LInt::<L>(data)
135136
}
136137
}
137138

@@ -155,10 +156,10 @@ impl<const L: usize> Neg for &LInt<L> {
155156
// For the two's complement code the additive negation is the result
156157
// of adding 1 to the bitwise inverted argument's representation
157158
let (mut data, mut carry) = ([0; L], true);
158-
for i in 0..L {
159-
(data[i], carry) = (!self.0[i]).overflowing_add(carry as u64);
159+
for (i, d) in data.iter_mut().enumerate().take(L) {
160+
(*d, carry) = (!self.0[i]).overflowing_add(carry as u64);
160161
}
161-
Self::Output { 0: data }
162+
LInt::<L>(data)
162163
}
163164
}
164165

@@ -180,7 +181,7 @@ impl<const L: usize> Mul for &LInt<L> {
180181
Self::Output::prodsum(self.0[i], other.0[k], data[i + k], carry);
181182
}
182183
}
183-
Self::Output { 0: data }
184+
LInt::<L>(data)
184185
}
185186
}
186187

@@ -219,11 +220,10 @@ impl<const L: usize> Mul<i64> for &LInt<L> {
219220
} else {
220221
(other as u64, 0, 0)
221222
};
222-
#[allow(clippy::needless_range_loop)]
223-
for i in 0..L {
224-
(data[i], carry) = Self::Output::prodsum(self.0[i] ^ mask, other, 0, carry);
223+
for (i, d) in data.iter_mut().enumerate().take(L) {
224+
(*d, carry) = Self::Output::prodsum(self.0[i] ^ mask, other, 0, carry);
225225
}
226-
Self::Output { 0: data }
226+
LInt::<L>(data)
227227
}
228228
}
229229

src/msm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub fn multiexp_serial<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C], acc: &
102102
let mut buckets: Vec<Bucket<C>> = vec![Bucket::None; 1 << (c - 1)];
103103

104104
for (coeff, base) in coeffs.iter().zip(bases.iter()) {
105-
let coeff = get_booth_index(current_window as usize, c, coeff.as_ref());
105+
let coeff = get_booth_index(current_window, c, coeff.as_ref());
106106
if coeff.is_positive() {
107107
buckets[coeff as usize - 1].add_assign(base);
108108
}
@@ -333,7 +333,7 @@ mod test {
333333
acc = acc.double();
334334
}
335335

336-
let idx = super::get_booth_index(i as usize, window, u.as_ref());
336+
let idx = super::get_booth_index(i, window, u.as_ref());
337337

338338
if idx.is_negative() {
339339
acc += table[idx.unsigned_abs() as usize].neg();

src/pluto_eris/fields/fp12.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ fn test_frobenius() {
643643
let mut b = a;
644644

645645
for _ in 0..i {
646-
a = a.pow_vartime(&[
646+
a = a.pow_vartime([
647647
0x9ffffcd300000001,
648648
0xa2a7e8c30006b945,
649649
0xe4a7a5fe8fadffd6,

src/pluto_eris/fields/fp2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl Field for Fp2 {
381381
};
382382

383383
// Algorithm (not constant time)
384-
let b = self.pow_vartime(&[
384+
let b = self.pow_vartime([
385385
// (p-1)/4 =
386386
// 0x900000000000900004c3800035fdc392a00f29dbd0e499bd10fe69736a29b1ef929e97fa3eb7ff5a8a9fa30c001ae5167ffff34c0000000
387387
0x67ffff34c0000000,
@@ -747,7 +747,7 @@ fn test_frobenius() {
747747
let mut b = a;
748748

749749
for _ in 0..i {
750-
a = a.pow_vartime(&[
750+
a = a.pow_vartime([
751751
0x9ffffcd300000001,
752752
0xa2a7e8c30006b945,
753753
0xe4a7a5fe8fadffd6,

src/pluto_eris/fields/fp6.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ fn test_frobenius() {
762762
let mut b = a;
763763

764764
for _ in 0..i {
765-
a = a.pow_vartime(&[
765+
a = a.pow_vartime([
766766
// p
767767
0x9ffffcd300000001,
768768
0xa2a7e8c30006b945,

src/pluto_eris/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
//! Supporting evidence: https://github.com/daira/pluto-eris
66
//! Field constant derivation: https://github.com/davidnevadoc/ec-constants/tree/main/pluto_eris
77
//! Pairing constants derivation: https://github.com/John-Gong-Math/pluto_eris/blob/main/pluto_pairing.ipynb
8-
9-
// temporarily allow clippy::all to avoid warnings in this module:
10-
#[allow(clippy::all)]
118
mod curve;
129
mod engine;
1310
mod fields;

0 commit comments

Comments
 (0)