Bitcoin Core  21.99.0
P2P Digital Currency
modinv32.h
Go to the documentation of this file.
1 /***********************************************************************
2  * Copyright (c) 2020 Peter Dettman *
3  * Distributed under the MIT software license, see the accompanying *
4  * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
5  **********************************************************************/
6 
7 #ifndef SECP256K1_MODINV32_H
8 #define SECP256K1_MODINV32_H
9 
10 #if defined HAVE_CONFIG_H
11 #include "libsecp256k1-config.h"
12 #endif
13 
14 #include "util.h"
15 
16 /* A signed 30-bit limb representation of integers.
17  *
18  * Its value is sum(v[i] * 2^(30*i), i=0..8). */
19 typedef struct {
20  int32_t v[9];
22 
23 typedef struct {
24  /* The modulus in signed30 notation, must be odd and in [3, 2^256]. */
26 
27  /* modulus^{-1} mod 2^30 */
28  uint32_t modulus_inv30;
30 
31 /* Replace x with its modular inverse mod modinfo->modulus. x must be in range [0, modulus).
32  * If x is zero, the result will be zero as well. If not, the inverse must exist (i.e., the gcd of
33  * x and modulus must be 1). These rules are automatically satisfied if the modulus is prime.
34  *
35  * On output, all of x's limbs will be in [0, 2^30).
36  */
38 
39 /* Same as secp256k1_modinv32_var, but constant time in x (not in the modulus). */
41 
42 #endif /* SECP256K1_MODINV32_H */
secp256k1_modinv32_var
static void secp256k1_modinv32_var(secp256k1_modinv32_signed30 *x, const secp256k1_modinv32_modinfo *modinfo)
util.h
secp256k1_modinv32_modinfo::modulus
secp256k1_modinv32_signed30 modulus
Definition: modinv32.h:25
secp256k1_modinv32_modinfo::modulus_inv30
uint32_t modulus_inv30
Definition: modinv32.h:28
libsecp256k1-config.h
secp256k1_modinv32_modinfo
Definition: modinv32.h:23
secp256k1_modinv32
static void secp256k1_modinv32(secp256k1_modinv32_signed30 *x, const secp256k1_modinv32_modinfo *modinfo)
secp256k1_modinv32_signed30
Definition: modinv32.h:19