Skip to content

Commit

Permalink
fmt and remove unneeded test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Feb 21, 2024
1 parent 76d2d6a commit 27abd27
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 75 deletions.
35 changes: 8 additions & 27 deletions math/src/gpu/icicle/bls12_377.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ impl ShortWeierstrassProjectivePoint<BLS12377Curve> {
}
}


fn from_icicle(icicle: &curve::G1Projective) -> Result<Self, ByteConversionError> {
Ok(Self::new([
FieldElement::<BLS12377PrimeField>::from_icicle(&icicle.x).unwrap(),
Expand Down Expand Up @@ -89,14 +88,14 @@ mod test {
use super::*;
use crate::{
elliptic_curve::{
short_weierstrass::curves::bls12_377::curve::BLS12377FieldElement, traits::IsEllipticCurve,
short_weierstrass::curves::bls12_377::curve::BLS12377FieldElement,
traits::IsEllipticCurve,
},
field::element::FieldElement,
msm::pippenger::msm,
};

impl ShortWeierstrassProjectivePoint<BLS12377Curve> {

fn from_icicle_affine(
icicle: &curve::G1Affine,
) -> Result<ShortWeierstrassProjectivePoint<BLS12377Curve>, ByteConversionError> {
Expand All @@ -123,8 +122,9 @@ mod test {
// convert value of 5 to icicle and back again and that icicle 5 matches
let point = point_times_5();
let icicle_point = point.to_icicle();
let res = ShortWeierstrassProjectivePoint::<BLS12377Curve>::from_icicle_affine(&icicle_point)
.unwrap();
let res =
ShortWeierstrassProjectivePoint::<BLS12377Curve>::from_icicle_affine(&icicle_point)
.unwrap();
assert_eq!(point, res)
}

Expand All @@ -133,8 +133,9 @@ mod test {
// Convert generator and see that it matches
let point = BLS12377Curve::generator();
let icicle_point = point.to_icicle();
let res = ShortWeierstrassProjectivePoint::<BLS12377Curve>::from_icicle_affine(&icicle_point)
.unwrap();
let res =
ShortWeierstrassProjectivePoint::<BLS12377Curve>::from_icicle_affine(&icicle_point)
.unwrap();
assert_eq!(point, res)
}

Expand All @@ -156,24 +157,4 @@ mod test {
let res = bls12_377_g1_msm(&lambda_scalars, &lambda_points, None).unwrap();
assert_eq!(res, expected);
}

/*
#[test]
fn icicle_1_ntt() {
const len: usize = 20;
let eight: BLS12377FieldElement = FieldElement::from(8);
let lambda_scalars = &vec![eight; len];
let expected = Polynomial::evaluate_fft::<BLS12377PrimeField>(
&Polynomial::new(lambda_scalars), 1, None,
).unwrap();
let icicle_scalars = lambda_scalars.as_slice().iter()
.map(|scalar| scalar.to_icicle_scalar())
.collect::<Vec<_>>();
println!("expected {:?}", expected);
let res = bls12_381_g1_ntt(&lambda_scalars, None, 4u64, false).unwrap();
println!();
println!("res {:?}", res);
assert_eq!(res, expected);
}
*/
}
35 changes: 8 additions & 27 deletions math/src/gpu/icicle/bls12_381.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ mod test {
use super::*;
use crate::{
elliptic_curve::{
short_weierstrass::curves::bls12_381::curve::BLS12381FieldElement, traits::IsEllipticCurve,
short_weierstrass::curves::bls12_381::curve::BLS12381FieldElement,
traits::IsEllipticCurve,
},
field::element::FieldElement,
msm::pippenger::msm,
};


impl ShortWeierstrassProjectivePoint<BLS12381Curve> {
fn from_icicle_affine(
icicle: &curve::G1Affine,
Expand All @@ -107,7 +107,6 @@ mod test {
}
}


fn point_times_5() -> ShortWeierstrassProjectivePoint<BLS12381Curve> {
let x = BLS12381FieldElement::from_hex_unchecked(
"32bcce7e71eb50384918e0c9809f73bde357027c6bf15092dd849aa0eac274d43af4c68a65fb2cda381734af5eecd5c",
Expand All @@ -123,8 +122,9 @@ mod test {
// convert value of 5 to icicle and back again and that icicle 5 matches
let point = point_times_5();
let icicle_point = point.to_icicle();
let res = ShortWeierstrassProjectivePoint::<BLS12381Curve>::from_icicle_affine(&icicle_point)
.unwrap();
let res =
ShortWeierstrassProjectivePoint::<BLS12381Curve>::from_icicle_affine(&icicle_point)
.unwrap();
assert_eq!(point, res)
}

Expand All @@ -133,8 +133,9 @@ mod test {
// Convert generator and see that it matches
let point = BLS12381Curve::generator();
let icicle_point = point.to_icicle();
let res = ShortWeierstrassProjectivePoint::<BLS12381Curve>::from_icicle_affine(&icicle_point)
.unwrap();
let res =
ShortWeierstrassProjectivePoint::<BLS12381Curve>::from_icicle_affine(&icicle_point)
.unwrap();
assert_eq!(point, res)
}

Expand All @@ -156,24 +157,4 @@ mod test {
let res = bls12_381_g1_msm(&lambda_scalars, &lambda_points, None).unwrap();
assert_eq!(res, expected);
}

/*
#[test]
fn icicle_1_ntt() {
const len: usize = 20;
let eight: BLS12381FieldElement = FieldElement::from(8);
let lambda_scalars = &vec![eight; len];
let expected = Polynomial::evaluate_fft::<BLS12381PrimeField>(
&Polynomial::new(lambda_scalars), 1, None,
).unwrap();
let icicle_scalars = lambda_scalars.as_slice().iter()
.map(|scalar| scalar.to_icicle_scalar())
.collect::<Vec<_>>();
println!("expected {:?}", expected);
let res = bls12_381_g1_ntt(&lambda_scalars, None, 4u64, false).unwrap();
println!();
println!("res {:?}", res);
assert_eq!(res, expected);
}
*/
}
21 changes: 0 additions & 21 deletions math/src/gpu/icicle/bn254.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ mod test {
msm::pippenger::msm,
};


impl ShortWeierstrassProjectivePoint<BN254Curve> {
fn from_icicle_affine(
icicle: &curve::G1Affine,
Expand Down Expand Up @@ -155,24 +154,4 @@ mod test {
let res = bn254_g1_msm(&lambda_scalars, &lambda_points, None).unwrap();
assert_eq!(res, expected);
}

/*
#[test]
fn icicle_1_ntt() {
const len: usize = 20;
let eight: BN254FieldElement = FieldElement::from(8);
let lambda_scalars = &vec![eight; len];
let expected = Polynomial::evaluate_fft::<BN254PrimeField>(
&Polynomial::new(lambda_scalars), 1, None,
).unwrap();
let icicle_scalars = lambda_scalars.as_slice().iter()
.map(|scalar| scalar.to_icicle_scalar())
.collect::<Vec<_>>();
println!("expected {:?}", expected);
let res = bn254_g1_ntt(&lambda_scalars, None, 4u64, false).unwrap();
println!();
println!("res {:?}", res);
assert_eq!(res, expected);
}
*/
}

0 comments on commit 27abd27

Please sign in to comment.