2020-12-17 08:33:49 +02:00
|
|
|
/***********************************************************************
|
2022-12-30 12:13:46 -05:00
|
|
|
* Copyright (c) 2015, 2022 Andrew Poelstra, Pieter Wuille *
|
2020-12-17 08:33:49 +02:00
|
|
|
* Distributed under the MIT software license, see the accompanying *
|
|
|
|
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
|
|
|
***********************************************************************/
|
2016-07-07 10:11:30 +00:00
|
|
|
|
2017-08-26 18:44:21 +03:00
|
|
|
#ifndef SECP256K1_SCALAR_REPR_H
|
|
|
|
#define SECP256K1_SCALAR_REPR_H
|
2016-07-07 10:11:30 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/** A scalar modulo the group order of the secp256k1 curve. */
|
|
|
|
typedef uint32_t secp256k1_scalar;
|
|
|
|
|
2022-12-30 12:13:46 -05:00
|
|
|
/* A compile-time constant equal to 2^32 (modulo order). */
|
|
|
|
#define SCALAR_2P32 ((0xffffffffUL % EXHAUSTIVE_TEST_ORDER) + 1U)
|
|
|
|
|
|
|
|
/* Compute a*2^32 + b (modulo order). */
|
|
|
|
#define SCALAR_HORNER(a, b) (((uint64_t)(a) * SCALAR_2P32 + (b)) % EXHAUSTIVE_TEST_ORDER)
|
|
|
|
|
|
|
|
/* Evaluates to the provided 256-bit constant reduced modulo order. */
|
|
|
|
#define SECP256K1_SCALAR_CONST(d7, d6, d5, d4, d3, d2, d1, d0) SCALAR_HORNER(SCALAR_HORNER(SCALAR_HORNER(SCALAR_HORNER(SCALAR_HORNER(SCALAR_HORNER(SCALAR_HORNER((d7), (d6)), (d5)), (d4)), (d3)), (d2)), (d1)), (d0))
|
2020-01-11 01:01:05 +00:00
|
|
|
|
2017-08-26 18:44:21 +03:00
|
|
|
#endif /* SECP256K1_SCALAR_REPR_H */
|