From 1605d14c7f4fe68dfdb1592ba5f119fc1ccd116c Mon Sep 17 00:00:00 2001 From: Joey Yandle Date: Thu, 10 Oct 2024 00:18:04 -0400 Subject: [PATCH] use fe_impl_set_b32_limit so we know if a value is out of range --- p256k1/src/_rename.rs | 4 ++-- p256k1/src/bindings.rs | 2 +- p256k1/src/point.rs | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/p256k1/src/_rename.rs b/p256k1/src/_rename.rs index 702c5da..6b0cc3b 100644 --- a/p256k1/src/_rename.rs +++ b/p256k1/src/_rename.rs @@ -41,8 +41,8 @@ pub use crate::bindings::{ s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_add as secp256k1_fe_add, s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_cmp_var as secp256k1_fe_cmp_var, s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_get_b32 as secp256k1_fe_get_b32, - s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_set_b32_mod as secp256k1_fe_set_b32, - s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_set_b32_limit as secp256k1_fe_set_b32_limit, + s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_set_b32_mod as secp256k1_fe_set_b32_mod, + s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_set_b32_limit as secp256k1_fe_set_b32, s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_inv as secp256k1_fe_inv, s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_is_odd as secp256k1_fe_is_odd, s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_mul as secp256k1_fe_mul, diff --git a/p256k1/src/bindings.rs b/p256k1/src/bindings.rs index 982394e..b5714cb 100644 --- a/p256k1/src/bindings.rs +++ b/p256k1/src/bindings.rs @@ -8396,7 +8396,7 @@ extern "C" { pub fn s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_set_b32_limit( r: *mut secp256k1_fe, a: *const ::std::os::raw::c_uchar, - ); + ) -> ::std::os::raw::c_int; } extern "C" { pub fn s642c885b6102725e25623738529895a95addc4f4_secp256k1_fe_impl_get_b32( diff --git a/p256k1/src/point.rs b/p256k1/src/point.rs index aab7154..4740548 100644 --- a/p256k1/src/point.rs +++ b/p256k1/src/point.rs @@ -476,12 +476,10 @@ impl TryFrom<&Compressed> for Point { let mut x = secp256k1_fe { n: [0; 5] }; - // XXX this is not ideal, since we should only load without rollover - secp256k1_fe_set_b32(&mut x, &c.data[1]); - /*let rx = secp256k1_fe_set_b32(&mut x, &c.data[1]); + let rx = secp256k1_fe_set_b32(&mut x, &c.data[1]); if rx == 0 { return Err(Error::Conversion(ConversionError::BadFieldElement)); - }*/ + } let ry = secp256k1_ge_set_xo_var( &mut y,