https://github.com/lattice-based-cryptography/module-lwe
Implementation of module-LWE encryption method in Rust.
https://github.com/lattice-based-cryptography/module-lwe
lattice-based-cryptography module-lwe rust
Last synced: over 1 year ago
JSON representation
Implementation of module-LWE encryption method in Rust.
- Host: GitHub
- URL: https://github.com/lattice-based-cryptography/module-lwe
- Owner: lattice-based-cryptography
- License: mit
- Created: 2024-12-25T16:52:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-18T19:02:24.000Z (over 1 year ago)
- Last Synced: 2025-02-18T19:39:39.623Z (over 1 year ago)
- Topics: lattice-based-cryptography, module-lwe, rust
- Language: Rust
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# module-LWE

[](https://opensource.org/licenses/MIT)
[](https://crates.io/crates/module-lwe)
Implmentation of lattice-based encryption method module-LWE in pure Rust.
**Description**: This provides the basic PKE (keygen, encryption, and decryption) operations for the module learning-with-errors scheme.
**Disclaimer**: This is not secure. It is not written in constant-time nor resistant to other side-channel attacks. This is intended for educational use and not for real-world applications.
**Usage**: In the `src` directory,
`cargo build`
To build the binary.
`cargo test`
- Performs keygen/encrypt/decrypt for a test message.
- Checks homomorphic addition and multiplcation hold for small values.
_Note_: Parameters optional via
- `--params `
where `n` is polynomial degree, `q` is modulus, `k` is the module rank.
If ommitted, the default parameters will be used.
`cargo run -- keygen`
This will generate a public/secret keypair.
`cargo run -- encrypt `
Generates the ciphertext.
`cargo run -- decrypt `
Decrypts the ciphertext given a secret key, printing the plaintext message.
**Benchmarks**:
| n | q | k | keygen | encrypt | decrypt | keygen_string | encrypt_string | decrypt_string |
|-----|-------|---|-----------|-----------|-----------|---------------|----------------|----------------|
| 256 | 12289 | 2 | 146.66 µs | 194.11 µs | 61.535 µs | 230.43 µs | 255.60 µs | 88.291 µs |
| 256 | 12289 | 4 | 562.56 µs | 622.29 µs | 118.37 µs | 819.22 µs | 787.60 µs | 167.38 µs |
| 384 | 12289 | 4 | 1.1774 ms | 1.3473 ms | 260.02 µs | 1.5546 ms | 1.5829 ms | 332.87 µs |
| 512 | 12289 | 4 | 1.1959 ms | 1.3597 ms | 260.77 µs | 1.7172 ms | 1.6976 ms | 356.75 µs |
| 512 | 12289 | 8 | 4.6993 ms | 4.8762 ms | 518.81 µs | 6.4127 ms | 5.7918 ms | 677.05 µs |