Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/ecmult_const_impl.h
/********************************************************************** | /********************************************************************** | ||||
* Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * | * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * | ||||
* Distributed under the MIT software license, see the accompanying * | * Distributed under the MIT software license, see the accompanying * | ||||
* file COPYING or http://www.opensource.org/licenses/mit-license.php.* | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* | ||||
**********************************************************************/ | **********************************************************************/ | ||||
#ifndef SECP256K1_ECMULT_CONST_IMPL_H | #ifndef SECP256K1_ECMULT_CONST_IMPL_H | ||||
#define SECP256K1_ECMULT_CONST_IMPL_H | #define SECP256K1_ECMULT_CONST_IMPL_H | ||||
#include "scalar.h" | #include "scalar.h" | ||||
#include "group.h" | #include "group.h" | ||||
#include "ecmult_const.h" | #include "ecmult_const.h" | ||||
#include "ecmult_impl.h" | #include "ecmult_impl.h" | ||||
#ifdef USE_ENDOMORPHISM | |||||
#define WNAF_BITS 128 | |||||
#else | |||||
#define WNAF_BITS 256 | |||||
#endif | |||||
#define WNAF_SIZE(w) ((WNAF_BITS + (w) - 1) / (w)) | |||||
/* This is like `ECMULT_TABLE_GET_GE` but is constant time */ | /* This is like `ECMULT_TABLE_GET_GE` but is constant time */ | ||||
#define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ | #define ECMULT_CONST_TABLE_GET_GE(r,pre,n,w) do { \ | ||||
int m; \ | int m; \ | ||||
int abs_n = (n) * (((n) > 0) * 2 - 1); \ | int abs_n = (n) * (((n) > 0) * 2 - 1); \ | ||||
int idx_n = abs_n / 2; \ | int idx_n = abs_n / 2; \ | ||||
secp256k1_fe neg_y; \ | secp256k1_fe neg_y; \ | ||||
VERIFY_CHECK(((n) & 1) == 1); \ | VERIFY_CHECK(((n) & 1) == 1); \ | ||||
VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ | VERIFY_CHECK((n) >= -((1 << ((w)-1)) - 1)); \ | ||||
▲ Show 20 Lines • Show All 211 Lines • Show Last 20 Lines |