Skip to content

Commit

Permalink
Rename polyvec -> poly_k
Browse files Browse the repository at this point in the history
Originally, polyvec was exclusively home to functions dealing with
the `polyvec` structure. Recent changes have invalidated that:
In addition to functions operating on `struct polyvec`, polyvec.[ch]
hosts all poly-related functionality that depends on the security-level
(e.g. the `poly_cbd_eta[12]` wrappers).

This commit renames `polyvec.[ch]` to `poly_k.[ch]` to reflect
this change in meaning.

This change was obtained by
- Manual renaming of the files `polyvec.[ch]` -> `poly_k.[ch]`
- ```bash
  git ls-files         \
     | xargs -I {} sh  \
       -c "sed -i '' 's/polyvec\.\([ch]\)/poly_k.\1/g' {}"
  ```
- Manual updating of symlinks in
  * examples/bring_your_own_fips202
  * examples/custom_backend

Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
  • Loading branch information
hanno-becker committed Jan 21, 2025
1 parent c3e44f0 commit 59b2ed6
Show file tree
Hide file tree
Showing 58 changed files with 82 additions and 82 deletions.
1 change: 1 addition & 0 deletions examples/bring_your_own_fips202/mlkem_native/poly_k.c
1 change: 1 addition & 0 deletions examples/bring_your_own_fips202/mlkem_native/poly_k.h
1 change: 0 additions & 1 deletion examples/bring_your_own_fips202/mlkem_native/polyvec.c

This file was deleted.

1 change: 0 additions & 1 deletion examples/bring_your_own_fips202/mlkem_native/polyvec.h

This file was deleted.

1 change: 1 addition & 0 deletions examples/custom_backend/mlkem_native/mlkem/poly_k.c
1 change: 1 addition & 0 deletions examples/custom_backend/mlkem_native/mlkem/poly_k.h
1 change: 0 additions & 1 deletion examples/custom_backend/mlkem_native/mlkem/polyvec.c

This file was deleted.

1 change: 0 additions & 1 deletion examples/custom_backend/mlkem_native/mlkem/polyvec.h

This file was deleted.

56 changes: 28 additions & 28 deletions examples/monolithic_build/mlkem_native_monobuild.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "mlkem/indcpa.c"
#include "mlkem/kem.c"
#include "mlkem/poly.c"
#include "mlkem/polyvec.c"
#include "mlkem/poly_k.c"
#include "mlkem/sampling.c"
#include "mlkem/verify.c"
#include "mlkem/zetas.c"
Expand Down Expand Up @@ -581,127 +581,127 @@
#undef UINT12_LIMIT
#endif

/* mlkem/polyvec.c */
/* mlkem/poly_k.c */
#if defined(poly_cbd_eta1)
#undef poly_cbd_eta1
#endif

/* mlkem/polyvec.c */
/* mlkem/poly_k.c */
#if defined(poly_cbd_eta2)
#undef poly_cbd_eta2
#endif

/* mlkem/polyvec.h */
#if defined(POLYVEC_H)
#undef POLYVEC_H
/* mlkem/poly_k.h */
#if defined(POLY_K_H)
#undef POLY_K_H
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(poly_compress_du)
#undef poly_compress_du
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(poly_compress_dv)
#undef poly_compress_dv
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(poly_decompress_du)
#undef poly_decompress_du
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(poly_decompress_dv)
#undef poly_decompress_dv
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(poly_getnoise_eta1122_4x)
#undef poly_getnoise_eta1122_4x
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(poly_getnoise_eta1_4x)
#undef poly_getnoise_eta1_4x
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(poly_getnoise_eta2)
#undef poly_getnoise_eta2
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(poly_getnoise_eta2_4x)
#undef poly_getnoise_eta2_4x
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec)
#undef polyvec
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_add)
#undef polyvec_add
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_basemul_acc_montgomery)
#undef polyvec_basemul_acc_montgomery
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_basemul_acc_montgomery_cached)
#undef polyvec_basemul_acc_montgomery_cached
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_compress_du)
#undef polyvec_compress_du
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_decompress_du)
#undef polyvec_decompress_du
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_frombytes)
#undef polyvec_frombytes
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_invntt_tomont)
#undef polyvec_invntt_tomont
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_mulcache)
#undef polyvec_mulcache
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_mulcache_compute)
#undef polyvec_mulcache_compute
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_ntt)
#undef polyvec_ntt
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_reduce)
#undef polyvec_reduce
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_tobytes)
#undef polyvec_tobytes
#endif

/* mlkem/polyvec.h */
/* mlkem/poly_k.h */
#if defined(polyvec_tomont)
#undef polyvec_tomont
#endif
Expand Down
2 changes: 1 addition & 1 deletion mlkem/indcpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "fips202/fips202x4.h"
#include "indcpa.h"
#include "poly.h"
#include "polyvec.h"
#include "poly_k.h"
#include "randombytes.h"
#include "sampling.h"
#include "symmetric.h"
Expand Down
2 changes: 1 addition & 1 deletion mlkem/indcpa.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdint.h>
#include "cbmc.h"
#include "common.h"
#include "polyvec.h"
#include "poly_k.h"

#define gen_matrix MLKEM_NAMESPACE_K(gen_matrix)
/*************************************************
Expand Down
2 changes: 1 addition & 1 deletion mlkem/native/aarch64/src/clean_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "arith_native_aarch64.h"

#include "../../../poly.h"
#include "../../../polyvec.h"
#include "../../../poly_k.h"

/* Set of primitives that this backend replaces */
#define MLKEM_USE_NATIVE_NTT
Expand Down
2 changes: 1 addition & 1 deletion mlkem/native/aarch64/src/opt_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "arith_native_aarch64.h"

#include "../../../poly.h"
#include "../../../polyvec.h"
#include "../../../poly_k.h"

/* Set of primitives that this backend replaces */
#define MLKEM_USE_NATIVE_NTT
Expand Down
2 changes: 1 addition & 1 deletion mlkem/native/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <stdint.h>
#include "../poly.h"
#include "../polyvec.h"
#include "../poly_k.h"

/*
* This is the C<->native interface allowing for the drop-in of
Expand Down
2 changes: 1 addition & 1 deletion mlkem/native/x86_64/src/arith_native_x86_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <immintrin.h>
#include <stdint.h>
#include "../../../polyvec.h"
#include "../../../poly_k.h"
#include "consts.h"

#define REJ_UNIFORM_AVX_NBLOCKS 3 /* See MLKEM_GEN_MATRIX_NBLOCKS */
Expand Down
2 changes: 1 addition & 1 deletion mlkem/native/x86_64/src/basemul.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#if defined(MLKEM_NATIVE_ARITH_BACKEND_X86_64_DEFAULT)

#include "../../../poly.h"
#include "../../../polyvec.h"
#include "../../../poly_k.h"

#include "arith_native_x86_64.h"
#include "consts.h"
Expand Down
2 changes: 1 addition & 1 deletion mlkem/native/x86_64/src/default_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <string.h>

#include "../../../poly.h"
#include "../../../polyvec.h"
#include "../../../poly_k.h"
#include "arith_native_x86_64.h"

#define MLKEM_USE_NATIVE_NTT_CUSTOM_ORDER
Expand Down
2 changes: 1 addition & 1 deletion mlkem/polyvec.c → mlkem/poly_k.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2024 The mlkem-native project authors
* SPDX-License-Identifier: Apache-2.0
*/
#include "polyvec.h"
#include "poly_k.h"
#include <stdint.h>
#include <string.h>
#include "arith_backend.h"
Expand Down
4 changes: 2 additions & 2 deletions mlkem/polyvec.h → mlkem/poly_k.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Copyright (c) 2024 The mlkem-native project authors
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef POLYVEC_H
#define POLYVEC_H
#ifndef POLY_K_H
#define POLY_K_H

#include <stdint.h>
#include "common.h"
Expand Down
2 changes: 1 addition & 1 deletion proofs/cbmc/matvec_mul/matvec_mul_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT-0

#include "indcpa.h"
#include "polyvec.h"
#include "poly_k.h"

#define matvec_mul MLKEM_NAMESPACE(matvec_mul)
void matvec_mul(polyvec *out, polyvec const *a, polyvec const *v,
Expand Down
2 changes: 1 addition & 1 deletion proofs/cbmc/poly_cbd_eta1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ REMOVE_FUNCTION_BODY +=
UNWINDSET +=

PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
PROJECT_SOURCES += $(SRCDIR)/mlkem/sampling.c $(SRCDIR)/mlkem/polyvec.c
PROJECT_SOURCES += $(SRCDIR)/mlkem/sampling.c $(SRCDIR)/mlkem/poly_k.c

CHECK_FUNCTION_CONTRACTS=$(MLKEM_NAMESPACE)poly_cbd_eta1
USE_FUNCTION_CONTRACTS=
Expand Down
2 changes: 1 addition & 1 deletion proofs/cbmc/poly_cbd_eta2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ REMOVE_FUNCTION_BODY +=
UNWINDSET +=

PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
PROJECT_SOURCES += $(SRCDIR)/mlkem/sampling.c $(SRCDIR)/mlkem/polyvec.c
PROJECT_SOURCES += $(SRCDIR)/mlkem/sampling.c $(SRCDIR)/mlkem/poly_k.c

# Only relevant for K=2 or K=4
ifeq ($(MLKEM_K),2)
Expand Down
2 changes: 1 addition & 1 deletion proofs/cbmc/poly_compress_du/poly_compress_du_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0 AND Apache-2.0

#include "polyvec.h"
#include "poly_k.h"

void harness(void)
{
Expand Down
2 changes: 1 addition & 1 deletion proofs/cbmc/poly_compress_dv/poly_compress_dv_harness.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0 AND Apache-2.0

#include "polyvec.h"
#include "poly_k.h"

void harness(void)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0 AND Apache-2.0

#include "polyvec.h"
#include "poly_k.h"

void harness(void)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0 AND Apache-2.0

#include "polyvec.h"
#include "poly_k.h"

void harness(void)
{
Expand Down
2 changes: 1 addition & 1 deletion proofs/cbmc/poly_getnoise_eta1122_4x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ REMOVE_FUNCTION_BODY +=
UNWINDSET +=

PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
PROJECT_SOURCES += $(SRCDIR)/mlkem/polyvec.c
PROJECT_SOURCES += $(SRCDIR)/mlkem/poly_k.c

# Only relevant for K=2
ifeq ($(MLKEM_K),2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0

#include <polyvec.h>
#include <poly_k.h>

void harness(void)
{
Expand Down
2 changes: 1 addition & 1 deletion proofs/cbmc/poly_getnoise_eta1_4x/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ REMOVE_FUNCTION_BODY +=
UNWINDSET +=

PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
PROJECT_SOURCES += $(SRCDIR)/mlkem/polyvec.c
PROJECT_SOURCES += $(SRCDIR)/mlkem/poly_k.c

CHECK_FUNCTION_CONTRACTS=$(MLKEM_NAMESPACE)poly_getnoise_eta1_4x
USE_FUNCTION_CONTRACTS=$(MLKEM_NAMESPACE)poly_cbd_eta1 $(MLKEM_NAMESPACE)shake256x4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0

#include <polyvec.h>
#include <poly_k.h>

void harness(void)
{
Expand Down
2 changes: 1 addition & 1 deletion proofs/cbmc/poly_getnoise_eta2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ REMOVE_FUNCTION_BODY +=
UNWINDSET +=

PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
PROJECT_SOURCES += $(SRCDIR)/mlkem/polyvec.c
PROJECT_SOURCES += $(SRCDIR)/mlkem/poly_k.c

# Only relevant for K=2 or K=4
ifeq ($(MLKEM_K),2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0

#include <polyvec.h>
#include <poly_k.h>

void harness(void)
{
Expand Down
Loading

0 comments on commit 59b2ed6

Please sign in to comment.