When use secp256k1_fe_normalize(_weak) ? #1375
-
Hello, Thanks to your library, I've recoded how elliptical addition works. I use the following functions:
Could you please help me? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Objects of type The functions that operate on field elements also operate on these two values. See the docs in Lines 270 to 277 in cc55757 As a user of these functions, it's your responsibility to adhere to the pre-conditions (e.g., "The magnitude of a must not exceed 8."), and then you are guaranteed the post-conditions (e.g., "On output, r will have magnitude 1, but won't be normalized."). When you have a secp256k1_fe that doesn't adhere to the pre-conditions of a function that you would like to call, you can call secp256k1_fe_normalize_weak first to change the magnitude to 1, or call secp256k1_fe_normalize first to additionally ensure that the secp256k1_fe is normalized.
In the tests (when |
Beta Was this translation helpful? Give feedback.
Objects of type
secp256k1_fe
implicitly carry a magnitude (an integer in [0, 32]), and whether they are normalized (a boolean). If asecp256k1_fe
is normalized, it is implied that its magnitude <= 1. These two values are not explicitly present materialized as fields of thesecp256k1_fe
struct, but they need to be tracked implicitly (unless in the tests when theVERIFY
macro is defined).The functions that operate on field elements also operate on these two values. See the docs in
src/field.h
, e.g., forsecp256k1_fe_sqr
:secp256k1/src/field.h
Lines 270 to 277 in cc55757