A Rust library for lattice-based additive homomorphic encryption.

Related tags

Cryptography Cupcake
Overview

Cupcake

Cupcake is an efficient Rust library for the (additive version of) Fan-Vercauteren homomorphic encryption scheme, offering capabilities to encrypt vectors, add/subtract two encrypted vectors, and rerandomize a ciphertext.

Requirements

Cupcake requires or works with

  • Mac OS X or Linux

Installation

Add the following line to the dependencies of your Cargo.toml:

Cupcake = "0.1.1"

Building from source

git clone https://github.com/facebookresearch/Cupcake
cd cupcake
cargo build --release

Examples

Several examples are included in examples/<name>.rs, and can be run via cargo run --example <name>

Documentation

Documentation on the API can be built from cargo doc.

Benchmarks and Tests

We have included benchmarks and tests for both homomorphic operations and underlying arithmetic operations. They can be run using cargo bench and cargo test.

Supported parameters

Currently, we provide only one set of secure parameter, namely FV::<Scalar>::default_2048();. This parameter set has an estimated security level of about 128 bits according to the homomorphic encryption security standards link. Use other parameters at your own risk! With the default parameter set, the plaintext type is vector of u8 with a fixed length 2048.

References

See the CONTRIBUTING file for how to help out.

License

Cupcake is MIT licensed, as found in the LICENSE file.

Comments
  • Crate naming conventions

    Crate naming conventions

    Hi @haochenuw,

    Not sure if you're aware of this, but just as a friendly heads up, in the Rust community, usually crate names are all in lowercase; this matches the naming scheme for modules. See here and here for details. (There is some disagreement on whether to choose kebab-case or snake_case, but in both cases the name is all lowercase.)

    Hence I'd like to suggest renaming the crate to cupcake to follow these conventions. Of course, feel free to close this issue if you'd like to keep the name as is.

    opened by Pratyush 2
  • Performance Optimizations

    Performance Optimizations

    • Use Lazy NTT
    • Other performance optimizations on random sampling, etc
    • Refactored benchmarks into scheme, polynomial, and integer level. Add micro benchmarks
    CLA Signed 
    opened by haochenuw 1
  • Implement `std::ops::{Add, Sub, AddAssign, SubAssign}` for ring elements and for ciphertexts

    Implement `std::ops::{Add, Sub, AddAssign, SubAssign}` for ring elements and for ciphertexts

    Rust enables overloading of the +, +=, -, and -= operators for user-defined types; this could be used to enable writing something like &a + &b, where a and b are ciphertexts, or even where b is a plaintext message. For ring-ring and ciphertext-ciphertext addition, the impl is fairly straightforward, along the lines of

    impl<'a, T> Add<&'a RqPoly<T>> for &'a RqPoly<T>
    where
        T: Clone + ArithUtils<T> + PartialEq,
    {
    	type Output = RqPoly<T>;
    	
    	fn add(self, other: &RqPoly<T>) -> RqPoly<T> {
    		let mut result = self.clone();
    		result.add_inplace(other);
    		result
    	}
    }
    
    impl<'a, T> Add<&'a FVCiphertext<T>> for &'a FVCiphertext<T>
    where
        T: Clone + ArithUtils<T> + PartialEq,
    {
    	type Output = FVCiphertext<T>;
    	
        fn add(self, other: &FVCiphertext<T>, ct2: &FVCiphertext<T>) -> FVCiphertext<T> {
        	let mut result = self.clone();
    		result.0.add_inplace(&other.0);
    		result.1.add_inplace(&other.1);
    		result
        }
    }
    

    For plaintext-ciphertext addition, it's a little more complicated as we need to pass in some additional data (namely, self.delta here), but if we include this data in the ciphertext or plaintext then overloading should be possible still.

    Let me know if a PR for some of these changes would be appreciated!

    opened by Pratyush 1
  • Adding serialization capability.

    Adding serialization capability.

    • Added support to serialize RqPolys and FVCiphertexts into Vec using the to_bytes function.
    • Added deserialization support through the API FV::from_bytes(& Vec).
    CLA Signed 
    opened by haochenuw 0
  • Question. using with serde or string

    Question. using with serde or string

    Hello. I only know the definition of Homomorphic Encryption. And I want to use a cupcake for my personal project.

    However, there are only a few simple examples. So, I leave a question here. I want to use a homomorphic encryption with a string or serde data. Can you give me some examples code?

    And is it right to ask here?

    opened by 1tang2bang92 0
  • sk and pk serialization/deserialization

    sk and pk serialization/deserialization

    Hello! Sorry for my (maybe) naive question but I am fairly new to the Rust language. I wanted to ask if there could be a method to serialize/deserialize the pk and the sk into a Vec. Maybe with serde::Serialize on the RqPoly struct and an sk.to_bytes() impl. Thanks in advance.

    opened by fuzzc0re 0
Releases(v0.2.1)
Owner
Facebook Research
Facebook Research
Authenticated Encryption with Associated Data Algorithms: high-level encryption ciphers

RustCrypto: Authenticated Encryption with Associated Data (AEAD) Algorithms Collection of Authenticated Encryption with Associated Data (AEAD) algorit

Rust Crypto 457 Jan 4, 2023
rabe is an Attribute Based Encryption library, written in Rust

Rabe rabe is a rust library implementing several Attribute Based Encryption (ABE) schemes using a modified version of the bn library of zcash (type-3

Fraunhofer AISEC 52 Dec 15, 2022
Chargo is a tool for file encryption/decryption. It's based on Argon2 and ChaCha20Poly1305 algorithms.

| Documentation Chargo is a tool for file encryption/decryption with password. It's based on Argon2 and ChaCha20Poly1305 algorithms. From arg2u with ♥

Airat Galiullin 7 Jan 1, 2023
A Rust Library of China's Standards of Encryption Algorithms (SM2/3/4)

Libsm Libsm is an open source pure rust library of China Cryptographic Algorithm Standards. It is completed by a collaborative effort between the Cryp

CITAHub 149 Dec 23, 2022
In addition to encryption library, pure RUST implementation of SSH-2.0 client protocol

In addition to encryption library, pure RUST implementation of SSH-2.0 client protocol

陈年旧事。 73 Jan 1, 2023
Rust library for practical time-lock encryption using `drand` threshold network

tlock-rs: Practical Timelock Encryption/Decryption in Rust This repo contains pure Rust implementation of drand/tlock scheme. It provides time-based e

Timofey 32 Jan 8, 2023
WebAssembly wrapper of the rage encryption library

rage-wasm: WebAssembly wrapper of rage rage is a simple, modern, and secure file encryption tool, using the age format. It features small explicit key

Kan-Ru Chen 35 Dec 16, 2022
Meta-repository for Miscreant: misuse-resistant symmetric encryption library with AES-SIV (RFC 5297) and AES-PMAC-SIV support

The best crypto you've never heard of, brought to you by Phil Rogaway A misuse resistant symmetric encryption library designed to support authenticate

miscreant. 480 Dec 8, 2022
A Rust binary for file encryption to multiple participants.

Kaspa-miner A Rust binary for file encryption to multiple participants. Installation From Sources With Rust's package manager cargo, you can install k

Elichai Turkel 31 Dec 30, 2022
A secure file encryption utility, written in rust.

Dexios Dexios What is it? Building notes Checksums Performance Output file sizes Environment Variables Key Inputs Usage Examples To Do What is it? Dex

brxken 156 Dec 22, 2022
A Rust Implementation of China's Standards of Encryption Algorithms(SM2/SM3/SM4)

gm-rs A Pure Rust High-Performance Implementation of China's Standards of Encryption Algorithms(SM2/SM3/SM4) Usage Add this to your Cargo.toml: [depen

null 2 Oct 27, 2022
Simple to use CLI tool that makes encryption easy! Written in Rust.

?? eme: Encryption Made Easy an extremely simple AES-256 encryption tool written in Rust Usage: # To encrypt: eme --encrypt secret.png # To decrypt: e

null 5 Jan 3, 2023
End-to-end encryption and mutual authentication for distributed applications.

✨ Hands-on Introduction: Build end-to-end encrypted, mutually-authenticated, secure messaging in Rust ✨ Rust and Elixir libraries for end-to-end encry

Ockam | Trust for Data-in-Motion 2.8k Jan 2, 2023
DexiosGUI - Simple cross-platform drag-and-drop Dexios file encryption

DexiosGUI Simple cross-platform drag-and-drop Dexios file encryption. Latest Windows x64 release is here. DexiosGUI is a Qt/C++ app for encrypt and de

Fabrice Corraire 4 Jul 25, 2022
The Hybrid Public Key Encryption (HPKE) standard in Python

Hybrid PKE The Hybrid Public Key Encryption (HPKE) standard in Python. hybrid_pke = hpke-rs ➕ PyO3 This library provides Python bindings to the hpke-r

Cape Privacy 4 Nov 7, 2022
Project Masterpass is a deterministic databaseless key management algorithm, aimed to help those who cannot protect their encryption keys in storage

Project Masterpass (working title) Attention! This project is still under heavy development, and SHOULD NOT be used in practice, as the algorithms cou

Gyorgy Wang 2 Sep 11, 2022
A simple to use, cross-platform aes encryption

About Project End to End encryption (AES) for multiple languages (cross-platform) with CBC Icon Item ?? Upcoming ⚖️ License ?? ChangeLog Usage (rust)

Zot Cryptography 2 Dec 15, 2022
Arkworks circuits for verifiable time-lock encryption

zk-timelock This repo contains arithmetic circuits for verifiable time-lock encryption made using arkworks-rs toolkit. For more details on such an enc

Timofey 68 Apr 5, 2023
This is a Order-preserving encryption (OPE) lib inspired by cryptdb's ope implementation.

Ope in rust This is an Order-preserving encryption (OPE) lib inspired by cryptdb's ope implementation. It is a pure rust implementation, no c dependen

Sentclose 8 Jul 19, 2023