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
25 changes: 15 additions & 10 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,51 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
title: ""
labels: bug
assignees: ''

assignees: ""
---

<!--
Thank you for filing a bug report! Please provide a short summary of the bug,
along with any information that might be required to replicate the bug, and if you already
along with any information that might be required to replicate the bug, and if you already
found a solution / workaround, please provide it.

If you feel like any of the provided sections are not needed or should be extended,
If you feel like any of the provided sections are not needed or should be extended,
feel free to adapt this form.
-->

**Describe the bug**

<!-- A clear and concise description of what the bug is. -->

**To Reproduce**

<!-- Steps to reproduce the behavior: -->
<!-- These steps are even more helpful if you provide some code for each step along the way using: -->

```rust
// write your code here
```

**Expected behavior**
<!-- A clear and concise description of what you expect to happen and
why the current behaviour does not match this criteria. -->

<!-- A clear and concise description of what you expect to happen and
why the current behaviour does not match this criteria. -->

**Screenshots**
<!-- If applicable, add screenshots to help explain your problem. -->

<!-- If applicable, add screenshots to help explain your problem. -->

**Desktop (please complete the following information):**
- OS: <!-- [e.g. iOS] -->
- Version of qFALL-crypto: <!-- [e.g. 1.0] -->

- OS: <!-- [e.g. iOS] -->
- Version of qFALL-tools: <!-- [e.g. 1.0] -->

**Additional context**

<!-- Add any other context about the problem here. -->

**Solution**

<!-- If you already have a solution in mind, feel free to share it here. -->
6 changes: 3 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: qFALL-crypto
message: 'University Paderborn, Codes and Cryptography'
title: qFALL-tools
message: "University Paderborn, Codes and Cryptography"
type: software
authors:
- given-names: Laurens
Expand All @@ -20,5 +20,5 @@ authors:
family-names: Schmidt
- given-names: Niklas
family-names: Siemer
repository-code: 'https://github.com/qfall/crypto'
repository-code: "https://github.com/qfall/crypto"
license: MPL-2.0
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "qfall-crypto"
name = "qfall-tools"
version = "0.1.0"
edition = "2021"
autobenches = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
qfall-math = { git = "https://github.com/qfall/math", rev="cac834c705ed05ce96262ebca72ec0dbe36720d9" }
qfall-math = { git = "https://github.com/qfall/math", rev="5f50c9cd31c869462d959774fb4b51fcd1727dbe" }
sha2 = "0.10.6"
serde = {version="1.0", features=["derive"]}
serde_json = "1.0"
Expand Down
52 changes: 21 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# qFALL-crypto
# qFALL-tools

[![made-with-rust](https://img.shields.io/badge/Made%20with-Rust-1f425f.svg)](https://www.rust-lang.org/)
[![CI](https://github.com/qfall/crypto/actions/workflows/push.yml/badge.svg?branch=dev)](https://github.com/qfall/crypto/actions/workflows/pull_request.yml)
[![CI](https://github.com/qfall/tools/actions/workflows/push.yml/badge.svg?branch=dev)](https://github.com/qfall/tools/actions/workflows/pull_request.yml)
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)

This repository is currently being developed by the project group [qFALL - quantum resistant fast lattice library](https://cs.uni-paderborn.de/cuk/lehre/veranstaltungen/ws-2022-23/project-group-qfall) in the winter term 2022 and summer term 2023 by the Codes and Cryptography research group in Paderborn.

The main objective of this project is to provide researchers and students with the possibility to easily and quickly prototype (lattice-based) cryptography.

## Disclaimer

Currently, we are in the development phase and interfaces might change.
Feel free to check out the current progress, but be aware, that the content will
change in the upcoming weeks and months. An official release will most likely be published in the second half of 2023.
Expand All @@ -19,53 +21,41 @@ Please refer to [our website](https://qfall.github.io/) as central information p
To install and add our library to your project, please refer to [our tutorial](https://qfall.github.io/book/index.html).
It provides a step-by-step guide to install the required libraries and gives further insights in the usage of our crates.

## What does qFALL-crypto offer?
## What does qFALL-tools offer?

qFALL-crypto offers a variety of implementations of cryptographic schemes, constructions, and primitives.
qFALL-tools offers a variety of implementations of commonly used tools in lattice-based cryptography.
We provide a brief overview in the following list.
For a more detailed description, please refer to [our tutorial section](https://qfall.github.io/book/crypto/features.html).

Full-fledged Cryptographic Features
- [Public Key Encryption](https://github.com/qfall/crypto/blob/dev/src/construction/pk_encryption.rs)
- [LWE Encryption](https://github.com/qfall/crypto/blob/dev/src/construction/pk_encryption/regev.rs)
- [Dual LWE Encryption](https://github.com/qfall/crypto/blob/dev/src/construction/pk_encryption/dual_regev.rs)
- [LPR Encryption](https://github.com/qfall/crypto/blob/dev/src/construction/pk_encryption/lpr.rs)
- [Ring-based LPR Encryption](https://github.com/qfall/crypto/blob/dev/src/construction/pk_encryption/ring_lpr.rs)
- [CCA-secure Encryption](https://github.com/qfall/crypto/blob/dev/src/construction/pk_encryption/ccs_from_ibe.rs)
- [Signatures](https://github.com/qfall/crypto/blob/dev/src/construction/signature.rs)
- [Full-Domain Hash (FDH)](https://github.com/qfall/crypto/blob/dev/src/construction/signature/fdh.rs)
- [Probabilistic FDH (PFDH)](https://github.com/qfall/crypto/blob/dev/src/construction/signature/pfdh.rs)
- [Ring-based FDH](https://github.com/qfall/crypto/blob/dev/src/construction/signature/fdh/gpv_ring.rs)
- [Identity Based Encryption](https://github.com/qfall/crypto/blob/dev/src/construction/identity_based_encryption.rs)
- [From Dual LWE Encryption](https://github.com/qfall/crypto/blob/dev/src/construction/identity_based_encryption/dual_regev_ibe.rs)
- [Hash Functions](https://github.com/qfall/crypto/blob/dev/src/construction/hash.rs)
- [SIS-Hash Function](https://github.com/qfall/crypto/blob/dev/src/construction/hash/sis.rs)
- [SHA-256-based Hash](https://github.com/qfall/crypto/blob/dev/src/construction/hash/sha256.rs)

Building Blocks and Primitives
- [Preimage Samplable Functions (PSF)](https://github.com/qfall/crypto/blob/dev/src/primitive/psf.rs)
- [Trapdoors](https://github.com/qfall/crypto/blob/dev/src/sample/g_trapdoor.rs)
- [G-trapdoor incl. short basis](https://github.com/qfall/crypto/blob/dev/src/sample/g_trapdoor/gadget_classical.rs)
- [Ring-based G-trapdoor incl. short basis](https://github.com/qfall/crypto/blob/dev/src/sample/g_trapdoor/gadget_ring.rs)
- [Preimage Samplable Functions (PSF)](https://github.com/qfall/tools/blob/dev/src/primitive/psf.rs)
- [Trapdoors](https://github.com/qfall/tools/blob/dev/src/sample/g_trapdoor.rs)
- [G-trapdoor incl. short basis](https://github.com/qfall/tools/blob/dev/src/sample/g_trapdoor/gadget_classical.rs)
- [Ring-based G-trapdoor incl. short basis](https://github.com/qfall/tools/blob/dev/src/sample/g_trapdoor/gadget_ring.rs)
- [Utility functions for quick instantiations](https://github.com/qfall/tools/blob/dev/src/utils/)
- [Common moduli](https://github.com/qfall/tools/blob/dev/src/utils/common_moduli.rs)
- [Rotation matrices](https://github.com/qfall/tools/blob/dev/src/utils/rotation_matrix.rs)
- [Common encodings](https://github.com/qfall/tools/blob/dev/src/utils/common_encodings.rs)

## License
This library is distributed under the **Mozilla Public License Version 2.0** which can be found here [License](https://github.com/qfall/crypto/blob/dev/LICENSE).

This library is distributed under the **Mozilla Public License Version 2.0** which can be found here [License](https://github.com/qfall/tools/blob/dev/LICENSE).
Permissions of this weak copyleft license are conditioned on making available source code of licensed files and modifications of those files under the same license (or in certain cases, one of the GNU licenses). Copyright and license notices must be preserved. Contributors provide an express grant of patent rights. However, a larger work using the licensed work may be distributed under different terms and without source code for files added in the larger work.

## Citing

Please use the following bibtex entry to cite [qFALL-crypto](https://github.com/qfall/crypto):
Please use the following bibtex entry to cite [qFALL-tools](https://github.com/qfall/tools):

```text
@misc{qFALL-crypto,
@misc{qFALL-tools,
author = {Porzenheim, Laurens and Beckmann, Marvin and Kramer, Paul and Milewski, Phil and Moog, Sven and Schmidt, Marcel and Siemer, Niklas},
title = {qFALL-crypto v0.0},
howpublished = {Online: \url{https://github.com/qfall/crypto}},
title = {qFALL-tools v0.0},
howpublished = {Online: \url{https://github.com/qfall/tools}},
month = Mar,
year = 2023,
note = {University Paderborn, Codes and Cryptography}
}
```

## Get in Touch

One can contact the members of the project group with our mailing list `pg-qfall(at)lists.upb.de`.
88 changes: 50 additions & 38 deletions benches/README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,94 @@
<!---
Copyright © 2023 Sven Moog

This file is part of qFALL-crypto.
This file is part of qFALL-tools.

qFALL-crypto is free software: you can redistribute it and/or modify it under
qFALL-tools is free software: you can redistribute it and/or modify it under
the terms of the Mozilla Public License Version 2.0 as published by the
Mozilla Foundation. See <https://mozilla.org/en-US/MPL/2.0/>.
-->

# How to run benchmarks:

## Criterion
We use criterion for statistical analysis. A plotting library has to be installed to generate graphs. You can find more information and help here:

We use criterion for statistical analysis. A plotting library has to be installed to generate graphs. You can find more information and help here:

- [Criterion-rs GitHub](https://github.com/bheisler/criterion.rs)
- [Cargo-criterion GitHub](https://github.com/bheisler/cargo-criterion)
- [Criterion Book](https://bheisler.github.io/criterion.rs/book/criterion_rs.html) (!Watchout for the criterion version, as of writing this the book is not on the latest version!)


### Commands
a) ```cargo criterion <benchmark name regex>```

a) `cargo criterion <benchmark name regex>`
Has to be installed with `cargo install cargo-criterion`.
Pros:

- You can remove `features = ["html_reports"]` from the `Cargo.toml` leading to a (slightly) faster compile times.
- Criterion aims to move to just using cargo criterion
- The large Probability Density Function graph shows the samples and marks the outlier categorization boarders.
- Can use either [gnuplot](http://www.gnuplot.info/) or [plotters](https://crates.io/crates/plotters)

b) ```cargo bench <benchmark name regex>```
b) `cargo bench <benchmark name regex>`
Pros:

- Can visualize the change in performance compared to previous run or other baseline
Cons:
Cons:
- Can only use [gnuplot](http://www.gnuplot.info/)

## Flamegraph

You can also run the benchmarks using the profiler flamegraph. Details can be found here:

- [Flamegraph GitHub](https://github.com/flamegraph-rs/flamegraph).
This provides insights on the execution time of the executed functions and their subroutines.
This provides insights on the execution time of the executed functions and their subroutines.

Note: Flamegraph does not work in WSL

### Command
```cargo flamegraph --freq 63300 --bench benchmarks -- --bench --profile-time 5 <benchmark name regex>```
Generates a flamegraph that allows to approximate how long each function executes. The accuracy of the approximation is better the more samples are produced. This can be improved by

`cargo flamegraph --freq 63300 --bench benchmarks -- --bench --profile-time 5 <benchmark name regex>`
Generates a flamegraph that allows to approximate how long each function executes. The accuracy of the approximation is better the more samples are produced. This can be improved by

- increasing the sample frequency (`--freq 63300`), This frequency is throttled to the highest possible frequency which depends on the cpu, cpu-temperature, power settings and much more...
- increasing `profile-time` (in seconds). This is how long the benchmark code will be executed.
This parameter also disables the statistical analysis of criterion which prevents it from showing up in the graph.
This parameter is optional, but suggested.
This parameter also disables the statistical analysis of criterion which prevents it from showing up in the graph.
This parameter is optional, but suggested.

The flamegraph can be overwhelming since it exposes a lot of internal workings of rust, criterion, and more.
The easiest way to find the function you are looking for is to search for it with `Ctrl + F`.
You have to enter a part of the rust function name or regex (not the benchmark name).

# How to create benchmarks

## No appropriate file exists so far:
1. create the file
2. Insert in new file:
``` rust
use criterion::*;

criterion_group!(benches);
```
3. Insert in [benchmarks.rs](/benches/benchmarks.rs):
``` rust
pub mod <new_file_name>;
```
and `<new_file_name>::benches` in the `criterion_main!` macro.

1. create the file
2. Insert in new file:

```rust
use criterion::*;

criterion_group!(benches);
```

3. Insert in [benchmarks.rs](/benches/benchmarks.rs):
```rust
pub mod <new_file_name>;
```
and `<new_file_name>::benches` in the `criterion_main!` macro.

## Appropriately named benchmark file exists in `/benches` (e.g. `integer.rs`)
1. Create a function that performs the functionality that should be benchmarked (called `do_stuff` below).
2. Add a function to handle the interaction with criterion.
e.g.:
``` rust
/// Add Comment describing the benchmark here
pub fn bench_do_stuff(c: &mut Criterion) {
c.bench_function("<benchmark name here>", |b| b.iter(|| do_stuff()));
}
```
The benchmark name specified here is later used to select which benchmark to run and also displayed in the output.
This function can also look differently, for example, because it uses [criterion groups](https://docs.rs/criterion/latest/criterion/struct.BenchmarkGroup.html).
3. Add function created in step 2 in the `criterion_group!` macro (bottom of file).

1. Create a function that performs the functionality that should be benchmarked (called `do_stuff` below).
2. Add a function to handle the interaction with criterion.
e.g.:
```rust
/// Add Comment describing the benchmark here
pub fn bench_do_stuff(c: &mut Criterion) {
c.bench_function("<benchmark name here>", |b| b.iter(|| do_stuff()));
}
```
The benchmark name specified here is later used to select which benchmark to run and also displayed in the output.
This function can also look differently, for example, because it uses [criterion groups](https://docs.rs/criterion/latest/criterion/struct.BenchmarkGroup.html).
3. Add function created in step 2 in the `criterion_group!` macro (bottom of file).
9 changes: 3 additions & 6 deletions benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// Copyright © 2023 Sven Moog
//
// This file is part of qFALL-crypto.
// This file is part of qFALL-tools.
//
// qFALL-crypto is free software: you can redistribute it and/or modify it under
// qFALL-tools is free software: you can redistribute it and/or modify it under
// the terms of the Mozilla Public License Version 2.0 as published by the
// Mozilla Foundation. See <https://mozilla.org/en-US/MPL/2.0/>.
//! This file collects the benchmarks from other files.

use criterion::criterion_main;

pub mod k_pke;
pub mod pfdh;
pub mod psf;
pub mod regev;

criterion_main! {regev::benches, pfdh::benches, k_pke::benches, psf::benches}
criterion_main! {psf::benches}
Loading
Loading