Skip to content

Commit 3c1561f

Browse files
SHELL Teamcopybara-github
authored andcommitted
No public description
PiperOrigin-RevId: 888846457
1 parent fcbd938 commit 3c1561f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

shell_encryption/rns/rns_polynomial_hwy.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ void BatchFusedMulAddMontgomeryRepHwy(absl::Span<const ModularInt64> a,
112112

113113
// Generate the masks on the even lanes, which correspond to the lower 64 bits
114114
// of BigInt64 (unsigned 128-bit int) values in the output vector.
115-
uint8_t* mask_lo_bits = new uint8_t[(N + 7) / 8];
116-
for (int j = 0; j < (N + 7) / 8; ++j) {
117-
mask_lo_bits[j] = 0;
115+
// LoadMaskBits requires at least 8 readable bytes, even if N is small.
116+
int num_bytes = (N + 7) / 8;
117+
int alloc_bytes = num_bytes < 8 ? 8 : num_bytes;
118+
uint8_t* mask_lo_bits = new uint8_t[alloc_bytes]();
119+
for (int j = 0; j < num_bytes; ++j) {
118120
for (int k = 0; k < 8; k += 2) {
119121
mask_lo_bits[j] |= static_cast<uint8_t>(1 << k);
120122
}

0 commit comments

Comments
 (0)