Skip to content

Commit 4f863ce

Browse files
hanno-beckermkannwischer
authored andcommitted
CBMC: Add proof for poly_permute_bitrev_to_custom_harness
Dull since this is a no-op in the C backend, but still needed for completeness. Signed-off-by: Hanno Becker <[email protected]>
1 parent d660fde commit 4f863ce

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed

proofs/cbmc/ct_get_optblocker_i32/ct_get_optblocker_i32_harness.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
#include "verify.h"
66

7-
void harness(void) { uint8_t x = mlk_ct_get_optblocker_u8(); }
7+
void harness(void) { int32_t x = mlk_ct_get_optblocker_i32(); }
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
include ../Makefile_params.common
4+
5+
HARNESS_ENTRY = harness
6+
HARNESS_FILE = poly_permute_bitrev_to_custom_harness
7+
8+
# This should be a unique identifier for this proof, and will appear on the
9+
# Litani dashboard. It can be human-readable and contain spaces if you wish.
10+
PROOF_UID = mlk_poly_permute_bitrev_to_custom
11+
12+
DEFINES +=
13+
INCLUDES +=
14+
15+
REMOVE_FUNCTION_BODY +=
16+
17+
PROOF_SOURCES += $(PROOFDIR)/$(HARNESS_FILE).c
18+
PROJECT_SOURCES += $(SRCDIR)/mlkem/indcpa.c
19+
20+
CHECK_FUNCTION_CONTRACTS=mlk_poly_permute_bitrev_to_custom
21+
USE_FUNCTION_CONTRACTS=
22+
APPLY_LOOP_CONTRACTS=on
23+
USE_DYNAMIC_FRAMES=1
24+
25+
# Disable any setting of EXTERNAL_SAT_SOLVER, and choose SMT backend instead
26+
EXTERNAL_SAT_SOLVER=
27+
CBMCFLAGS=--smt2
28+
29+
# For this proof we tell CBMC to
30+
# 1. not decompose arrays into their individual cells
31+
# 2. to model arrays directly as SMT-lib arrays
32+
# 3. to slice constraints that are not in the cone of influence of the proof obligations
33+
# These options simplify them modelling of arrays and produce much more compact
34+
# SMT files, leaving all array-type reasoning to the SMT solver.
35+
#
36+
# For functions that use large and multi-dimensional arrays, this yields
37+
# a substantial improvement in proof performance.
38+
CBMCFLAGS += --no-array-field-sensitivity --arrays-uf-always --slice-formula
39+
40+
FUNCTION_NAME = mlk_poly_permute_bitrev_to_custom
41+
42+
# If this proof is found to consume huge amounts of RAM, you can set the
43+
# EXPENSIVE variable. With new enough versions of the proof tools, this will
44+
# restrict the number of EXPENSIVE CBMC jobs running at once. See the
45+
# documentation in Makefile.common under the "Job Pools" heading for details.
46+
# EXPENSIVE = true
47+
48+
# This function is large enough to need...
49+
CBMC_OBJECT_BITS = 8
50+
51+
# If you require access to a file-local ("static") function or object to conduct
52+
# your proof, set the following (and do not include the original source file
53+
# ("mlkem/poly.c") in PROJECT_SOURCES).
54+
# REWRITTEN_SOURCES = $(PROOFDIR)/<__SOURCE_FILE_BASENAME__>.i
55+
# include ../Makefile.common
56+
# $(PROOFDIR)/<__SOURCE_FILE_BASENAME__>.i_SOURCE = $(SRCDIR)/mlkem/poly.c
57+
# $(PROOFDIR)/<__SOURCE_FILE_BASENAME__>.i_FUNCTIONS = foo bar
58+
# $(PROOFDIR)/<__SOURCE_FILE_BASENAME__>.i_OBJECTS = baz
59+
# Care is required with variables on the left-hand side: REWRITTEN_SOURCES must
60+
# be set before including Makefile.common, but any use of variables on the
61+
# left-hand side requires those variables to be defined. Hence, _SOURCE,
62+
# _FUNCTIONS, _OBJECTS is set after including Makefile.common.
63+
64+
include ../Makefile.common
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2024-2025 The mlkem-native project authors
2+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
// SPDX-License-Identifier: MIT-0
4+
5+
#include <stdint.h>
6+
#include "params.h"
7+
8+
void mlk_poly_permute_bitrev_to_custom(int16_t data[MLKEM_N]);
9+
10+
void harness(void)
11+
{
12+
int16_t data[MLKEM_N];
13+
mlk_poly_permute_bitrev_to_custom(data);
14+
}

0 commit comments

Comments
 (0)