Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/scalar_4x64_impl.h
Show First 20 Lines • Show All 942 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[1] = shift < 448 ? (l[1 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[2 + shiftlimbs] << shifthigh) : 0)) : 0; | r->d[1] = shift < 448 ? (l[1 + shiftlimbs] >> shiftlow | (shift < 384 && shiftlow ? (l[2 + shiftlimbs] << shifthigh) : 0)) : 0; | ||||
r->d[2] = shift < 384 ? (l[2 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[3 + shiftlimbs] << shifthigh) : 0)) : 0; | r->d[2] = shift < 384 ? (l[2 + shiftlimbs] >> shiftlow | (shift < 320 && shiftlow ? (l[3 + shiftlimbs] << shifthigh) : 0)) : 0; | ||||
r->d[3] = shift < 320 ? (l[3 + shiftlimbs] >> shiftlow) : 0; | r->d[3] = shift < 320 ? (l[3 + shiftlimbs] >> shiftlow) : 0; | ||||
secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 6] >> ((shift - 1) & 0x3f)) & 1); | secp256k1_scalar_cadd_bit(r, 0, (l[(shift - 1) >> 6] >> ((shift - 1) & 0x3f)) & 1); | ||||
} | } | ||||
static SECP256K1_INLINE void secp256k1_scalar_cmov(secp256k1_scalar *r, const secp256k1_scalar *a, int flag) { | static SECP256K1_INLINE void secp256k1_scalar_cmov(secp256k1_scalar *r, const secp256k1_scalar *a, int flag) { | ||||
uint64_t mask0, mask1; | uint64_t mask0, mask1; | ||||
VG_CHECK_VERIFY(r->d, sizeof(r->d)); | |||||
mask0 = flag + ~((uint64_t)0); | mask0 = flag + ~((uint64_t)0); | ||||
mask1 = ~mask0; | mask1 = ~mask0; | ||||
r->d[0] = (r->d[0] & mask0) | (a->d[0] & mask1); | r->d[0] = (r->d[0] & mask0) | (a->d[0] & mask1); | ||||
r->d[1] = (r->d[1] & mask0) | (a->d[1] & mask1); | r->d[1] = (r->d[1] & mask0) | (a->d[1] & mask1); | ||||
r->d[2] = (r->d[2] & mask0) | (a->d[2] & mask1); | r->d[2] = (r->d[2] & mask0) | (a->d[2] & mask1); | ||||
r->d[3] = (r->d[3] & mask0) | (a->d[3] & mask1); | r->d[3] = (r->d[3] & mask0) | (a->d[3] & mask1); | ||||
} | } | ||||
#endif /* SECP256K1_SCALAR_REPR_IMPL_H */ | #endif /* SECP256K1_SCALAR_REPR_IMPL_H */ |