plat-core 0.1.1

Core types and traits for the plat FHE compute engine
Documentation
  • Coverage
  • 91.04%
    61 out of 67 items documented0 out of 44 items with examples
  • Size
  • Source code size: 41.21 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 957.17 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 27s Average build duration of successful builds.
  • all releases: 30s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Ryujiyasu/plat
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Ryujiyasu

plat-core

Lattice cryptography primitives for Fully Homomorphic Encryption in pure Rust.

Part of the hyde ecosystem.

What's inside

Module What it does
poly Polynomial ring Z_q[X]/(X^N + 1) — add, sub, negacyclic multiply
ntt Number Theoretic Transform — O(N log N) polynomial multiplication
modular Modular arithmetic — add, sub, mul, pow, inv over Z_q
sampling Discrete Gaussian, uniform, ternary, binary sampling
params Parameter sets (test, research-grade N=2048)
rlwe Ring-LWE encryption — keygen, encrypt, decrypt, homomorphic add, scalar multiply

Usage

use plat_core::params::Params;
use plat_core::ntt::NttTables;
use plat_core::rlwe;
use rand::SeedableRng;
use rand::rngs::StdRng;

let params = Params::test_small();
let ntt = NttTables::new(&params);
let mut rng = StdRng::seed_from_u64(42);

// Key generation
let (sk, pk) = rlwe::keygen(&params, &ntt, &mut rng);

// Encrypt two values
let ct_a = rlwe::encrypt_u64(&params, &ntt, &pk, 5, &mut rng);
let ct_b = rlwe::encrypt_u64(&params, &ntt, &pk, 7, &mut rng);

// Homomorphic addition (no decryption!)
let ct_sum = rlwe::add(&params, &ct_a, &ct_b);

// Decrypt the result
let result = rlwe::decrypt_u64(&params, &ntt, &sk, &ct_sum);
assert_eq!(result, 12);

Design

  • Pure Rust — no C/C++ bindings, no FFI
  • MIT license — no copyleft restrictions
  • NTT uses the negacyclic twist for correct multiplication in Z_q[X]/(X^N + 1)
  • Gaussian sampling via Box-Muller (rand_distr)
  • All arithmetic uses u128 intermediates to avoid overflow

Parameters

Name N q σ Security Use
test_tiny 64 769 1.0 Unit tests
test_small 256 12289 1.0 Fast integration tests
research_2048 2048 132120577 3.2 ~100-bit Research prototype

Ecosystem

Crate Role
plat-core Lattice primitives (this crate)
plat-mkfhe Multi-Key FHE — compute across independent keys
hyde-plat Unified re-export of the full stack

License

MIT