pqc/crypto_kem/ledakemlt32/leaktime/H_Q_matrices_generation.c

33 lines
1.1 KiB
C
Raw Normal View History

#include "H_Q_matrices_generation.h"
#include "gf2x_arith_mod_xPplusOne.h"
2019-06-16 16:01:29 +01:00
void PQCLEAN_LEDAKEMLT32_LEAKTIME_generateHPosOnes_HtrPosOnes(
2019-05-24 17:38:54 +01:00
POSITION_T HPosOnes[N0][DV],
POSITION_T HtrPosOnes[N0][DV],
AES_XOF_struct *keys_expander) {
for (int i = 0; i < N0; i++) {
/* Generate a random block of Htr */
2019-06-16 16:01:29 +01:00
PQCLEAN_LEDAKEMLT32_LEAKTIME_rand_circulant_sparse_block(&HtrPosOnes[i][0], DV, keys_expander);
}
for (int i = 0; i < N0; i++) {
/* Obtain directly the sparse representation of the block of H */
for (int k = 0; k < DV; k++) {
HPosOnes[i][k] = (P - HtrPosOnes[i][k]) % P; /* transposes indexes */
2019-06-07 14:07:22 +01:00
}
}
2019-05-24 17:38:54 +01:00
}
2019-06-16 16:01:29 +01:00
void PQCLEAN_LEDAKEMLT32_LEAKTIME_generateQsparse(
2019-05-24 17:38:54 +01:00
POSITION_T pos_ones[N0][M],
AES_XOF_struct *keys_expander) {
for (int i = 0; i < N0; i++) {
int placed_ones = 0;
for (int j = 0; j < N0; j++) {
2019-06-16 16:01:29 +01:00
PQCLEAN_LEDAKEMLT32_LEAKTIME_rand_circulant_sparse_block(&pos_ones[i][placed_ones],
2019-05-24 17:38:54 +01:00
qBlockWeights[i][j],
keys_expander);
placed_ones += qBlockWeights[i][j];
2019-06-07 14:07:22 +01:00
}
}
2019-05-24 17:38:54 +01:00
}