3个版本
0.1.1 | 2022年11月16日 |
---|---|
0.1.0 | 2022年10月19日 |
0.1.0-beta.0 | 2022年7月6日 |
#2563 in 密码学
用于concrete
1MB
13K SLoC
concrete Integer
concrete-integer
是基于 concrete-shortint
的 Rust 库,它通过组合多个 shortint
来处理任意大小的加密整数。
许可证
本软件在 BSD-3-Clause-Clear 许可证下分发。如有任何问题,请联系我们:hello@zama.ai
。
lib.rs
:
欢迎使用 concrete-integer
文档!
描述
该库使您能够对加密整数执行模运算。
它允许在不受信任的服务器上执行整数电路,因为电路的输入输出都保持私有。
数据在客户端加密后发送到服务器。在服务器端,所有计算都在密文上进行
快速示例
以下代码片段展示了如何生成密钥并同态运行一个整数电路。
use concrete_integer::gen_keys_radix;
use concrete_shortint::parameters::PARAM_MESSAGE_2_CARRY_2;
//4 blocks for the radix decomposition
let number_of_blocks = 4;
// Modulus = (2^2)*4 = 2^8 (from the parameters chosen and the number of blocks
let modulus = 1 << 8;
// Generation of the client/server keys, using the default parameters:
let (mut client_key, mut server_key) =
gen_keys_radix(&PARAM_MESSAGE_2_CARRY_2, number_of_blocks);
let msg1 = 153;
let msg2 = 125;
// Encryption of two messages using the client key:
let ct_1 = client_key.encrypt(msg1);
let ct_2 = client_key.encrypt(msg2);
// Homomorphic evaluation of an integer circuit (here, an addition) using the server key:
let ct_3 = server_key.unchecked_add(&ct_1, &ct_2);
// Decryption of the ciphertext using the client key:
let output = client_key.decrypt(&ct_3);
assert_eq!(output, (msg1 + msg2) % modulus);
警告
此代码使用来自 concrete-shortint
的加密参数。目前,基数方法仅与消息和进位缓冲区大小相同的参数集兼容。
依赖项
~8MB
~151K SLoC