Skip to content
Merged
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
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:
build-essential \
cmake \
pkg-config \
libssl-dev \
libcppunit-dev
libssl-dev

- name: Configure (${{ matrix.name }})
run: |
Expand All @@ -50,7 +49,7 @@ jobs:
run: |
ctest --test-dir build-${{ matrix.name }} \
--output-on-failure \
-R 'test_kryzhovnik|test_kryzhovnik_wrapper|test_kryzhovnik_api|test_merkletree|test_adapters_smoke|test_adapters_batch'
-R 'test_kryzhovnik|test_kryzhovnik_wrapper|test_kryzhovnik_api|test_adapters_smoke|test_adapters_batch|test_streebog|test_merkle|test_batch_signing'

- name: Benchmark smoke (${{ matrix.name }})
run: |
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@
path = third_party/kryzhovnik
url = https://github.com/cherninkiy/kryzhovnik-wrapper-tc26
branch = main
[submodule "third_party/iaik_merkle_tree"]
path = third_party/iaik_merkle_tree
url = https://github.com/IAIK/merkle-tree.git
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ The goal is to measure the speedup of signing a batch of messages with a single

## Features

- (planned) Generic Merkle tree implementation (wrapper around [IAIK/merkle-tree](https://github.com/IAIK/merkle-tree))
- (planned) Hash abstraction layer (supports **Streebog** via Hypericum implementation, SHA-256 for fallback/testing)
- Generic Merkle tree implementation integrated in `src/merkle`
- Batch signing core integrated in `src/batch_signing*`
- Batch signature format: `root_signature + list_of_proofs` (with metadata framing for serialization)
- Hash abstraction layer (supports **Streebog** and test hash backends)
- Signature abstraction layer for Russian PQC:
- [Shipovnik](https://github.com/QAPP-tech/shipovnik_tc26)
- [Hypericum](https://github.com/QAPP-tech/hypericum_tc26)
Expand Down Expand Up @@ -59,9 +61,14 @@ batch-pqc/
│ ├── shipovnik/ → https://github.com/cherninkiy/shipovnik-wrapper-tc26
│ ├── hypericum/ → https://github.com/cherninkiy/hypericum-wrapper-tc26
│ ├── kryzhovnik/ → https://github.com/cherninkiy/kryzhovnik-wrapper-tc26
│ └── iaik_merkle_tree/ → https://github.com/IAIK/merkle-tree
├── src/
│ ├── signature/ # signature provider adapters
│ ├── batch_bench.h # unified adapter contract (bb_status, bb_algorithm)
│ ├── merkle/ # Merkle tree implementation
│ ├── batch_signing.h # batch signing API
│ ├── batch_signing.c # batch signing implementation
│ ├── batch_adapters.h # callbacks to connect batch layer with bb_algorithm API
│ ├── batch_adapters.c # adapter callback implementation
│ └── utils/ # timers, message generators
├── bench/ # benchmarking executables
├── tests/ # unit tests (CTest)
Expand All @@ -76,7 +83,7 @@ batch-pqc/

- Linux x86_64 (tested on Ubuntu 22.04)
- CMake 3.14+, GCC/Clang with C11 support
- OpenSSL (for SHA-256 fallback, optional)
- OpenSSL development package (`libssl-dev`) for Kryzhovnik build

### Quick Start

Expand Down Expand Up @@ -142,8 +149,8 @@ After running benchmarks, the `results/` directory will contain:
- [x] Adapters for Shipovnik / Hypericum / Kryzhovnik with unified `bb_status`
- [x] Detached/status-return integration APIs wired through wrapper submodules
- [x] Sequential benchmark `bench_seq` with warmup and corrected signature-size metric
- [x] Test coverage: `test_adapters_smoke`, `test_adapters_batch`, `test_kryzhovnik*`, `test_merkletree`
- [ ] Merkle-based batch signer/verifier implementation
- [x] Merkle-based batch signer/verifier implementation
- [x] Test coverage: `test_adapters_smoke`, `test_adapters_batch`, `test_kryzhovnik*`, `test_merkle`, `test_batch_signing`, `test_streebog`
- [ ] Sequential vs real batch signing benchmark comparison
- [ ] Final report (PDF)

Expand All @@ -164,12 +171,10 @@ This project is licensed under the **MIT License** – see [LICENSE](LICENSE) fi

Third-party components have their own licenses:

- `iaik_merkle_tree` – public domain / BSD-like
- PQC implementations – please refer to each submodule's license

## Acknowledgments

- [IAIK/merkle-tree](https://github.com/IAIK/merkle-tree) – Merkle tree implementation (public domain / BSD‑like)
- [QAPP-tech](https://github.com/QAPP-tech) – Shipovnik and Hypericum (including Streebog hash) PQC signatures
- [Elena Kirshanova](https://github.com/ElenaKirshanova) – original Kryzhovnik implementation: [pqc_LWR_signature](https://github.com/ElenaKirshanova/pqc_LWR_signature)
- A compatibility fork is used in this project to integrate Kryzhovnik with Hypericum and Shipovnik
Expand Down
21 changes: 13 additions & 8 deletions README_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
## Возможности


- (планируется) Реализация дерева Меркла (обёртка над [IAIK/merkle-tree](https://github.com/IAIK/merkle-tree))
- (планируется) Слой абстракции хеш-функций (поддерживает **Стрибог** через реализацию Hypericum, SHA-256 для тестов)
- Реализация дерева Меркла в `src/merkle`
- Ядро пакетной подписи в `src/batch_signing*`
- Формат пакетной подписи: `подпись_корня + список_доказательств` (с метаданными для сериализации)
- Слой абстракции хеш-функций (поддерживает **Стрибог** и тестовые hash-backend'ы)
- Слой абстракции подписей для российских PQC:
- [Шиповник](https://github.com/QAPP-tech/shipovnik_tc26)
- [Гиперикум](https://github.com/QAPP-tech/hypericum_tc26)
Expand Down Expand Up @@ -63,9 +65,14 @@ batch-pqc/
│ ├── shipovnik/ → https://github.com/cherninkiy/shipovnik-wrapper-tc26
│ ├── hypericum/ → https://github.com/cherninkiy/hypericum-wrapper-tc26
│ ├── kryzhovnik/ → https://github.com/cherninkiy/kryzhovnik-wrapper-tc26
│ └── iaik_merkle_tree/ → https://github.com/IAIK/merkle-tree
├── src/
│ ├── signature/ # адаптеры для алгоритмов подписи
│ ├── batch_bench.h # единый контракт адаптеров (bb_status, bb_algorithm)
│ ├── merkle/ # реализация дерева Меркла
│ ├── batch_signing.h # API пакетной подписи
│ ├── batch_signing.c # реализация пакетной подписи
│ ├── batch_adapters.h # callback-интерфейс для интеграции с bb_algorithm API
│ ├── batch_adapters.c # реализация callback-адаптеров
│ └── utils/ # таймеры, генераторы сообщений
├── bench/ # исполняемые файлы бенчмарков
├── tests/ # модульные тесты (CTest)
Expand All @@ -80,7 +87,7 @@ batch-pqc/

- Linux x86_64 (тестировалось на Ubuntu 22.04)
- CMake 3.14+, GCC/Clang с поддержкой C11
- OpenSSL (для SHA-256, опционально)
- OpenSSL development package (`libssl-dev`) для сборки Kryzhovnik

### Быстрый старт

Expand Down Expand Up @@ -147,8 +154,8 @@ cmake --build build --parallel
- [x] Адаптеры для Шиповника / Гиперикума / Крыжовника с единым `bb_status`
- [x] Подключены detached/status-return API через wrapper-сабмодули
- [x] Последовательный бенчмарк `bench_seq` с warmup и исправленной метрикой размера подписей
- [x] Покрытие тестами: `test_adapters_smoke`, `test_adapters_batch`, `test_kryzhovnik*`, `test_merkletree`
- [ ] Реализация пакетной подписи/верификации на основе дерева Меркла
- [x] Реализация пакетной подписи/верификации на основе дерева Меркла
- [x] Покрытие тестами: `test_adapters_smoke`, `test_adapters_batch`, `test_kryzhovnik*`, `test_merkle`, `test_batch_signing`, `test_streebog`
- [ ] Сравнение бенчмарков: последовательная vs реальная пакетная подпись
- [ ] Финальный отчёт (PDF)

Expand All @@ -170,12 +177,10 @@ cmake --build build --parallel

Сторонние компоненты имеют свои лицензии:

- `iaik_merkle_tree` – public domain / BSD-like
- Реализации PQC – смотрите лицензии в каждом субмодуле

## Благодарности

- [IAIK/merkle-tree](https://github.com/IAIK/merkle-tree) – реализация дерева Меркла (public domain / BSD‑like)
- [QAPP-tech](https://github.com/QAPP-tech) – подписи Шиповник и Гиперикум (включая хеш Стрибог)
- [Elena Kirshanova](https://github.com/ElenaKirshanova) – оригинальная реализация Крыжовника: [pqc_LWR_signature](https://github.com/ElenaKirshanova/pqc_LWR_signature)
- В этом проекте используется форк совместимости для интеграции Крыжовника с Гиперикум и Шиповник
Expand Down
29 changes: 29 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,32 @@ target_link_libraries(batch_bench_adapters
)

target_compile_features(batch_bench_adapters PRIVATE c_std_99)

add_library(batch_signing_core STATIC
merkle/merkle.c
batch_signing.c
)

target_include_directories(batch_signing_core
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

target_compile_features(batch_signing_core PRIVATE c_std_99)

add_library(batch_adapters STATIC
batch_adapters.c
)

target_include_directories(batch_adapters
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(batch_adapters
PUBLIC
batch_signing_core
batch_bench_adapters
)
Comment thread
cherninkiy marked this conversation as resolved.

target_compile_features(batch_adapters PRIVATE c_std_99)
72 changes: 72 additions & 0 deletions src/batch_adapters.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include "batch_adapters.h"

int batch_bb_adapter_init(batch_bb_adapter_ctx* ctx,
const bb_algorithm* algorithm,
const uint8_t* sk,
size_t sk_len,
const uint8_t* pk,
size_t pk_len) {
if (ctx == NULL || algorithm == NULL || algorithm->sign == NULL || algorithm->verify == NULL) {
return -1;
}
if (sk == NULL || pk == NULL) {
return -1;
}

ctx->algorithm = algorithm;
ctx->sk = sk;
ctx->sk_len = sk_len;
ctx->pk = pk;
ctx->pk_len = pk_len;
return 0;
}

size_t batch_bb_signature_capacity(const batch_bb_adapter_ctx* ctx) {
if (ctx == NULL || ctx->algorithm == NULL) {
return 0;
}
return ctx->algorithm->signature_bytes;
}

int batch_bb_sign_callback(void* user_ctx,
const uint8_t* msg,
size_t msg_len,
uint8_t* sig,
size_t sig_capacity,
size_t* sig_len) {
batch_bb_adapter_ctx* ctx = (batch_bb_adapter_ctx*)user_ctx;
bb_status status;

if (ctx == NULL || ctx->algorithm == NULL || ctx->algorithm->sign == NULL ||
msg == NULL || sig == NULL || sig_len == NULL) {
return 0;
}

status = ctx->algorithm->sign(ctx->sk,
ctx->sk_len,
ctx->pk,
ctx->pk_len,
msg,
msg_len,
sig,
sig_capacity,
sig_len);
return status == BB_OK ? 1 : 0;
}

int batch_bb_verify_callback(void* user_ctx,
const uint8_t* msg,
size_t msg_len,
const uint8_t* sig,
size_t sig_len) {
batch_bb_adapter_ctx* ctx = (batch_bb_adapter_ctx*)user_ctx;
bb_status status;

if (ctx == NULL || ctx->algorithm == NULL || ctx->algorithm->verify == NULL ||
msg == NULL || sig == NULL) {
return 0;
}

status = ctx->algorithm->verify(ctx->pk, ctx->pk_len, msg, msg_len, sig, sig_len);
return status == BB_OK ? 1 : 0;
}
40 changes: 40 additions & 0 deletions src/batch_adapters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef BATCH_ADAPTERS_H
#define BATCH_ADAPTERS_H

#include "batch_bench.h"
#include "batch_signing.h"

#include <stddef.h>
#include <stdint.h>

typedef struct batch_bb_adapter_ctx {
const bb_algorithm* algorithm;
const uint8_t* sk;
size_t sk_len;
const uint8_t* pk;
size_t pk_len;
} batch_bb_adapter_ctx;

int batch_bb_adapter_init(batch_bb_adapter_ctx* ctx,
const bb_algorithm* algorithm,
const uint8_t* sk,
size_t sk_len,
const uint8_t* pk,
size_t pk_len);

size_t batch_bb_signature_capacity(const batch_bb_adapter_ctx* ctx);

int batch_bb_sign_callback(void* user_ctx,
const uint8_t* msg,
size_t msg_len,
uint8_t* sig,
size_t sig_capacity,
size_t* sig_len);

int batch_bb_verify_callback(void* user_ctx,
const uint8_t* msg,
size_t msg_len,
const uint8_t* sig,
size_t sig_len);

#endif
Loading
Loading