ecmult_gen.h (1888B)
1 /*********************************************************************** 2 * Copyright (c) 2013, 2014 Pieter Wuille * 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_ECMULT_GEN_H 8 #define SECP256K1_ECMULT_GEN_H 9 10 #include "scalar.h" 11 #include "group.h" 12 13 #ifndef ECMULT_GEN_PREC_BITS 14 # define ECMULT_GEN_PREC_BITS 4 15 # ifdef DEBUG_CONFIG 16 # pragma message DEBUG_CONFIG_MSG("ECMULT_GEN_PREC_BITS undefined, assuming default value") 17 # endif 18 #endif 19 20 #ifdef DEBUG_CONFIG 21 # pragma message DEBUG_CONFIG_DEF(ECMULT_GEN_PREC_BITS) 22 #endif 23 24 #if ECMULT_GEN_PREC_BITS != 2 && ECMULT_GEN_PREC_BITS != 4 && ECMULT_GEN_PREC_BITS != 8 25 # error "Set ECMULT_GEN_PREC_BITS to 2, 4 or 8." 26 #endif 27 28 #define ECMULT_GEN_PREC_G(bits) (1 << bits) 29 #define ECMULT_GEN_PREC_N(bits) (256 / bits) 30 31 typedef struct { 32 /* Whether the context has been built. */ 33 int built; 34 35 /* Blinding values used when computing (n-b)G + bG. */ 36 haskellsecp256k1_v0_1_0_scalar blind; /* -b */ 37 haskellsecp256k1_v0_1_0_gej initial; /* bG */ 38 } haskellsecp256k1_v0_1_0_ecmult_gen_context; 39 40 static void haskellsecp256k1_v0_1_0_ecmult_gen_context_build(haskellsecp256k1_v0_1_0_ecmult_gen_context* ctx); 41 static void haskellsecp256k1_v0_1_0_ecmult_gen_context_clear(haskellsecp256k1_v0_1_0_ecmult_gen_context* ctx); 42 43 /** Multiply with the generator: R = a*G */ 44 static void haskellsecp256k1_v0_1_0_ecmult_gen(const haskellsecp256k1_v0_1_0_ecmult_gen_context* ctx, haskellsecp256k1_v0_1_0_gej *r, const haskellsecp256k1_v0_1_0_scalar *a); 45 46 static void haskellsecp256k1_v0_1_0_ecmult_gen_blind(haskellsecp256k1_v0_1_0_ecmult_gen_context *ctx, const unsigned char *seed32); 47 48 #endif /* SECP256K1_ECMULT_GEN_H */