Skip to content

Commit

Permalink
Merge pull request bitcoin#133
Browse files Browse the repository at this point in the history
9048def Avoid undefined shift behaviour (Pieter Wuille)
  • Loading branch information
sipa committed Dec 3, 2014
2 parents d220062 + 9048def commit 0bf70a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/scalar_4x64_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void secp256k1_scalar_add(secp256k1_scalar_t *r, const secp256k1_scalar_t

static void secp256k1_scalar_add_bit(secp256k1_scalar_t *r, unsigned int bit) {
VERIFY_CHECK(bit < 256);
uint128_t t = (uint128_t)r->d[0] + (((uint64_t)((bit >> 6) == 0)) << bit);
uint128_t t = (uint128_t)r->d[0] + (((uint64_t)((bit >> 6) == 0)) << (bit & 0x3F));
r->d[0] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64;
t += (uint128_t)r->d[1] + (((uint64_t)((bit >> 6) == 1)) << (bit & 0x3F));
r->d[1] = t & 0xFFFFFFFFFFFFFFFFULL; t >>= 64;
Expand Down
2 changes: 1 addition & 1 deletion src/scalar_8x32_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void secp256k1_scalar_add(secp256k1_scalar_t *r, const secp256k1_scalar_t

static void secp256k1_scalar_add_bit(secp256k1_scalar_t *r, unsigned int bit) {
VERIFY_CHECK(bit < 256);
uint64_t t = (uint64_t)r->d[0] + (((uint32_t)((bit >> 5) == 0)) << bit);
uint64_t t = (uint64_t)r->d[0] + (((uint32_t)((bit >> 5) == 0)) << (bit & 0x1F));
r->d[0] = t & 0xFFFFFFFFULL; t >>= 32;
t += (uint64_t)r->d[1] + (((uint32_t)((bit >> 5) == 1)) << (bit & 0x1F));
r->d[1] = t & 0xFFFFFFFFULL; t >>= 32;
Expand Down

0 comments on commit 0bf70a5

Please sign in to comment.