2020-12-29 17:15:51 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* Copyright (c) 2013, 2014 Pieter Wuille *
|
|
|
|
* Distributed under the MIT software license, see the accompanying *
|
|
|
|
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
|
|
|
|
***********************************************************************/
|
2015-10-26 14:54:21 +00:00
|
|
|
|
2018-07-09 11:17:44 +00:00
|
|
|
#ifndef SECP256K1_ECMULT_GEN_H
|
|
|
|
#define SECP256K1_ECMULT_GEN_H
|
2015-10-26 14:54:21 +00:00
|
|
|
|
|
|
|
#include "scalar.h"
|
|
|
|
#include "group.h"
|
|
|
|
|
2022-12-20 21:11:14 +00:00
|
|
|
#ifndef ECMULT_GEN_PREC_BITS
|
|
|
|
# define ECMULT_GEN_PREC_BITS 4
|
|
|
|
# ifdef DEBUG_CONFIG
|
|
|
|
# pragma message DEBUG_CONFIG_MSG("ECMULT_GEN_PREC_BITS undefined, assuming default value")
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG_CONFIG
|
|
|
|
# pragma message DEBUG_CONFIG_DEF(ECMULT_GEN_PREC_BITS)
|
|
|
|
#endif
|
|
|
|
|
2020-08-26 17:35:27 +00:00
|
|
|
#if ECMULT_GEN_PREC_BITS != 2 && ECMULT_GEN_PREC_BITS != 4 && ECMULT_GEN_PREC_BITS != 8
|
|
|
|
# error "Set ECMULT_GEN_PREC_BITS to 2, 4 or 8."
|
|
|
|
#endif
|
2022-12-20 21:11:14 +00:00
|
|
|
|
2022-03-08 19:45:41 +00:00
|
|
|
#define ECMULT_GEN_PREC_G(bits) (1 << bits)
|
|
|
|
#define ECMULT_GEN_PREC_N(bits) (256 / bits)
|
2020-08-26 17:35:27 +00:00
|
|
|
|
2015-10-26 14:54:21 +00:00
|
|
|
typedef struct {
|
2022-03-08 19:45:41 +00:00
|
|
|
/* Whether the context has been built. */
|
|
|
|
int built;
|
|
|
|
|
|
|
|
/* Blinding values used when computing (n-b)G + bG. */
|
2024-01-02 16:22:20 +00:00
|
|
|
rustsecp256k1_v0_9_2_scalar blind; /* -b */
|
|
|
|
rustsecp256k1_v0_9_2_gej initial; /* bG */
|
|
|
|
} rustsecp256k1_v0_9_2_ecmult_gen_context;
|
2022-03-08 19:45:41 +00:00
|
|
|
|
2024-01-02 16:22:20 +00:00
|
|
|
static void rustsecp256k1_v0_9_2_ecmult_gen_context_build(rustsecp256k1_v0_9_2_ecmult_gen_context* ctx);
|
|
|
|
static void rustsecp256k1_v0_9_2_ecmult_gen_context_clear(rustsecp256k1_v0_9_2_ecmult_gen_context* ctx);
|
2015-10-26 14:54:21 +00:00
|
|
|
|
|
|
|
/** Multiply with the generator: R = a*G */
|
2024-01-02 16:22:20 +00:00
|
|
|
static void rustsecp256k1_v0_9_2_ecmult_gen(const rustsecp256k1_v0_9_2_ecmult_gen_context* ctx, rustsecp256k1_v0_9_2_gej *r, const rustsecp256k1_v0_9_2_scalar *a);
|
2015-10-26 14:54:21 +00:00
|
|
|
|
2024-01-02 16:22:20 +00:00
|
|
|
static void rustsecp256k1_v0_9_2_ecmult_gen_blind(rustsecp256k1_v0_9_2_ecmult_gen_context *ctx, const unsigned char *seed32);
|
2015-10-26 14:54:21 +00:00
|
|
|
|
2018-07-09 11:17:44 +00:00
|
|
|
#endif /* SECP256K1_ECMULT_GEN_H */
|