-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathparams.h
64 lines (54 loc) · 1.9 KB
/
params.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (c) 2024 The mlkem-native project authors
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef PARAMS_H
#define PARAMS_H
#if defined(MLKEM_NATIVE_CONFIG_FILE)
#include MLKEM_NATIVE_CONFIG_FILE
#else
#include "config.h"
#endif /* MLKEM_NATIVE_CONFIG_FILE */
#if !defined(MLKEM_K)
#error MLKEM_K is not defined
#endif
#define MLKEM_N 256
#define MLKEM_Q 3329
#define UINT12_LIMIT 4096
#define MLKEM_SYMBYTES 32 /* size in bytes of hashes, and seeds */
#define MLKEM_SSBYTES 32 /* size in bytes of shared key */
#define MLKEM_POLYBYTES 384
#define MLKEM_POLYVECBYTES (MLKEM_K * MLKEM_POLYBYTES)
#if MLKEM_K == 2
#define MLKEM_LVL 512
#define MLKEM_ETA1 3
#define MLKEM_POLYCOMPRESSEDBYTES_DV 128
#define MLKEM_POLYCOMPRESSEDBYTES_DU 320
#define MLKEM_POLYVECCOMPRESSEDBYTES_DU (MLKEM_K * MLKEM_POLYCOMPRESSEDBYTES_DU)
#elif MLKEM_K == 3
#define MLKEM_LVL 768
#define MLKEM_ETA1 2
#define MLKEM_POLYCOMPRESSEDBYTES_DV 128
#define MLKEM_POLYCOMPRESSEDBYTES_DU 320
#define MLKEM_POLYVECCOMPRESSEDBYTES_DU (MLKEM_K * MLKEM_POLYCOMPRESSEDBYTES_DU)
#elif MLKEM_K == 4
#define MLKEM_LVL 1024
#define MLKEM_ETA1 2
#define MLKEM_POLYCOMPRESSEDBYTES_DV 160
#define MLKEM_POLYCOMPRESSEDBYTES_DU 352
#define MLKEM_POLYVECCOMPRESSEDBYTES_DU (MLKEM_K * MLKEM_POLYCOMPRESSEDBYTES_DU)
#endif
#define MLKEM_ETA2 2
#define MLKEM_INDCPA_MSGBYTES (MLKEM_SYMBYTES)
#define MLKEM_INDCPA_PUBLICKEYBYTES (MLKEM_POLYVECBYTES + MLKEM_SYMBYTES)
#define MLKEM_INDCPA_SECRETKEYBYTES (MLKEM_POLYVECBYTES)
#define MLKEM_INDCPA_BYTES \
(MLKEM_POLYVECCOMPRESSEDBYTES_DU + MLKEM_POLYCOMPRESSEDBYTES_DV)
#define MLKEM_INDCCA_PUBLICKEYBYTES (MLKEM_INDCPA_PUBLICKEYBYTES)
/* 32 bytes of additional space to save H(pk) */
#define MLKEM_INDCCA_SECRETKEYBYTES \
(MLKEM_INDCPA_SECRETKEYBYTES + MLKEM_INDCPA_PUBLICKEYBYTES + \
2 * MLKEM_SYMBYTES)
#define MLKEM_INDCCA_CIPHERTEXTBYTES (MLKEM_INDCPA_BYTES)
#define KECCAK_WAY 4
#endif