1301 {
1302 if constexpr(BlindingEnabled) {
1303 constexpr size_t mask_words = BlindingBits / WordInfo<W>::bits;
1304 constexpr size_t mask_bytes = mask_words * WordInfo<W>::bytes;
1305
1306 constexpr size_t n_words = C::Words;
1307
1308 uint8_t maskb[mask_bytes] = {0};
1309 if(rng.is_seeded()) {
1310 rng.randomize(maskb, mask_bytes);
1311 } else {
1312
1313
1314
1315
1316
1317
1318
1319 std::array<uint8_t, C::Scalar::BYTES> sbytes = {};
1320 scalar.serialize_to(sbytes);
1321 for(size_t i = 0; i != sbytes.size(); ++i) {
1322 maskb[i % mask_bytes] ^= sbytes[i];
1323 }
1324 }
1325
1326 W mask[n_words] = {0};
1327 load_le(mask, maskb, mask_words);
1328 mask[mask_words - 1] |= WordInfo<W>::top_bit;
1329 mask[0] |= 1;
1330
1331 W mask_n[2 * n_words] = {0};
1332
1333 const auto sw = scalar.to_words();
1334
1335
1337 bigint_add2(mask_n, 2 * n_words, sw.data(), sw.size());
1338
1339 std::reverse(mask_n, mask_n + 2 * n_words);
1341 } else {
1342 static_assert(
Bytes == C::Scalar::BYTES);
1343 m_bytes.resize(
Bytes);
1344 scalar.serialize_to(std::span{m_bytes}.template first<Bytes>());
1345 }
1346
1348 }
static constexpr size_t Bytes
constexpr void poison(const T *p, size_t n)
constexpr auto bigint_add2(W x[], size_t x_size, const W y[], size_t y_size) -> W
constexpr void comba_mul(W z[2 *N], const W x[N], const W y[N])
constexpr auto load_le(ParamTs &&... params)
constexpr auto store_be(ParamTs &&... params)