|
Embedded SDK
Embedded SDK
|
ML-KEM sampling routines (FIPS 203). More...
#include <string.h>#include "cx_mlkem_poly.h"#include "cx_mlkem_util.h"#include "cx_mlkem_sample.h"
Go to the source code of this file.
Macros | |
| #define | XOF_BLOCKBYTES 168U |
| #define | REJ_UNIFORM_NBLOCKS 5U |
| #define | REJ_UNIFORM_BUFLEN (REJ_UNIFORM_NBLOCKS * XOF_BLOCKBYTES) |
| #define | REJ_UNIFORM_BUFLEN_EXT (REJ_UNIFORM_BUFLEN + (XOF_BLOCKBYTES * 3U)) |
Functions | |
| static uint32_t | load32_le (const uint8_t *x) |
| static uint32_t | load24_le (const uint8_t *x) |
| void | MLKEM_SAMPLE_cbd2 (poly *r, const uint8_t *buf) |
| Samples a polynomial using the centered binomial distribution with eta=2. | |
| void | MLKEM_SAMPLE_cbd3 (poly *r, const uint8_t *buf) |
| Samples a polynomial using the centered binomial distribution with eta=3. | |
| void | MLKEM_SAMPLE_getnoise (poly *r, const uint8_t *seed, uint8_t nonce, uint8_t eta) |
| Samples a noise polynomial using PRF and CBD. | |
| void | MLKEM_SAMPLE_rej_uniform (poly *r, const uint8_t *seed, uint8_t x, uint8_t y) |
| Samples a polynomial using rejection sampling from a uniform distribution. | |
ML-KEM sampling routines (FIPS 203).
Implements rejection sampling (rej_uniform), centered binomial distribution sampling (CBD eta=2 and eta=3), and noise generation for ML-KEM.
Definition in file cx_mlkem_sample.c.
| #define REJ_UNIFORM_BUFLEN (REJ_UNIFORM_NBLOCKS * XOF_BLOCKBYTES) |
Definition at line 36 of file cx_mlkem_sample.c.
| #define REJ_UNIFORM_BUFLEN_EXT (REJ_UNIFORM_BUFLEN + (XOF_BLOCKBYTES * 3U)) |
Definition at line 98 of file cx_mlkem_sample.c.
| #define REJ_UNIFORM_NBLOCKS 5U |
Definition at line 35 of file cx_mlkem_sample.c.
| #define XOF_BLOCKBYTES 168U |
Definition at line 34 of file cx_mlkem_sample.c.
|
static |
Definition at line 45 of file cx_mlkem_sample.c.
|
static |
Definition at line 39 of file cx_mlkem_sample.c.
| void MLKEM_SAMPLE_cbd2 | ( | poly * | r, |
| const uint8_t * | buf | ||
| ) |
Samples a polynomial using the centered binomial distribution with eta=2.
| [out] | r | Output polynomial. |
| [in] | buf | Input byte buffer of 2 * MLKEM_N / 4 bytes. |
Definition at line 50 of file cx_mlkem_sample.c.
| void MLKEM_SAMPLE_cbd3 | ( | poly * | r, |
| const uint8_t * | buf | ||
| ) |
Samples a polynomial using the centered binomial distribution with eta=3.
| [out] | r | Output polynomial. |
| [in] | buf | Input byte buffer of 3 * MLKEM_N / 4 bytes. |
Definition at line 65 of file cx_mlkem_sample.c.
| void MLKEM_SAMPLE_getnoise | ( | poly * | r, |
| const uint8_t * | seed, | ||
| uint8_t | nonce, | ||
| uint8_t | eta | ||
| ) |
Samples a noise polynomial using PRF and CBD.
| [out] | r | Output polynomial. |
| [in] | seed | Seed of MLKEM_SYMBYTES bytes. |
| [in] | nonce | Nonce byte. |
| [in] | eta | CBD parameter (2 or 3). |
Definition at line 81 of file cx_mlkem_sample.c.
| void MLKEM_SAMPLE_rej_uniform | ( | poly * | r, |
| const uint8_t * | seed, | ||
| uint8_t | x, | ||
| uint8_t | y | ||
| ) |
Samples a polynomial using rejection sampling from a uniform distribution.
| [out] | r | Output polynomial with coefficients in [0, q-1]. |
| [in] | seed | Seed of MLKEM_SYMBYTES bytes. |
| [in] | x | First index byte for the XOF. |
| [in] | y | Second index byte for the XOF. |
Definition at line 100 of file cx_mlkem_sample.c.