Skip to content

Commit 7070fff

Browse files
committed
add ML-KEM as an option for base OT
This makes the base OT post-quantum secure by utilizing ML-KEM key encapsulation via https://crates.io/crates/ml-kem. We keep the Simplest OT as default base OT and make ML-KEM optional by adding compile-time features for different variants (k = 512/768/1024). References: MR19: https://eprint.iacr.org/2019/706 FIPS 203: https://csrc.nist.gov/pubs/fips/203/final libOTe: https://github.com/osu-crypto/libOTe/blob/d0e499206d1d4d16c6b4ca6c0e712490e0632f80/thirdparty/KyberOT/KyberOT.c#L40-L41 ML-KEM implementation: https://github.com/RustCrypto/KEMs/blob/5a7f3ab7af5420cacca9befc9212532e4c7f6ca1/ml-kem/src/ ml-kem crate: https://crates.io/crates/ml-kem module-lattice crate: https://crates.io/crates/module-lattice
1 parent ace68ce commit 7070fff

File tree

13 files changed

+898
-24
lines changed

13 files changed

+898
-24
lines changed

.github/workflows/pull_request.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ jobs:
3535
if: ${{ matrix.os == 'windows-latest' }}
3636
uses: ilammy/setup-nasm@72793074d3c8cdda771dba85f6deafe00623038b # 1.5.2
3737

38-
- name: Run tests
39-
run: cargo test --workspace --verbose --all-features --no-fail-fast
38+
- name: Run tests (all features)
39+
run: cargo test --workspace --verbose --all-features --no-fail-fast ${{ runner.os == 'macOS' && '-- --test-threads=1' || '' }}
40+
41+
- name: Run tests (no features)
42+
run: cargo test --workspace --verbose --no-fail-fast ${{ runner.os == 'macOS' && '-- --test-threads=1' || '' }}
4043

4144
miri:
4245
name: Miri

.github/workflows/push.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ jobs:
2323
- name: Show CPU info
2424
run: lscpu
2525

26-
- name: Test
26+
- name: Run tests (all features)
2727
run: cargo test --workspace --verbose --all-features --no-fail-fast
28+
29+
- name: Run tests (no features)
30+
run: cargo test --workspace --verbose --no-fail-fast

Cargo.lock

Lines changed: 83 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ bincode = "1.3.3"
2020
bitvec = "1.0.1"
2121
blake3 = "1.5.5"
2222
bytemuck = { version = "1.25.0", features = ["must_cast"] }
23+
cfg-if = "1"
2324
cpufeatures = "0.3.0"
2425
criterion = { version = "0.8", features = ["async_tokio", "html_reports"] }
2526
cryprot-codes = { version = "0.2.2", path = "cryprot-codes" }
@@ -31,6 +32,9 @@ fastdivide = "0.4.2"
3132
futures = "0.3.30"
3233
hybrid-array = { version = "0.4.7", features = ["bytemuck"] }
3334
libc = "0.2.181"
35+
ml-kem = "0.2.2"
36+
module-lattice = "0.1.0"
37+
sha3 = "0.10.8"
3438
ndarray = "0.17.2"
3539
num-traits = "0.2.19"
3640
rand = "0.10.0"
@@ -40,7 +44,8 @@ rayon = "1.10.0"
4044
s2n-quic = "1.74.0"
4145
seq-macro = "=0.3.6"
4246
serde = "1.0.203"
43-
subtle = "2.6.1"
47+
serde_bytes = "0.11.19"
48+
subtle = { version = "2.6.1", features = ["const-generics"] }
4449
thiserror = "2.0.18"
4550
tokio = "1.50.0"
4651
tokio-serde = "0.9.0"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The `cryprot` crates implement several **cryp**tographic **prot**ocols and utili
1111
| [`cryprot-net`] | Networking abstractions built atop [s2n-quic](https://docs.rs/s2n-quic/latest/s2n_quic/). | [![crates.io](https://img.shields.io/crates/v/cryprot-net)](https://crates.io/crates/cryprot-net) | [![docs.rs](https://img.shields.io/docsrs/cryprot-net)](https://docs.rs/cryprot-net) |
1212
| [`cryprot-pprf`] | Distributed PPRF implementation used in Silent OT [[BCG+19]](https://eprint.iacr.org/2019/1159), based on [libOTe](https://github.com/osu-crypto/libOTe). | [![crates.io](https://img.shields.io/crates/v/cryprot-pprf)](https://crates.io/crates/cryprot-pprf) | [![docs.rs](https://img.shields.io/docsrs/cryprot-pprf)](https://docs.rs/cryprot-pprf) |
1313
| [`cryprot-codes`] | Expand-convolute linear code [[RRT23]](https://eprint.iacr.org/2023/882), based on [libOTe](https://github.com/osu-crypto/libOTe), used in Silent OT. | [![crates.io](https://img.shields.io/crates/v/cryprot-codes)](https://crates.io/crates/cryprot-codes) | [![docs.rs](https://img.shields.io/docsrs/cryprot-codes)](https://docs.rs/cryprot-codes) |
14-
| [`cryprot-ot`] | Oblivious transfer implementations:<br>• Base OT: "Simplest OT" [[CO15]](https://eprint.iacr.org/2015/267)<br>• OT extensions: [[IKNP03]](https://www.iacr.org/archive/crypto2003/27290145/27290145.pdf)<br>• Malicious OT extension: [[KOS15]](https://eprint.iacr.org/2015/546.pdf)<br>• Silent OT extension: [[BCG+19]](https://eprint.iacr.org/2019/1159) Silent OT using [[RRT23]](https://eprint.iacr.org/2023/882) code and optional [[YWL+20]](https://dl.acm.org/doi/pdf/10.1145/3372297.3417276) consistency check for malicious security. | [![crates.io](https://img.shields.io/crates/v/cryprot-ot)](https://crates.io/crates/cryprot-ot) | [![docs.rs](https://img.shields.io/docsrs/cryprot-ot)](https://docs.rs/cryprot-ot) |
14+
| [`cryprot-ot`] | Oblivious transfer implementations:<br>• Base OT: "Simplest OT" [[CO15]](https://eprint.iacr.org/2015/267)<br>• Base OT (post-quantum, optional): [ML-KEM](https://crates.io/crates/ml-kem) based OT [[FIPS 203]](https://csrc.nist.gov/pubs/fips/203/final)<br>• OT extensions: [[IKNP03]](https://www.iacr.org/archive/crypto2003/27290145/27290145.pdf)<br>• Malicious OT extension: [[KOS15]](https://eprint.iacr.org/2015/546.pdf)<br>• Silent OT extension: [[BCG+19]](https://eprint.iacr.org/2019/1159) Silent OT using [[RRT23]](https://eprint.iacr.org/2023/882) code and optional [[YWL+20]](https://dl.acm.org/doi/pdf/10.1145/3372297.3417276) consistency check for malicious security. | [![crates.io](https://img.shields.io/crates/v/cryprot-ot)](https://crates.io/crates/cryprot-ot) | [![docs.rs](https://img.shields.io/docsrs/cryprot-ot)](https://docs.rs/cryprot-ot) |
1515

1616
Documentation for the latest main branch state is available [here](https://robinhundt.github.io/CryProt/cryprot_ot/).
1717
## Platform Support
@@ -45,7 +45,7 @@ Silent OT will perform faster for smaller numbers of OTs at slightly increased c
4545

4646
Our OT implementations should be on par or faster than those in libOTe. In the future we want to benchmark libOTe on the same hardware for a fair comparison.
4747

48-
**Base OT Benchmark:**
48+
**Base OT Benchmark (Simplest OT):**
4949

5050
| Benchmark | Mean Time (ms) |
5151
|---------------|---------------|

cryprot-ot/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ version = "0.2.2"
99
authors.workspace = true
1010
repository.workspace = true
1111

12+
[features]
13+
# ML-KEM-based base OT. Pick only one variant.
14+
ml-kem-base-ot-512 = ["_ml-kem-base-ot"]
15+
ml-kem-base-ot-768 = ["_ml-kem-base-ot"]
16+
ml-kem-base-ot-1024 = ["_ml-kem-base-ot"]
17+
# Internal feature — do not enable directly.
18+
_ml-kem-base-ot = ["dep:ml-kem", "dep:module-lattice", "dep:hybrid-array", "dep:sha3"]
19+
1220
[lints]
1321
workspace = true
1422

@@ -19,13 +27,20 @@ bench = false
1927
[dependencies]
2028
bitvec = { workspace = true, features = ["serde"] }
2129
bytemuck.workspace = true
30+
cfg-if.workspace = true
2231
cryprot-codes.workspace = true
2332
cryprot-core = { workspace = true, features = ["tokio-rayon"] }
2433
cryprot-net.workspace = true
2534
cryprot-pprf.workspace = true
2635
curve25519-dalek = { workspace = true, features = ["rand_core", "serde"] }
2736
futures.workspace = true
37+
hybrid-array = { workspace = true, optional = true }
38+
ml-kem = { workspace = true, optional = true }
39+
module-lattice = { workspace = true, optional = true }
2840
rand.workspace = true
41+
sha3 = { workspace = true, optional = true }
42+
serde_bytes.workspace = true
43+
serde = { workspace = true, features = ["derive"] }
2944
subtle.workspace = true
3045
thiserror.workspace = true
3146
tokio = { workspace = true, features = ["io-util"] }

cryprot-ot/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Oblivious transfer implementations. Currently implemented are the following:
77

88
- base OT: "Simplest OT" [[CO15](https://eprint.iacr.org/2015/267)]
9+
- base OT (post-quantum, optional): [ML-KEM-768](https://crates.io/crates/ml-kem) based OT [[FIPS 203](https://csrc.nist.gov/pubs/fips/203/final)]
910
- semi-honest OT extension: optimized [[IKNP03](https://www.iacr.org/archive/crypto2003/27290145/27290145.pdf)] protocol
1011
- malicious OT extension: optimized [[KOS15]](https://eprint.iacr.org/2015/546.pdf) protocol
1112
- silent OT extension: [[BCG+19](https://eprint.iacr.org/2019/1159)] silent OT using [[RRT23](https://eprint.iacr.org/2023/882)] code (semi-honest and malicious with [[YWL+20](https://dl.acm.org/doi/pdf/10.1145/3372297.3417276)] consistency check)
@@ -27,7 +28,7 @@ Silent OT will perform faster for smaller numbers of OTs at slightly increased c
2728

2829
Our OT implementations should be on par or faster than those in libOTe. In the future we want to benchmark libOTe on the same hardware for a fair comparison.
2930

30-
**Base OT Benchmark:**
31+
**Base OT Benchmark (Simplest OT):**
3132

3233
| Benchmark | Mean Time (ms) |
3334
|---------------|---------------|

cryprot-ot/benches/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use cryprot_core::{Block, alloc::HugePageMemory};
88
use cryprot_net::testing::{init_bench_tracing, local_conn};
99
use cryprot_ot::{
1010
CotReceiver, CotSender, RotReceiver, RotSender,
11-
base::SimplestOt,
1211
extension::{
1312
MaliciousOtExtensionReceiver, MaliciousOtExtensionSender, SemiHonestOtExtensionReceiver,
1413
SemiHonestOtExtensionSender,
@@ -18,6 +17,7 @@ use cryprot_ot::{
1817
MaliciousSilentOtReceiver, MaliciousSilentOtSender, SemiHonestSilentOtReceiver,
1918
SemiHonestSilentOtSender,
2019
},
20+
simplest_ot::SimplestOt,
2121
};
2222
use rand::{SeedableRng, rngs::StdRng};
2323
use tokio::runtime::{self, Runtime};

0 commit comments

Comments
 (0)