Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 45 additions & 0 deletions .github/workflows/test-ref.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests for ref implementation

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
size:
- 512
- 768
- 1024
steps:
- uses: actions/checkout@v4
- name: Run make
run: |
make -C ref clean
make -C ref nistkat
- name: Copy req file
run: |
if [ ${{ matrix.size }} -eq 512 ]; then
req=1632
elif [ ${{ matrix.size }} -eq 768 ]; then
req=2400
else
req=3168
fi
cp Kyber_KAT/Kyber${{ matrix.size }}/PQCkemKAT_${req}.req ref/
- name: Run PQCgenKAT_kem
run: |
cd ref
chmod +x ./nistkat/PQCgenKAT_kem${{ matrix.size }}
./nistkat/PQCgenKAT_kem${{ matrix.size }}
- name: Verify KAT output
run: |
if [ ${{ matrix.size }} -eq 512 ]; then
diff ref/PQCkemKAT_1632.rsp Kyber_KAT/Kyber512/PQCkemKAT_1632.rsp
elif [ ${{ matrix.size }} -eq 768 ]; then
diff ref/PQCkemKAT_2400.rsp Kyber_KAT/Kyber768/PQCkemKAT_2400.rsp
else
diff ref/PQCkemKAT_3168.rsp Kyber_KAT/Kyber1024/PQCkemKAT_3168.rsp
fi
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.html).

### Summary
This version introduces modifications to the `ref` implementation for performance analysis and benchmarking purposes. The core cryptographic logic of the original Kyber algorithm remains unchanged. All modifications are confined to the `ref` directory and supplementary testing scripts.

### Added
- **Performance Benchmarking Framework:**
- Introduced a `timing_info_t` struct in `ref/kem.h` to capture execution time for key generation, encapsulation, and decapsulation steps.
- Integrated `clock_gettime` with `CLOCK_MONOTONIC` in `ref/kem.c` to precisely measure the duration of `crypto_kem_keypair`, `crypto_kem_enc`, and `crypto_kem_dec`. This required adding `#include <time.h>` and defining `_POSIX_C_SOURCE`.
- Added `print_timing_info()` function to display aggregated timing results.
- **Automated Testing Support:**
- Added `run_test` function prototype in `ref/kem.h` to facilitate running tests multiple times for stable performance metrics.

### Changed
- **Disabled Debug Outputs:**
- The extensive `printf` statements previously used for tracing the algorithm's flow in `ref/kem.c` and `ref/indcpa.c` have been disabled to allow for clean performance measurement. The original versions with these outputs are preserved in `kem.c.old` and `indcpa.c.old` for reference.
- **Code Formatting:**
- Applied consistent code formatting (e.g., spacing, newlines) across multiple files in the `ref` directory to improve readability.
- **Makefile Adjustments:**
- Modified `ref/Makefile` to disable the compilation of `test_vectors` targets, streamlining the build process for performance testing.

### Removed
- (No features removed from the core implementation)

### Acknowledgements
This project is a fork of the official [pq-crystals/kyber](https://github.com/pq-crystals/kyber) repository. The modifications, available at [quannguyen247/kyber-dev](https://github.com/quannguyen247/kyber-dev), are focused on performance analysis and benchmarking. The core cryptographic logic of the original public domain implementation of CRYSTALS-Kyber remains unchanged.
Loading