Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/scalar_8x32_impl.h
/********************************************************************** | /********************************************************************** | ||||
* Copyright (c) 2014 Pieter Wuille * | * Copyright (c) 2014 Pieter Wuille * | ||||
* 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_SCALAR_REPR_IMPL_H_ | #ifndef SECP256K1_SCALAR_REPR_IMPL_H | ||||
#define _SECP256K1_SCALAR_REPR_IMPL_H_ | #define SECP256K1_SCALAR_REPR_IMPL_H | ||||
/* Limbs of the secp256k1 order. */ | /* Limbs of the secp256k1 order. */ | ||||
#define SECP256K1_N_0 ((uint32_t)0xD0364141UL) | #define SECP256K1_N_0 ((uint32_t)0xD0364141UL) | ||||
#define SECP256K1_N_1 ((uint32_t)0xBFD25E8CUL) | #define SECP256K1_N_1 ((uint32_t)0xBFD25E8CUL) | ||||
#define SECP256K1_N_2 ((uint32_t)0xAF48A03BUL) | #define SECP256K1_N_2 ((uint32_t)0xAF48A03BUL) | ||||
#define SECP256K1_N_3 ((uint32_t)0xBAAEDCE6UL) | #define SECP256K1_N_3 ((uint32_t)0xBAAEDCE6UL) | ||||
#define SECP256K1_N_4 ((uint32_t)0xFFFFFFFEUL) | #define SECP256K1_N_4 ((uint32_t)0xFFFFFFFEUL) | ||||
#define SECP256K1_N_5 ((uint32_t)0xFFFFFFFFUL) | #define SECP256K1_N_5 ((uint32_t)0xFFFFFFFFUL) | ||||
▲ Show 20 Lines • Show All 696 Lines • ▼ Show 20 Lines | SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_scalar *a, const secp256k1_scalar *b, unsigned int shift) { | ||||
r->d[3] = shift < 416 ? (l[3 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[4 + shiftlimbs] << shifthigh) : 0)) : 0; | r->d[3] = shift < 416 ? (l[3 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[4 + shiftlimbs] << shifthigh) : 0)) : 0; | ||||
r->d[4] = shift < 384 ? (l[4 + shiftlimbs] >> shiftlow | (shift < 352 && shiftlow ? (l[5 + shiftlimbs] << shifthigh) : 0)) : 0; | r->d[4] = shift < 384 ? (l[4 + shiftlimbs] >> shiftlow | (shift < 352 && shiftlow ? (l[5 + shiftlimbs] << shifthigh) : 0)) : 0; | ||||
r->d[5] = shift < 352 ? (l[5 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[6 + shiftlimbs] << shifthigh) : 0)) : 0; | r->d[5] = shift < 352 ? (l[5 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[6 + shiftlimbs] << shifthigh) : 0)) : 0; | ||||
r->d[6] = shift < 320 ? (l[6 + shiftlimbs] >> shiftlow | (shift < 288 && shiftlow ? (l[7 + shiftlimbs] << shifthigh) : 0)) : 0; | r->d[6] = shift < 320 ? (l[6 + shiftlimbs] >> shiftlow | (shift < 288 && shiftlow ? (l[7 + shiftlimbs] << shifthigh) : 0)) : 0; | ||||
r->d[7] = shift < 288 ? (l[7 + shiftlimbs] >> shiftlow) : 0; | r->d[7] = shift < 288 ? (l[7 + shiftlimbs] >> shiftlow) : 0; | ||||
secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 5] >> ((shift - 1) & 0x1f)) & 1); | secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 5] >> ((shift - 1) & 0x1f)) & 1); | ||||
} | } | ||||
#endif | #endif /* SECP256K1_SCALAR_REPR_IMPL_H */ |