Skip to content

Commit 0948ae2

Browse files
committed
rename type
1 parent cd639fc commit 0948ae2

File tree

3 files changed

+158
-153
lines changed

3 files changed

+158
-153
lines changed

ec/src/scalar_mul/variable_base/mod.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub mod stream_pippenger;
1616
pub use stream_pippenger::*;
1717

1818
use super::ScalarMul;
19-
use ark_ff::biginteger::{U128OrI128, U64OrI64};
19+
use ark_ff::biginteger::{U128AndSign, U64AndSign};
2020

2121
#[cfg(all(
2222
target_has_atomic = "8",
@@ -648,7 +648,7 @@ pub fn msm_u128<V: VariableBaseMSM>(
648648
/// MSM over mixed-signed 64-bit integers using the small-scalar engine.
649649
pub fn msm_u64_or_i64<V: VariableBaseMSM>(
650650
mut bases: &[V::MulBase],
651-
mut scalars: &[U64OrI64],
651+
mut scalars: &[U64AndSign],
652652
serial: bool,
653653
) -> V {
654654
// Partition by sign for better locality; build magnitudes as u64.
@@ -663,15 +663,10 @@ pub fn msm_u64_or_i64<V: VariableBaseMSM>(
663663
});
664664
let (negative_scalars, non_negative_scalars): (Vec<u64>, Vec<u64>) = scalars
665665
.iter()
666-
.partition_map(|s| match *s {
667-
U64OrI64::Unsigned(u) => Either::Right(u),
668-
U64OrI64::Signed(v) => {
669-
if v < 0 {
670-
Either::Left(v.unsigned_abs())
671-
} else {
672-
Either::Right(v as u64)
673-
}
674-
}
666+
.partition_map(|s| if s.is_negative() {
667+
Either::Left(s.magnitude)
668+
} else {
669+
Either::Right(s.magnitude)
675670
});
676671

677672
if serial {
@@ -698,30 +693,24 @@ pub fn msm_u64_or_i64<V: VariableBaseMSM>(
698693
/// MSM over mixed-signed 128-bit integers.
699694
pub fn msm_u128_or_i128<V: VariableBaseMSM>(
700695
mut bases: &[V::MulBase],
701-
mut scalars: &[U128OrI128],
696+
mut scalars: &[U128AndSign],
702697
serial: bool,
703698
) -> V {
704699
// u128 path with sign partitioning.
705700
let (negative_bases, non_negative_bases): (Vec<V::MulBase>, Vec<V::MulBase>) = bases
706701
.iter()
707702
.enumerate()
708-
.partition_map(|(i, b)| if match scalars[i] { U128OrI128::Signed(v) if v < 0 => true, _ => false } {
703+
.partition_map(|(i, b)| if scalars[i].is_negative() {
709704
Either::Left(b)
710705
} else {
711706
Either::Right(b)
712707
});
713708
let (negative_scalars, non_negative_scalars): (Vec<u128>, Vec<u128>) = scalars
714709
.iter()
715-
.partition_map(|s| match *s {
716-
U128OrI128::Unsigned(u) => Either::Right(u),
717-
U128OrI128::Signed(v) => {
718-
let abs = v.unsigned_abs();
719-
if v < 0 {
720-
Either::Left(abs)
721-
} else {
722-
Either::Right(abs)
723-
}
724-
}
710+
.partition_map(|s| if s.is_negative() {
711+
Either::Left(s.magnitude)
712+
} else {
713+
Either::Right(s.magnitude)
725714
});
726715

727716
if serial {

ff/src/biginteger/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use zeroize::Zeroize;
3030
pub mod arithmetic;
3131

3232
pub mod types;
33-
pub use types::{U128OrI128, U64OrI64};
33+
pub use types::{U128AndSign, U64AndSign};
3434

3535
#[derive(Copy, Clone, PartialEq, Eq, Hash, Zeroize)]
3636
pub struct BigInt<const N: usize>(pub [u64; N]);

0 commit comments

Comments
 (0)