Skip to content

Commit ebf5cc6

Browse files
committed
aklsjlskjd
Signed-off-by: dkostic <[email protected]>
1 parent 24f3e57 commit ebf5cc6

File tree

7 files changed

+26
-24
lines changed

7 files changed

+26
-24
lines changed

benchmarks/benchmark.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,6 @@ void call_edwards25519_scalarmuldouble_alt(void) repeatfewer(10,edwards25519_sca
768768
void call_mlkem_basemul_k2(void) repeat(mlkem_basemul_k2((int16_t*)b0,(int16_t*)b1,(int16_t*)b2,(int16_t*)b3))
769769
void call_mlkem_basemul_k3(void) repeat(mlkem_basemul_k3((int16_t*)b0,(int16_t*)b1,(int16_t*)b2,(int16_t*)b3))
770770
void call_mlkem_basemul_k4(void) repeat(mlkem_basemul_k4((int16_t*)b0,(int16_t*)b1,(int16_t*)b2,(int16_t*)b3))
771-
void call_mlkem_ntt(void) repeat(mlkem_ntt((int16_t*)b0,(int16_t*)b1,(int16_t*)b2))
772771
void call_mlkem_reduce(void) repeat(mlkem_reduce((int16_t*)b0))
773772

774773
void call_p256_montjadd(void) repeat(p256_montjadd(b1,b2,b3))
@@ -831,6 +830,8 @@ void call_sm2_montjscalarmul_alt(void) repeatfewer(10,sm2_montjscalarmul_alt(b1,
831830
void call_mldsa_ntt(void) repeat(mldsa_ntt((int32_t*)b0,(const int32_t*)b1))
832831
void call_mldsa_poly_reduce(void) repeat(mldsa_poly_reduce((int32_t*)b0))
833832

833+
void call_mlkem_ntt(void) repeat(mlkem_ntt((int16_t*)b0,(int16_t*)b1))
834+
834835
void call_bignum_copy_row_from_table_8n__32_16(void) {}
835836
void call_bignum_copy_row_from_table_8n__32_32(void) {}
836837
void call_bignum_copy_row_from_table_16__32(void) {}
@@ -1131,6 +1132,7 @@ void call_bignum_emontredc_8n_cdiff__32(void) repeat(bignum_emontredc_8n_cdiff(3
11311132

11321133
void call_mlkem_intt(void) repeat(mlkem_intt((int16_t*)b0,(int16_t*)b1,(int16_t*)b2))
11331134
void call_mlkem_mulcache_compute(void) repeat(mlkem_mulcache_compute((int16_t*)b0,(int16_t*)b1,(int16_t*)b2,(int16_t*)b3))
1135+
void call_mlkem_ntt(void) repeat(mlkem_ntt((int16_t*)b0,(int16_t*)b1,(int16_t*)b2))
11341136
void call_mlkem_tobytes(void) repeat(mlkem_tobytes((uint8_t*)b0,(int16_t*)b1))
11351137
void call_mlkem_tomont(void) repeat(mlkem_tomont((int16_t*)b0))
11361138
void call_mlkem_rej_uniform(void) repeat(mlkem_rej_uniform_VARIABLE_TIME((int16_t*)b0,(uint8_t*)b1,1200,mlkem_rej_uniform_table))

include/s2n-bignum.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,15 +1006,13 @@ extern void mlkem_intt(int16_t a[S2N_BIGNUM_STATIC 256],const int16_t z_01234[S2
10061006
// Inputs a[256], z[128] and t[128] (signed 16-bit words); output x[128] (signed 16-bit words)
10071007
extern void mlkem_mulcache_compute(int16_t x[S2N_BIGNUM_STATIC 128],const int16_t a[S2N_BIGNUM_STATIC 256],const int16_t z[S2N_BIGNUM_STATIC 128],const int16_t t[S2N_BIGNUM_STATIC 128]);
10081008

1009-
#ifdef __x86_64__
10101009
// Forward number-theoretic transform from ML-KEM x86 implementation
1011-
// Input a[256] (signed 16-bit words), qdata[624]
1012-
extern void mlkem_ntt(int16_t a[S2N_BIGNUM_STATIC 256],const int16_t qdata[S2N_BIGNUM_STATIC 624]);
1013-
#else
1010+
// Input a[256] (signed 16-bit words), qdata[624]; output a[256] (signed 16-bit words)
1011+
extern void mlkem_ntt_x86(int16_t a[S2N_BIGNUM_STATIC 256],const int16_t qdata[S2N_BIGNUM_STATIC 624]);
1012+
10141013
// Forward number-theoretic transform from ML-KEM
10151014
// Input a[256] (signed 16-bit words), z_01234[80] (signed 16-bit words), z_56[384] (signed 16-bit words); output a[256] (signed 16-bit words)
10161015
extern void mlkem_ntt(int16_t a[S2N_BIGNUM_STATIC 256],const int16_t z_01234[S2N_BIGNUM_STATIC 80],const int16_t z_56[S2N_BIGNUM_STATIC 384]);
1017-
#endif
10181016

10191017
// Canonical modular reduction of polynomial coefficients for ML-KEM
10201018
// Input a[256] (signed 16-bit words); output a[256] (signed 16-bit words)

tests/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12192,7 +12192,7 @@ uint64_t t, i;
1219212192
a[i] = (int16_t) (random64() % 16383) - 8192; // |a[i]| < 8192 assumed
1219312193
for (i = 0; i < 256; ++i) b[i] = a[i];
1219412194
#ifdef __x86_64__
12195-
mlkem_ntt(b, mlkem_qdata);
12195+
mlkem_ntt_x86(b, mlkem_qdata);
1219612196
reference_forward_ntt(c,a); reference_bitreverse(c,c);
1219712197
mlkem_poly_to_avx2_layout(c);
1219812198
#else

tools/collect-signatures.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def stripPrefixes(s, prefixes):
298298
"curve25519_x25519_byte",
299299
"curve25519_x25519_byte_alt",
300300
"sha3_",
301+
"mlkem_ntt",
301302
"mlkem_intt",
302303
"mlkem_mulcache_compute",
303304
"mlkem_rej_uniform_VARIABLE_TIME",
@@ -331,6 +332,7 @@ def stripPrefixes(s, prefixes):
331332
"bignum_triple_sm2_alt",
332333
"mldsa_ntt",
333334
"mldsa_poly_reduce",
335+
"mlkem_ntt_x86",
334336
]
335337

336338
for arch in ["arm","x86"]:

x86/mlkem/mlkem_ntt.S

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

55
// ----------------------------------------------------------------------------
66
// Forward number-theoretic transform from ML-KEM
7-
// Input a[256], z_01234[80], z_56[384] (all signed 16-bit words); output a[256] (signed 16-bit words).
7+
// Input a[256], qdata[624] (all signed 16-bit words); output a[256] (signed 16-bit words).
88
//
99
// The transform is in-place with input and output a[256], with the output
1010
// in bitreversed order. The second parameter is expected to point to a
1111
// table of constants whose definitions can be found in the mlkem-native
1212
// repo or our "tests/test.c".
1313
//
14-
// extern void mlkem_ntt(int16_t a[static 256], const int16_t *qdata);
14+
// extern void mlkem_ntt_x86(int16_t a[static 256], const int16_t qdata[static 624]);
1515
//
1616
// Standard x86-64 ABI: RDI = a, RSI = qdata
1717
// Microsoft x64 ABI: RCX = a, RDX = qdata
1818
// ----------------------------------------------------------------------------
1919
#include "_internal_s2n_bignum_x86.h"
2020

2121
.intel_syntax noprefix
22-
S2N_BN_SYM_VISIBILITY_DIRECTIVE(mlkem_ntt)
23-
S2N_BN_FUNCTION_TYPE_DIRECTIVE(mlkem_ntt)
24-
S2N_BN_SYM_PRIVACY_DIRECTIVE(mlkem_ntt)
22+
S2N_BN_SYM_VISIBILITY_DIRECTIVE(mlkem_ntt_x86)
23+
S2N_BN_FUNCTION_TYPE_DIRECTIVE(mlkem_ntt_x86)
24+
S2N_BN_SYM_PRIVACY_DIRECTIVE(mlkem_ntt_x86)
2525
.text
2626
.balign 4
2727

28-
S2N_BN_SYMBOL(mlkem_ntt):
28+
S2N_BN_SYMBOL(mlkem_ntt_x86):
2929
CFI_START
3030
_CET_ENDBR
3131

@@ -652,7 +652,7 @@ S2N_BN_SYMBOL(mlkem_ntt):
652652
#endif
653653
CFI_RET
654654

655-
S2N_BN_SIZE_DIRECTIVE(mlkem_ntt)
655+
S2N_BN_SIZE_DIRECTIVE(mlkem_ntt_x86)
656656

657657
#if defined(__linux__) && defined(__ELF__)
658658
.section .note.GNU-stack,"",%progbits

x86/proofs/subroutine_signatures.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4793,15 +4793,15 @@ let subroutine_signatures = [
47934793
])
47944794
);
47954795

4796-
("mlkem_ntt",
4796+
("mlkem_ntt_x86",
47974797
([(*args*)
47984798
("a", "int16_t[static 256]", (*is const?*)"false");
4799-
("q", "int16_t[static 624]", (*is const?*)"true");
4799+
("qdata", "int16_t[static 624]", (*is const?*)"true");
48004800
],
48014801
"void",
48024802
[(* input buffers *)
48034803
("a", "256"(* num elems *), 2(* elem bytesize *));
4804-
("q", "624"(* num elems *), 2(* elem bytesize *));
4804+
("qdata", "624"(* num elems *), 2(* elem bytesize *));
48054805
],
48064806
[(* output buffers *)
48074807
("a", "256"(* num elems *), 2(* elem bytesize *));

x86_att/mlkem/mlkem_ntt.S

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

55
// ----------------------------------------------------------------------------
66
// Forward number-theoretic transform from ML-KEM
7-
// Input a[256], z_01234[80], z_56[384] (all signed 16-bit words); output a[256] (signed 16-bit words).
7+
// Input a[256], qdata[624] (all signed 16-bit words); output a[256] (signed 16-bit words).
88
//
99
// The transform is in-place with input and output a[256], with the output
1010
// in bitreversed order. The second parameter is expected to point to a
1111
// table of constants whose definitions can be found in the mlkem-native
1212
// repo or our "tests/test.c".
1313
//
14-
// extern void mlkem_ntt(int16_t a[static 256], const int16_t *qdata);
14+
// extern void mlkem_ntt_x86(int16_t a[static 256], const int16_t qdata[static 624]);
1515
//
1616
// Standard x86-64 ABI: RDI = a, RSI = qdata
1717
// Microsoft x64 ABI: RCX = a, RDX = qdata
1818
// ----------------------------------------------------------------------------
1919
#include "_internal_s2n_bignum_x86_att.h"
2020

2121

22-
S2N_BN_SYM_VISIBILITY_DIRECTIVE(mlkem_ntt)
23-
S2N_BN_FUNCTION_TYPE_DIRECTIVE(mlkem_ntt)
24-
S2N_BN_SYM_PRIVACY_DIRECTIVE(mlkem_ntt)
22+
S2N_BN_SYM_VISIBILITY_DIRECTIVE(mlkem_ntt_x86)
23+
S2N_BN_FUNCTION_TYPE_DIRECTIVE(mlkem_ntt_x86)
24+
S2N_BN_SYM_PRIVACY_DIRECTIVE(mlkem_ntt_x86)
2525
.text
2626
.balign 4
2727

28-
S2N_BN_SYMBOL(mlkem_ntt):
28+
S2N_BN_SYMBOL(mlkem_ntt_x86):
2929
CFI_START
3030
_CET_ENDBR
3131

@@ -652,7 +652,7 @@ vpblendw $0xaa,%ymm8,%ymm4,%ymm8
652652
#endif
653653
CFI_RET
654654

655-
S2N_BN_SIZE_DIRECTIVE(mlkem_ntt)
655+
S2N_BN_SIZE_DIRECTIVE(mlkem_ntt_x86)
656656

657657
#if defined(__linux__) && defined(__ELF__)
658658
.section .note.GNU-stack,"",%progbits

0 commit comments

Comments
 (0)