From a5f21de0beade0f5b966b33151e7f3616e78b4d9 Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Mon, 1 Nov 2021 17:52:52 -0700 Subject: [PATCH] fixed curve_summation tests --- src/curve/secp256k1_curve.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/curve/secp256k1_curve.rs b/src/curve/secp256k1_curve.rs index 89497a7d..1e721640 100644 --- a/src/curve/secp256k1_curve.rs +++ b/src/curve/secp256k1_curve.rs @@ -39,6 +39,8 @@ const SECP256K1_GENERATOR_Y: Secp256K1Base = Secp256K1Base([ #[cfg(test)] mod tests { + use num::BigUint; + use crate::curve::curve_types::{Curve, ProjectivePoint}; use crate::curve::secp256k1_curve::Secp256K1; use crate::field::field_types::Field; @@ -52,7 +54,7 @@ mod tests { p.double(), p.to_projective().double().to_affine()); } - } + }*/ #[test] fn test_naive_multiplication() { @@ -65,7 +67,9 @@ mod tests { #[test] fn test_g1_multiplication() { - let lhs = Secp256K1Scalar::from_canonical([11111111, 22222222, 33333333, 44444444]); + let lhs = Secp256K1Scalar::from_biguint( + BigUint::from_slice(&[1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888]) + ); assert_eq!(Secp256K1::convert(lhs) * Secp256K1::GENERATOR_PROJECTIVE, mul_naive(lhs, Secp256K1::GENERATOR_PROJECTIVE)); } @@ -74,7 +78,7 @@ mod tests { fn mul_naive(lhs: Secp256K1Scalar, rhs: ProjectivePoint) -> ProjectivePoint { let mut g = rhs; let mut sum = ProjectivePoint::ZERO; - for limb in lhs.to_canonical().iter() { + for limb in lhs.to_biguint().to_u64_digits().iter() { for j in 0..64 { if (limb >> j & 1u64) != 0u64 { sum = sum + g; @@ -83,5 +87,5 @@ mod tests { } } sum - }*/ + } }