Skip to content

Commit b19c000

Browse files
committed
Merge dashpay#607: Use size_t shifts when computing a size_t
e6d01e9 Use size_t shifts when computing a size_t (Pieter Wuille) Pull request description: This was detected by compiling with MSVC; it triggers warning C4334. I don't think this is necessary, as we know the maximum shift is a very small integer, but this makes the code more obviously correct. Tree-SHA512: 3c0cf412c75b4361d01e78bf13fe81c3f28b82abd40b0706285cc691124381cb1ff1f1c3512420250180b7612a471ce48357b282b1e34a08f5359e58af25e198
2 parents 4d01bc2 + e6d01e9 commit b19c000

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ecmult_impl.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ static size_t secp256k1_pippenger_scratch_size(size_t n_points, int bucket_windo
960960
size_t entries = n_points + 1;
961961
#endif
962962
size_t entry_size = sizeof(secp256k1_ge) + sizeof(secp256k1_scalar) + sizeof(struct secp256k1_pippenger_point_state) + (WNAF_SIZE(bucket_window+1)+1)*sizeof(int);
963-
return ((1<<bucket_window) * sizeof(secp256k1_gej) + sizeof(struct secp256k1_pippenger_state) + entries * entry_size);
963+
return (sizeof(secp256k1_gej) << bucket_window) + sizeof(struct secp256k1_pippenger_state) + entries * entry_size;
964964
}
965965

966966
static int secp256k1_ecmult_pippenger_batch(const secp256k1_ecmult_context *ctx, secp256k1_scratch *scratch, secp256k1_gej *r, const secp256k1_scalar *inp_g_sc, secp256k1_ecmult_multi_callback cb, void *cbdata, size_t n_points, size_t cb_offset) {
@@ -996,7 +996,7 @@ static int secp256k1_ecmult_pippenger_batch(const secp256k1_ecmult_context *ctx,
996996
state_space = (struct secp256k1_pippenger_state *) secp256k1_scratch_alloc(scratch, sizeof(*state_space));
997997
state_space->ps = (struct secp256k1_pippenger_point_state *) secp256k1_scratch_alloc(scratch, entries * sizeof(*state_space->ps));
998998
state_space->wnaf_na = (int *) secp256k1_scratch_alloc(scratch, entries*(WNAF_SIZE(bucket_window+1)) * sizeof(int));
999-
buckets = (secp256k1_gej *) secp256k1_scratch_alloc(scratch, (1<<bucket_window) * sizeof(*buckets));
999+
buckets = (secp256k1_gej *) secp256k1_scratch_alloc(scratch, sizeof(*buckets) << bucket_window);
10001000

10011001
if (inp_g_sc != NULL) {
10021002
scalars[0] = *inp_g_sc;
@@ -1063,7 +1063,7 @@ static size_t secp256k1_pippenger_max_points(secp256k1_scratch *scratch) {
10631063
#ifdef USE_ENDOMORPHISM
10641064
entry_size = 2*entry_size;
10651065
#endif
1066-
space_overhead = ((1<<bucket_window) * sizeof(secp256k1_gej) + entry_size + sizeof(struct secp256k1_pippenger_state));
1066+
space_overhead = (sizeof(secp256k1_gej) << bucket_window) + entry_size + sizeof(struct secp256k1_pippenger_state);
10671067
if (space_overhead > max_alloc) {
10681068
break;
10691069
}

0 commit comments

Comments
 (0)