3 releases

0.1.1 Nov 16, 2022
0.1.0 Oct 19, 2022
0.1.0-beta.0 Jul 6, 2022

#2378 in Cryptography

Download history 18/week @ 2023-10-18 20/week @ 2023-10-25 15/week @ 2023-11-01 19/week @ 2023-11-08 14/week @ 2023-11-15 23/week @ 2023-11-22 31/week @ 2023-11-29 14/week @ 2023-12-06 22/week @ 2023-12-13 19/week @ 2023-12-20 15/week @ 2023-12-27 14/week @ 2024-01-03 19/week @ 2024-01-10 16/week @ 2024-01-17 19/week @ 2024-01-24 14/week @ 2024-01-31

70 downloads per month
Used in 2 crates



concrete Shortint

concrete-shortint is a Rust library based on concrete-core with the goal of providing an abstraction layer that provides "short integer" types.

By "short integer", we mean unsigned integers, with usually less than 8 bits and that fits on a single LWE ciphertext.

The intended target audience for this library is people with cryptography knowledge.


This software is distributed under the BSD-3-Clause-Clear license. If you have any questions, please contact us at hello@zama.ai.


Welcome the the concrete-shortint documentation!


This library makes it possible to execute modular operations over encrypted short integer.

It allows to execute an integer circuit on an untrusted server because both circuit inputs and outputs are kept private.

Data are encrypted on the client side, before being sent to the server. On the server side every computation is performed on ciphertexts.

The server however, has to know the integer circuit to be evaluated. At the end of the computation, the server returns the encryption of the result to the user.


This crates exposes two type of keys:

  • The [ClientKey] is used to encrypt and decrypt and has to be kept secret;
  • The [ServerKey] is used to perform homomorphic operations on the server side and it is meant to be published (the client sends it to the server).

Quick Example

The following piece of code shows how to generate keys and run a small integer circuit homomorphically.

use concrete_shortint::{gen_keys, Parameters};

// We generate a set of client/server keys, using the default parameters:
let (mut client_key, mut server_key) = gen_keys(Parameters::default());

let msg1 = 1;
let msg2 = 0;

// We use the client key to encrypt two messages:
let ct_1 = client_key.encrypt(msg1);
let ct_2 = client_key.encrypt(msg2);

// We use the server public key to execute an integer circuit:
let ct_3 = server_key.unchecked_add(&ct_1, &ct_2);

// We use the client key to decrypt the output of the circuit:
let output = client_key.decrypt(&ct_3);
assert_eq!(output, 1);


~112K SLoC