Skip to content

Commit

Permalink
rename dilithium constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemas committed Dec 20, 2024
1 parent a3fd830 commit 4a7a61a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions crypto/dilithium/pqcrystals_dilithium_ref_common/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ typedef struct {

// We define max values for some parameters because they are used
// for static allocation.
#define DILITHIUM_K_MAX (8)
#define DILITHIUM_L_MAX (7)
#define DILITHIUM_C_TILDE_BYTES_MAX (64)
#define DILITHIUM_POLYW1_PACKEDBYTES_MAX (192)
#define DILITHIUM_POLY_UNIFORM_ETA_NBLOCKS_MAX ((227 + SHAKE256_RATE - 1)/SHAKE256_RATE)
#define DILITHIUM_POLYZ_PACKEDBYTES_MAX (576)
#define ML_DSA_K_MAX (8)
#define ML_DSA_L_MAX (7)
#define ML_DSA_C_TILDE_BYTES_MAX (64)
#define ML_DSA_POLYW1_PACKEDBYTES_MAX (192)
#define ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX ((227 + SHAKE256_RATE - 1)/SHAKE256_RATE)
#define ML_DSA_POLYZ_PACKEDBYTES_MAX (576)

void ml_dsa_44_params_init(ml_dsa_params *params);
void ml_dsa_65_params_init(ml_dsa_params *params);
Expand Down
8 changes: 4 additions & 4 deletions crypto/dilithium/pqcrystals_dilithium_ref_common/poly.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ void poly_uniform_eta(ml_dsa_params *params,
uint16_t nonce)
{
unsigned int ctr;
unsigned int buflen = DILITHIUM_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_RATE;
uint8_t buf[DILITHIUM_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_RATE];
unsigned int buflen = ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_RATE;
uint8_t buf[ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_RATE];
KECCAK1600_CTX state;

uint8_t t[2];
Expand All @@ -409,7 +409,7 @@ void poly_uniform_eta(ml_dsa_params *params,
SHAKE_Init(&state, SHAKE256_BLOCKSIZE);
SHA3_Update(&state, seed, CRHBYTES);
SHA3_Update(&state, t, 2);
SHAKE_Final(buf, &state, DILITHIUM_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_BLOCKSIZE);
SHAKE_Final(buf, &state, ML_DSA_POLY_UNIFORM_ETA_NBLOCKS_MAX * SHAKE256_BLOCKSIZE);

ctr = rej_eta(params, a->coeffs, ML_DSA_N, buf, buflen);

Expand All @@ -434,7 +434,7 @@ void poly_uniform_eta(ml_dsa_params *params,
* - const uint8_t seed[]: byte array with seed of length CRHBYTES
* - uint16_t nonce: 16-bit nonce
**************************************************/
#define POLY_UNIFORM_GAMMA1_NBLOCKS ((DILITHIUM_POLYZ_PACKEDBYTES_MAX + SHAKE256_RATE - 1) / SHAKE256_RATE)
#define POLY_UNIFORM_GAMMA1_NBLOCKS ((ML_DSA_POLYZ_PACKEDBYTES_MAX + SHAKE256_RATE - 1) / SHAKE256_RATE)
void poly_uniform_gamma1(ml_dsa_params *params,
poly *a,
const uint8_t seed[CRHBYTES],
Expand Down
4 changes: 2 additions & 2 deletions crypto/dilithium/pqcrystals_dilithium_ref_common/polyvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/* Vectors of polynomials of length L */
typedef struct {
poly vec[DILITHIUM_L_MAX];
poly vec[ML_DSA_L_MAX];
} polyvecl;

void polyvecl_uniform_eta(ml_dsa_params *params,
Expand Down Expand Up @@ -44,7 +44,7 @@ void polyvecl_pointwise_acc_montgomery(ml_dsa_params *params,
int polyvecl_chknorm(ml_dsa_params *params, const polyvecl *v, int32_t B);

typedef struct {
poly vec[DILITHIUM_K_MAX];
poly vec[ML_DSA_K_MAX];
} polyveck;

void polyveck_uniform_eta(ml_dsa_params *params,
Expand Down
12 changes: 6 additions & 6 deletions crypto/dilithium/pqcrystals_dilithium_ref_common/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int crypto_sign_keypair_internal(ml_dsa_params *params,
uint8_t seedbuf[2*SEEDBYTES + CRHBYTES];
uint8_t tr[TRBYTES];
const uint8_t *rho, *rhoprime, *key;
polyvecl mat[DILITHIUM_K_MAX];
polyvecl mat[ML_DSA_K_MAX];
polyvecl s1 = {{{{0}}}};
polyvecl s1hat;
polyveck s2, t1, t0;
Expand Down Expand Up @@ -138,7 +138,7 @@ int crypto_sign_signature_internal(ml_dsa_params *params,
uint8_t seedbuf[2*SEEDBYTES + TRBYTES + 2*CRHBYTES];
uint8_t *rho, *tr, *key, *mu, *rhoprime;
uint16_t nonce = 0;
polyvecl mat[DILITHIUM_K_MAX], s1, y, z;
polyvecl mat[ML_DSA_K_MAX], s1, y, z;
polyveck t0, s2, w1, w0, h;
poly cp;
KECCAK1600_CTX state;
Expand Down Expand Up @@ -365,14 +365,14 @@ int crypto_sign_verify_internal(ml_dsa_params *params,
const uint8_t *pk)
{
unsigned int i;
uint8_t buf[DILITHIUM_K_MAX*DILITHIUM_POLYW1_PACKEDBYTES_MAX];
uint8_t buf[ML_DSA_K_MAX*ML_DSA_POLYW1_PACKEDBYTES_MAX];
uint8_t rho[SEEDBYTES];
uint8_t mu[CRHBYTES];
uint8_t tr[TRBYTES];
uint8_t c[DILITHIUM_C_TILDE_BYTES_MAX];
uint8_t c2[DILITHIUM_C_TILDE_BYTES_MAX];
uint8_t c[ML_DSA_C_TILDE_BYTES_MAX];
uint8_t c2[ML_DSA_C_TILDE_BYTES_MAX];
poly cp;
polyvecl mat[DILITHIUM_K_MAX], z;
polyvecl mat[ML_DSA_K_MAX], z;
polyveck t1, w1, h;
KECCAK1600_CTX state;

Expand Down

0 comments on commit 4a7a61a

Please sign in to comment.