mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-23 16:29:26 +00:00
Updates the libsecp256k1 dependency to commit: c0d9480fbbf8eccbd4be23ed27f6f2af6f3b211e PR: ``` BenchmarkSign-24 57756 21214 ns/op 164 B/op 3 allocs/op BenchmarkRecover-24 37156 33044 ns/op 80 B/op 1 allocs/op BenchmarkEcrecoverSignature-24 36889 32935 ns/op 80 B/op 1 allocs/op BenchmarkVerifySignature-24 41163 29207 ns/op 0 B/op 0 allocs/op BenchmarkDecompressPubkey-24 318624 4062 ns/op 304 B/op 6 allocs/op ``` Master: ``` BenchmarkSign-24 34509 35330 ns/op 164 B/op 3 allocs/op BenchmarkRecover-24 25418 47725 ns/op 80 B/op 1 allocs/op BenchmarkEcrecoverSignature-24 25735 47591 ns/op 80 B/op 1 allocs/op BenchmarkVerifySignature-24 29108 41097 ns/op 0 B/op 0 allocs/op BenchmarkDecompressPubkey-24 294747 4143 ns/op 304 B/op 6 allocs/op ``` Performance seems to be improved significantly: ``` Sign-24 34.86µ ± 3% 21.66µ ± 2% -37.86% (p=0.000 n=10) Recover-24 46.14µ ± 3% 33.24µ ± 2% -27.95% (p=0.000 n=10) ```
43 lines
1.8 KiB
C
43 lines
1.8 KiB
C
/***********************************************************************
|
|
* Copyright (c) 2020 Peter Dettman *
|
|
* Distributed under the MIT software license, see the accompanying *
|
|
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
|
**********************************************************************/
|
|
|
|
#ifndef SECP256K1_MODINV32_H
|
|
#define SECP256K1_MODINV32_H
|
|
|
|
#include "util.h"
|
|
|
|
/* A signed 30-bit limb representation of integers.
|
|
*
|
|
* Its value is sum(v[i] * 2^(30*i), i=0..8). */
|
|
typedef struct {
|
|
int32_t v[9];
|
|
} secp256k1_modinv32_signed30;
|
|
|
|
typedef struct {
|
|
/* The modulus in signed30 notation, must be odd and in [3, 2^256]. */
|
|
secp256k1_modinv32_signed30 modulus;
|
|
|
|
/* modulus^{-1} mod 2^30 */
|
|
uint32_t modulus_inv30;
|
|
} secp256k1_modinv32_modinfo;
|
|
|
|
/* Replace x with its modular inverse mod modinfo->modulus. x must be in range [0, modulus).
|
|
* If x is zero, the result will be zero as well. If not, the inverse must exist (i.e., the gcd of
|
|
* x and modulus must be 1). These rules are automatically satisfied if the modulus is prime.
|
|
*
|
|
* On output, all of x's limbs will be in [0, 2^30).
|
|
*/
|
|
static void secp256k1_modinv32_var(secp256k1_modinv32_signed30 *x, const secp256k1_modinv32_modinfo *modinfo);
|
|
|
|
/* Same as secp256k1_modinv32_var, but constant time in x (not in the modulus). */
|
|
static void secp256k1_modinv32(secp256k1_modinv32_signed30 *x, const secp256k1_modinv32_modinfo *modinfo);
|
|
|
|
/* Compute the Jacobi symbol for (x | modinfo->modulus). x must be coprime with modulus (and thus
|
|
* cannot be 0, as modulus >= 3). All limbs of x must be non-negative. Returns 0 if the result
|
|
* cannot be computed. */
|
|
static int secp256k1_jacobi32_maybe_var(const secp256k1_modinv32_signed30 *x, const secp256k1_modinv32_modinfo *modinfo);
|
|
|
|
#endif /* SECP256K1_MODINV32_H */
|