Skip to content

Commit 22a3bb0

Browse files
rod-chapmanhanno-becker
authored andcommitted
Rename mlk_keypair_getnoise() to mlk_keypair_getnoise_eta1()
Signed-off-by: Rod Chapman <rodchap@amazon.com>
1 parent 45f8f40 commit 22a3bb0

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

mlkem/src/indcpa.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
MLK_ADD_PARAM_SET(mlk_polyvec_permute_bitrev_to_custom)
4040
#define mlk_polymat_permute_bitrev_to_custom \
4141
MLK_ADD_PARAM_SET(mlk_polymat_permute_bitrev_to_custom)
42-
#define mlk_keypair_getnoise MLK_ADD_PARAM_SET(mlk_keypair_getnoise)
42+
#define mlk_keypair_getnoise_eta1 MLK_ADD_PARAM_SET(mlk_keypair_getnoise_eta1)
4343
/* End of parameter set namespacing */
4444

4545
/*************************************************
@@ -367,10 +367,10 @@ __contract__(
367367
}
368368

369369
/*************************************************
370-
* Name: mlk_keypair_getnoise
370+
* Name: mlk_keypair_getnoise_eta1
371371
*
372372
* Description: Computes and fills the pv and e polyvec
373-
* structures needed by mlk_keypair_derand()
373+
* structures needed by mlk_keypair_derand().
374374
*
375375
* Arguments: - pv: Pointer to output polynomial vector
376376
* - e: Pointer to output polynomial vector
@@ -379,8 +379,8 @@ __contract__(
379379
* Specification: Implements @[FIPS203, Algorithm 13 (K-PKE.KeyGen)].
380380
* steps 8 - 15
381381
**************************************************/
382-
static void mlk_keypair_getnoise(mlk_polyvec *pv, mlk_polyvec *e,
383-
const uint8_t seed[MLKEM_SYMBYTES])
382+
static void mlk_keypair_getnoise_eta1(mlk_polyvec *pv, mlk_polyvec *e,
383+
const uint8_t seed[MLKEM_SYMBYTES])
384384
__contract__(
385385
requires(memory_no_alias(pv, sizeof(mlk_polyvec)))
386386
requires(memory_no_alias(e, sizeof(mlk_polyvec)))
@@ -392,17 +392,19 @@ __contract__(
392392
)
393393
{
394394
#if MLKEM_K == 2
395-
mlk_poly_getnoise_eta1_4x(&pv->vec[0], &pv->vec[1], &e->vec[0], &e->vec[1],
395+
mlk_poly_getnoise_eta1_4x(&pv->vec[0], &pv->vec[1], /* Fill elements of pv */
396+
&e->vec[0], &e->vec[1], /* and two elements of e */
396397
seed, 0, 1, 2, 3);
397398
#elif MLKEM_K == 3
398399
/*
399-
* Only the first three output buffers are needed.
400+
* Only the first three output buffers are needed, so we pass NULL as
401+
* the fourth parameter, and 0xFF as its dummy nonce.
400402
*/
401403
mlk_poly_getnoise_eta1_4x(&pv->vec[0], &pv->vec[1], &pv->vec[2], NULL, seed,
402-
0, 1, 2, 0xFF /* irrelevant */);
404+
0, 1, 2, 0xFF);
403405
/* Same here */
404406
mlk_poly_getnoise_eta1_4x(&e->vec[0], &e->vec[1], &e->vec[2], NULL, seed, 3,
405-
4, 5, 0xFF /* irrelevant */);
407+
4, 5, 0xFF);
406408
#elif MLKEM_K == 4
407409
mlk_poly_getnoise_eta1_4x(&pv->vec[0], &pv->vec[1], &pv->vec[2], &pv->vec[3],
408410
seed, 0, 1, 2, 3);
@@ -463,7 +465,7 @@ int mlk_indcpa_keypair_derand(uint8_t pk[MLKEM_INDCPA_PUBLICKEYBYTES],
463465

464466
mlk_gen_matrix(a, publicseed, 0 /* no transpose */);
465467

466-
mlk_keypair_getnoise(skpv, e, noiseseed);
468+
mlk_keypair_getnoise_eta1(skpv, e, noiseseed);
467469

468470
mlk_polyvec_ntt(skpv);
469471
mlk_polyvec_ntt(e);
@@ -652,4 +654,4 @@ int mlk_indcpa_dec(uint8_t m[MLKEM_INDCPA_MSGBYTES],
652654
#undef mlk_matvec_mul
653655
#undef mlk_polyvec_permute_bitrev_to_custom
654656
#undef mlk_polymat_permute_bitrev_to_custom
655-
#undef mlk_keypair_getnoise
657+
#undef mlk_keypair_getnoise_eta1

proofs/cbmc/indcpa_keypair_derand/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ CHECK_FUNCTION_CONTRACTS=mlk_indcpa_keypair_derand
2323
USE_FUNCTION_CONTRACTS = mlk_zeroize
2424
USE_FUNCTION_CONTRACTS += mlk_sha3_512
2525
USE_FUNCTION_CONTRACTS += mlk_gen_matrix
26-
USE_FUNCTION_CONTRACTS += mlk_keypair_getnoise
26+
USE_FUNCTION_CONTRACTS += mlk_keypair_getnoise_eta1
2727
USE_FUNCTION_CONTRACTS += mlk_polyvec_ntt
2828
USE_FUNCTION_CONTRACTS += mlk_polyvec_mulcache_compute
2929
USE_FUNCTION_CONTRACTS += mlk_matvec_mul

proofs/cbmc/keypair_getnoise/Makefile renamed to proofs/cbmc/keypair_getnoise_eta1/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
include ../Makefile_params.common
55

66
HARNESS_ENTRY = harness
7-
HARNESS_FILE = keypair_getnoise_harness
7+
HARNESS_FILE = keypair_getnoise_eta1_harness
88

99
# This should be a unique identifier for this proof, and will appear on the
1010
# Litani dashboard. It can be human-readable and contain spaces if you wish.
11-
PROOF_UID = mlk_keypair_getnoise
11+
PROOF_UID = mlk_keypair_getnoise_eta1
1212

1313
DEFINES +=
1414
INCLUDES +=
@@ -18,7 +18,7 @@ REMOVE_FUNCTION_BODY +=
1818
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
1919
PROJECT_SOURCES += $(SRCDIR)/mlkem/src/indcpa.c
2020

21-
CHECK_FUNCTION_CONTRACTS=mlk_keypair_getnoise
21+
CHECK_FUNCTION_CONTRACTS=mlk_keypair_getnoise_eta1
2222
USE_FUNCTION_CONTRACTS=mlk_poly_getnoise_eta1_4x
2323
APPLY_LOOP_CONTRACTS=on
2424
USE_DYNAMIC_FRAMES=1
@@ -27,7 +27,7 @@ USE_DYNAMIC_FRAMES=1
2727
EXTERNAL_SAT_SOLVER=
2828
CBMCFLAGS=--smt2 --slice-formula
2929

30-
FUNCTION_NAME = mlk_keypair_getnoise
30+
FUNCTION_NAME = mlk_keypair_getnoise_eta1
3131

3232
# If this proof is found to consume huge amounts of RAM, you can set the
3333
# EXPENSIVE variable. With new enough versions of the proof tools, this will

proofs/cbmc/keypair_getnoise/keypair_getnoise_harness.c renamed to proofs/cbmc/keypair_getnoise_eta1/keypair_getnoise_eta1_harness.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
#include <indcpa.h>
66

7-
#define mlk_keypair_getnoise MLK_NAMESPACE(keypair_getnoise)
8-
void mlk_keypair_getnoise(mlk_polyvec *pv, mlk_polyvec *e,
9-
const uint8_t seed[MLKEM_SYMBYTES]);
7+
#define mlk_keypair_getnoise_eta1 MLK_NAMESPACE(keypair_getnoise_eta1)
8+
void mlk_keypair_getnoise_eta1(mlk_polyvec *pv, mlk_polyvec *e,
9+
const uint8_t seed[MLKEM_SYMBYTES]);
1010

1111
void harness(void)
1212
{
@@ -18,5 +18,5 @@ void harness(void)
1818
free(NULL);
1919
}
2020

21-
mlk_keypair_getnoise(a, b, seed);
21+
mlk_keypair_getnoise_eta1(a, b, seed);
2222
}

0 commit comments

Comments
 (0)