Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0a81791
Added optimized ppc64le support functions for ML-KEM.
dannytsen Sep 8, 2025
68ee31c
Document nix 2.18 requirement; disable nix setup test for nix 2.6
mkannwischer Sep 8, 2025
1f41a2e
Add clang_21 to compiler and constant-time tests
mkannwischer Aug 2, 2025
d4e8c28
bitwuzla: update the bitwuzla version from 0.7.0 to 0.8.2 in nix
willieyz Aug 12, 2025
4e33b28
Add compiler test for zig 0.15
mkannwischer Sep 9, 2025
aa3b87b
Fixed auto.mk, components.mk and YML files.
dannytsen Sep 9, 2025
5f71ef6
Fixed format and styling by using autogen but no simpasm was run.
Sep 18, 2025
f3a7d3c
Add MLK_CONFIG_NO_RANDOMIZED_API with default not set
willieyz Sep 10, 2025
25d3218
Guard the `crypto_kem_keypair` and `crypto_kem_enc` from:
willieyz Sep 10, 2025
b4d8771
Add new example `basic_deterministic`
willieyz Sep 10, 2025
95d003e
CBMC: Increase the CBMC_OBJECT_BITS of `matvec_mul` to 12
willieyz Sep 11, 2025
111fbd9
Add `--exclude example` args for "PCT enabled" CI testing
willieyz Sep 11, 2025
f768bb5
Introduce explicit upper bounds on lengths of
rod-chapman Sep 16, 2025
61abb93
Removed un-wanted comment.
dannytsen Sep 22, 2025
6f1e95c
Merge branch 'pq-code-package:main' into main
dannytsen Sep 22, 2025
52b9c78
Removed unused comment lines.
dannytsen Sep 22, 2025
df55bea
Merge branch 'pq-code-package:main' into main
dannytsen Oct 8, 2025
33858ec
Fixed failure in INTT unit tests.
dannytsen Oct 8, 2025
615cf86
Merge branch 'main' into main
dannytsen Oct 9, 2025
2ccdfaf
Merge branch 'pq-code-package:main' into main
dannytsen Oct 18, 2025
7b09ee4
Fixed illegal instructions used for p8 arch, lxv and stxv.
dannytsen Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BIBLIOGRAPHY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ source code and documentation.
- [examples/basic_deterministic/mlkem_native/custom_no_randomized_config.h](examples/basic_deterministic/mlkem_native/custom_no_randomized_config.h)
- [integration/liboqs/config_aarch64.h](integration/liboqs/config_aarch64.h)
- [integration/liboqs/config_c.h](integration/liboqs/config_c.h)
- [integration/liboqs/config_ppc64le.h](integration/liboqs/config_ppc64le.h)
- [integration/liboqs/config_x86_64.h](integration/liboqs/config_x86_64.h)
- [mlkem/src/config.h](mlkem/src/config.h)
- [mlkem/src/kem.c](mlkem/src/kem.c)
Expand Down
6 changes: 6 additions & 0 deletions dev/ppc64le/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[//]: # (SPDX-License-Identifier: CC-BY-4.0)

# ppc64le backend (little endian)

This directory contains a native backend for little endian POWER 8 (ppc64le) and above systems.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed before, I couldn't yet run the code with power8 emulation, and I think you mentioned you only tested power9 and power10. Are you sure it works on power8?


53 changes: 53 additions & 0 deletions dev/ppc64le/meta.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) The mlkem-native project authors
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
*/

#ifndef MLK_DEV_PPC64LE_META_H
#define MLK_DEV_PPC64LE_META_H

/* Identifier for this backend so that source and assembly files
* in the build can be appropriately guarded. */
#define MLK_ARITH_BACKEND_PPC64LE_DEFAULT

#define MLK_ARITH_BACKEND_NAME PPC64LE_DEFAULT

/* Set of primitives that this backend replaces */
#define MLK_USE_NATIVE_NTT
#define MLK_USE_NATIVE_INTT
#define MLK_USE_NATIVE_POLY_REDUCE
#define MLK_USE_NATIVE_POLY_TOMONT

#if !defined(__ASSEMBLER__)
#include <string.h>
#include "../../common.h"
#include "../../params.h"
#include "../api.h"
#include "src/arith_native_ppc64le.h"

static MLK_INLINE int mlk_ntt_native(int16_t data[MLKEM_N])
{
mlk_ntt_ppc(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
}

static MLK_INLINE int mlk_intt_native(int16_t data[MLKEM_N])
{
mlk_intt_ppc(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
}

static MLK_INLINE int mlk_poly_reduce_native(int16_t data[MLKEM_N])
{
mlk_reduce_ppc(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
}

static MLK_INLINE int mlk_poly_tomont_native(int16_t data[MLKEM_N])
{
mlk_poly_tomont_ppc(data, mlk_ppc_qdata);
return MLK_NATIVE_FUNC_SUCCESS;
}
#endif /* !__ASSEMBLER__ */

#endif /* !MLK_DEV_PPC64LE_META_H */
24 changes: 24 additions & 0 deletions dev/ppc64le/src/arith_native_ppc64le.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2024-2025 The mlkem-native project authors
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef MLK_DEV_PPC64LE_SRC_ARITH_NATIVE_PPC64LE_H
#define MLK_DEV_PPC64LE_SRC_ARITH_NATIVE_PPC64LE_H

#include <stdint.h>
#include "../../../common.h"
#include "consts.h"

#define mlk_ntt_ppc MLK_NAMESPACE(ntt_ppc)
void mlk_ntt_ppc(int16_t *, const int16_t *);

#define mlk_intt_ppc MLK_NAMESPACE(intt_ppc)
void mlk_intt_ppc(int16_t *, const int16_t *);

#define mlk_reduce_ppc MLK_NAMESPACE(reduce_ppc)
void mlk_reduce_ppc(int16_t *r, const int16_t *);

#define mlk_poly_tomont_ppc MLK_NAMESPACE(poly_tomont_ppc)
void mlk_poly_tomont_ppc(int16_t *, const int16_t *);

#endif /* !MLK_DEV_PPC64LE_SRC_ARITH_NATIVE_PPC64LE_H */
155 changes: 155 additions & 0 deletions dev/ppc64le/src/consts.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
* Copyright (c) The mlkem-native project authors
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
*/

#include "../../../common.h"

#if defined(MLK_ARITH_BACKEND_PPC64LE_DEFAULT) && \
!defined(MLK_CONFIG_MULTILEVEL_NO_SHARED)

#include "consts.h"

MLK_ALIGN const int16_t mlk_ppc_qdata[1568] = {
/* -Q */
-3329, -3329, -3329, -3329, -3329, -3329, -3329, -3329,
/* QINV */
-3327, -3327, -3327, -3327, -3327, -3327, -3327, -3327,
/* Q */
3329, 3329, 3329, 3329, 3329, 3329, 3329, 3329,
/* const 20159 for reduce.S and intt */
20159, 20159, 20159, 20159, 20159, 20159, 20159, 20159,
/* const 1441 for intt */
1441, 1441, 1441, 1441, 1441, 1441, 1441, 1441,
/* for poly_tomont.S */
1353, 1353, 1353, 1353, 1353, 1353, 1353, 1353,
/* zetas */
/* For ntt Len=128, offset 96 */
-758, -758, -758, -758, -758, -758, -758, -758, -359, -359, -359, -359,
-359, -359, -359, -359, -1517, -1517, -1517, -1517, -1517, -1517, -1517,
-1517, 1493, 1493, 1493, 1493, 1493, 1493, 1493, 1493, 1422, 1422, 1422,
1422, 1422, 1422, 1422, 1422, 287, 287, 287, 287, 287, 287, 287, 287, 202,
202, 202, 202, 202, 202, 202, 202, -171, -171, -171, -171, -171, -171, -171,
-171, 622, 622, 622, 622, 622, 622, 622, 622, 1577, 1577, 1577, 1577, 1577,
1577, 1577, 1577, 182, 182, 182, 182, 182, 182, 182, 182, 962, 962, 962,
962, 962, 962, 962, 962, -1202, -1202, -1202, -1202, -1202, -1202, -1202,
-1202, -1474, -1474, -1474, -1474, -1474, -1474, -1474, -1474, 1468, 1468,
1468, 1468, 1468, 1468, 1468, 1468, 573, 573, 573, 573, 573, 573, 573, 573,
-1325, -1325, -1325, -1325, -1325, -1325, -1325, -1325, 264, 264, 264, 264,
264, 264, 264, 264, 383, 383, 383, 383, 383, 383, 383, 383, -829, -829,
-829, -829, -829, -829, -829, -829, 1458, 1458, 1458, 1458, 1458, 1458,
1458, 1458, -1602, -1602, -1602, -1602, -1602, -1602, -1602, -1602, -130,
-130, -130, -130, -130, -130, -130, -130, -681, -681, -681, -681, -681,
-681, -681, -681, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 732, 732,
732, 732, 732, 732, 732, 732, 608, 608, 608, 608, 608, 608, 608, 608, -1542,
-1542, -1542, -1542, -1542, -1542, -1542, -1542, 411, 411, 411, 411, 411,
411, 411, 411, -205, -205, -205, -205, -205, -205, -205, -205, -1571, -1571,
-1571, -1571, -1571, -1571, -1571, -1571, 1223, 1223, 1223, 1223, 1223,
1223, 1223, 1223, 652, 652, 652, 652, 652, 652, 652, 652, -552, -552, -552,
-552, -552, -552, -552, -552, 1015, 1015, 1015, 1015, 1015, 1015, 1015,
1015, -1293, -1293, -1293, -1293, -1293, -1293, -1293, -1293, 1491, 1491,
1491, 1491, 1491, 1491, 1491, 1491, -282, -282, -282, -282, -282, -282,
-282, -282, -1544, -1544, -1544, -1544, -1544, -1544, -1544, -1544, 516,
516, 516, 516, 516, 516, 516, 516, -8, -8, -8, -8, -8, -8, -8, -8, -320,
-320, -320, -320, -320, -320, -320, -320, -666, -666, -666, -666, -666,
-666, -666, -666, -1618, -1618, -1618, -1618, -1618, -1618, -1618, -1618,
-1162, -1162, -1162, -1162, -1162, -1162, -1162, -1162, 126, 126, 126, 126,
126, 126, 126, 126, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, -853,
-853, -853, -853, -853, -853, -853, -853, -90, -90, -90, -90, -90, -90, -90,
-90, -271, -271, -271, -271, -271, -271, -271, -271, 830, 830, 830, 830,
830, 830, 830, 830, 107, 107, 107, 107, 107, 107, 107, 107, -1421, -1421,
-1421, -1421, -1421, -1421, -1421, -1421, -247, -247, -247, -247, -247,
-247, -247, -247, -951, -951, -951, -951, -951, -951, -951, -951, -398,
-398, -398, -398, -398, -398, -398, -398, 961, 961, 961, 961, 961, 961, 961,
961, -1508, -1508, -1508, -1508, -1508, -1508, -1508, -1508, -725, -725,
-725, -725, -725, -725, -725, -725, 448, 448, 448, 448, 448, 448, 448, 448,
-1065, -1065, -1065, -1065, -1065, -1065, -1065, -1065, 677, 677, 677, 677,
677, 677, 677, 677, -1275, -1275, -1275, -1275, -1275, -1275, -1275, -1275,
/* For intt Len=2, offset IZETA_NTT_OFFSET64 */
-1103, -1103, -1103, -1103, 430, 430, 430, 430, 555, 555, 555, 555, 843,
843, 843, 843, -1251, -1251, -1251, -1251, 871, 871, 871, 871, 1550, 1550,
1550, 1550, 105, 105, 105, 105, 422, 422, 422, 422, 587, 587, 587, 587, 177,
177, 177, 177, -235, -235, -235, -235, -291, -291, -291, -291, -460, -460,
-460, -460, 1574, 1574, 1574, 1574, 1653, 1653, 1653, 1653, -246, -246,
-246, -246, 778, 778, 778, 778, 1159, 1159, 1159, 1159, -147, -147, -147,
-147, -777, -777, -777, -777, 1483, 1483, 1483, 1483, -602, -602, -602,
-602, 1119, 1119, 1119, 1119, -1590, -1590, -1590, -1590, 644, 644, 644,
644, -872, -872, -872, -872, 349, 349, 349, 349, 418, 418, 418, 418, 329,
329, 329, 329, -156, -156, -156, -156, -75, -75, -75, -75, 817, 817, 817,
817, 1097, 1097, 1097, 1097, 603, 603, 603, 603, 610, 610, 610, 610, 1322,
1322, 1322, 1322, -1285, -1285, -1285, -1285, -1465, -1465, -1465, -1465,
384, 384, 384, 384, -1215, -1215, -1215, -1215, -136, -136, -136, -136,
1218, 1218, 1218, 1218, -1335, -1335, -1335, -1335, -874, -874, -874, -874,
220, 220, 220, 220, -1187, -1187, -1187, -1187, -1659, -1659, -1659, -1659,
-1185, -1185, -1185, -1185, -1530, -1530, -1530, -1530, -1278, -1278, -1278,
-1278, 794, 794, 794, 794, -1510, -1510, -1510, -1510, -854, -854, -854,
-854, -870, -870, -870, -870, 478, 478, 478, 478, -108, -108, -108, -108,
-308, -308, -308, -308, 996, 996, 996, 996, 991, 991, 991, 991, 958, 958,
958, 958, -1460, -1460, -1460, -1460, 1522, 1522, 1522, 1522, 1628, 1628,
1628, 1628,
/* For intt Len=2, offset IZETA_NTT_OFFSET127 */
1628, 1628, 1628, 1628, 1522, 1522, 1522, 1522, -1460, -1460, -1460, -1460,
958, 958, 958, 958, 991, 991, 991, 991, 996, 996, 996, 996, -308, -308,
-308, -308, -108, -108, -108, -108, 478, 478, 478, 478, -870, -870, -870,
-870, -854, -854, -854, -854, -1510, -1510, -1510, -1510, 794, 794, 794,
794, -1278, -1278, -1278, -1278, -1530, -1530, -1530, -1530, -1185, -1185,
-1185, -1185, -1659, -1659, -1659, -1659, -1187, -1187, -1187, -1187, 220,
220, 220, 220, -874, -874, -874, -874, -1335, -1335, -1335, -1335, 1218,
1218, 1218, 1218, -136, -136, -136, -136, -1215, -1215, -1215, -1215, 384,
384, 384, 384, -1465, -1465, -1465, -1465, -1285, -1285, -1285, -1285, 1322,
1322, 1322, 1322, 610, 610, 610, 610, 603, 603, 603, 603, 1097, 1097, 1097,
1097, 817, 817, 817, 817, -75, -75, -75, -75, -156, -156, -156, -156, 329,
329, 329, 329, 418, 418, 418, 418, 349, 349, 349, 349, -872, -872, -872,
-872, 644, 644, 644, 644, -1590, -1590, -1590, -1590, 1119, 1119, 1119,
1119, -602, -602, -602, -602, 1483, 1483, 1483, 1483, -777, -777, -777,
-777, -147, -147, -147, -147, 1159, 1159, 1159, 1159, 778, 778, 778, 778,
-246, -246, -246, -246, 1653, 1653, 1653, 1653, 1574, 1574, 1574, 1574,
-460, -460, -460, -460, -291, -291, -291, -291, -235, -235, -235, -235, 177,
177, 177, 177, 587, 587, 587, 587, 422, 422, 422, 422, 105, 105, 105, 105,
1550, 1550, 1550, 1550, 871, 871, 871, 871, -1251, -1251, -1251, -1251, 843,
843, 843, 843, 555, 555, 555, 555, 430, 430, 430, 430, -1103, -1103, -1103,
-1103,
/* For intt Len=4 and others, offset IZETA_NTT_OFFSET63 */
-1275, -1275, -1275, -1275, -1275, -1275, -1275, -1275, 677, 677, 677, 677,
677, 677, 677, 677, -1065, -1065, -1065, -1065, -1065, -1065, -1065, -1065,
448, 448, 448, 448, 448, 448, 448, 448, -725, -725, -725, -725, -725, -725,
-725, -725, -1508, -1508, -1508, -1508, -1508, -1508, -1508, -1508, 961,
961, 961, 961, 961, 961, 961, 961, -398, -398, -398, -398, -398, -398, -398,
-398, -951, -951, -951, -951, -951, -951, -951, -951, -247, -247, -247,
-247, -247, -247, -247, -247, -1421, -1421, -1421, -1421, -1421, -1421,
-1421, -1421, 107, 107, 107, 107, 107, 107, 107, 107, 830, 830, 830, 830,
830, 830, 830, 830, -271, -271, -271, -271, -271, -271, -271, -271, -90,
-90, -90, -90, -90, -90, -90, -90, -853, -853, -853, -853, -853, -853, -853,
-853, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 1469, 126, 126, 126, 126,
126, 126, 126, 126, -1162, -1162, -1162, -1162, -1162, -1162, -1162, -1162,
-1618, -1618, -1618, -1618, -1618, -1618, -1618, -1618, -666, -666, -666,
-666, -666, -666, -666, -666, -320, -320, -320, -320, -320, -320, -320,
-320, -8, -8, -8, -8, -8, -8, -8, -8, 516, 516, 516, 516, 516, 516, 516,
516, -1544, -1544, -1544, -1544, -1544, -1544, -1544, -1544, -282, -282,
-282, -282, -282, -282, -282, -282, 1491, 1491, 1491, 1491, 1491, 1491,
1491, 1491, -1293, -1293, -1293, -1293, -1293, -1293, -1293, -1293, 1015,
1015, 1015, 1015, 1015, 1015, 1015, 1015, -552, -552, -552, -552, -552,
-552, -552, -552, 652, 652, 652, 652, 652, 652, 652, 652, 1223, 1223, 1223,
1223, 1223, 1223, 1223, 1223, -1571, -1571, -1571, -1571, -1571, -1571,
-1571, -1571, -205, -205, -205, -205, -205, -205, -205, -205, 411, 411, 411,
411, 411, 411, 411, 411, -1542, -1542, -1542, -1542, -1542, -1542, -1542,
-1542, 608, 608, 608, 608, 608, 608, 608, 608, 732, 732, 732, 732, 732, 732,
732, 732, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, -681, -681, -681,
-681, -681, -681, -681, -681, -130, -130, -130, -130, -130, -130, -130,
-130, -1602, -1602, -1602, -1602, -1602, -1602, -1602, -1602, 1458, 1458,
1458, 1458, 1458, 1458, 1458, 1458, -829, -829, -829, -829, -829, -829,
-829, -829, 383, 383, 383, 383, 383, 383, 383, 383, 264, 264, 264, 264, 264,
264, 264, 264, -1325, -1325, -1325, -1325, -1325, -1325, -1325, -1325, 573,
573, 573, 573, 573, 573, 573, 573, 1468, 1468, 1468, 1468, 1468, 1468, 1468,
1468, -1474, -1474, -1474, -1474, -1474, -1474, -1474, -1474, -1202, -1202,
-1202, -1202, -1202, -1202, -1202, -1202, 962, 962, 962, 962, 962, 962, 962,
962, 182, 182, 182, 182, 182, 182, 182, 182, 1577, 1577, 1577, 1577, 1577,
1577, 1577, 1577, 622, 622, 622, 622, 622, 622, 622, 622, -171, -171, -171,
-171, -171, -171, -171, -171, 202, 202, 202, 202, 202, 202, 202, 202, 287,
287, 287, 287, 287, 287, 287, 287, 1422, 1422, 1422, 1422, 1422, 1422, 1422,
1422, 1493, 1493, 1493, 1493, 1493, 1493, 1493, 1493, -1517, -1517, -1517,
-1517, -1517, -1517, -1517, -1517, -359, -359, -359, -359, -359, -359, -359,
-359, -758, -758, -758, -758, -758, -758, -758, -758};

#endif /* MLK_ARITH_BACKEND_PPC64LE_DEFAULT && \
!MLK_CONFIG_MULTILEVEL_NO_SHARED */
26 changes: 26 additions & 0 deletions dev/ppc64le/src/consts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) The mlkem-native project authors
* SPDX-License-Identifier: Apache-2.0 OR ISC OR MIT
*/

#ifndef MLK_DEV_PPC64LE_SRC_CONSTS_H
#define MLK_DEV_PPC64LE_SRC_CONSTS_H
#include "../../../common.h"

#define NQ_OFFSET 0
#define QINV_OFFSET 16
#define Q_OFFSET 32
#define C20159_OFFSET 48
#define C1441_OFFSET 64
#define C1353_OFFSET 80
#define ZETA_NTT_OFFSET 96
#define ZETA_NTT_OFFSET64 1104
#define IZETA_NTT_OFFSET127 1616
#define IZETA_NTT_OFFSET63 2128

#ifndef __ASSEMBLER__
#define mlk_ppc_qdata MLK_NAMESPACE(ppc_qdata)
extern const int16_t mlk_ppc_qdata[];
#endif

#endif /* !MLK_DEV_PPC64LE_SRC_CONSTS_H */
Loading