Top Related Projects
A library for lattice-based multiparty homomorphic encryption in Go
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
This is the development repository for the OpenFHE library. The current development version is 1.4.0 (released on August 18, 2025). The current stable version is 1.3.1 (released on July 11, 2025).
An FHE compiler for C++
Quick Overview
Lattigo is an open-source Go library for Homomorphic Encryption (HE) and Multiparty Computation (MPC). It provides implementations of lattice-based cryptographic schemes, focusing on practical applications of HE in cloud computing and data analysis while maintaining data privacy.
Pros
- Implements state-of-the-art lattice-based cryptographic schemes
- Written in Go, offering good performance and easy integration with other Go projects
- Supports both HE and MPC, allowing for versatile privacy-preserving computations
- Actively maintained with regular updates and improvements
Cons
- Requires a solid understanding of cryptography and HE concepts for effective use
- Limited documentation for advanced features and use cases
- Performance may be slower compared to some C/C++ implementations of similar algorithms
- Relatively young project, which may lead to API changes and potential instability
Code Examples
- Encrypting and decrypting a message:
params := bfv.NewDefaultParams()
sk := bfv.NewKeyGenerator(params).GenSecretKey()
encoder := bfv.NewEncoder(params)
encryptor := bfv.NewEncryptor(params, sk)
decryptor := bfv.NewDecryptor(params, sk)
plaintext := bfv.NewPlaintext(params)
encoder.EncodeUint([]uint64{123, 456, 789}, plaintext)
ciphertext := bfv.NewCiphertext(params, 1)
encryptor.Encrypt(plaintext, ciphertext)
decryptedPlaintext := bfv.NewPlaintext(params)
decryptor.Decrypt(ciphertext, decryptedPlaintext)
result := encoder.DecodeUint(decryptedPlaintext)
fmt.Println(result) // Output: [123 456 789]
- Performing homomorphic addition:
evaluator := bfv.NewEvaluator(params)
ciphertext1 := encryptor.EncryptNew(encoder.EncodeUintNew([]uint64{1, 2, 3}))
ciphertext2 := encryptor.EncryptNew(encoder.EncodeUintNew([]uint64{4, 5, 6}))
result := evaluator.AddNew(ciphertext1, ciphertext2)
decrypted := decryptor.DecryptNew(result)
fmt.Println(encoder.DecodeUint(decrypted)) // Output: [5 7 9]
- Generating and using a relinearization key:
kgen := bfv.NewKeyGenerator(params)
rlk := kgen.GenRelinearizationKey(sk)
ciphertext := encryptor.EncryptNew(encoder.EncodeUintNew([]uint64{2, 3, 4}))
squared := evaluator.MulNew(ciphertext, ciphertext)
relinearized := evaluator.RelinearizeNew(squared, rlk)
decrypted := decryptor.DecryptNew(relinearized)
fmt.Println(encoder.DecodeUint(decrypted)) // Output: [4 9 16]
Getting Started
- Install Go (version 1.16 or later)
- Install Lattigo:
go get -u github.com/tuneinsight/lattigo/v4
- Import Lattigo in your Go code:
import ( "github.com/tuneinsight/lattigo/v4/bfv" "github.com/tuneinsight/lattigo/v4/rlwe" )
- Start using Lattigo's cryptographic schemes and tools in your project.
Competitor Comparisons
A library for lattice-based multiparty homomorphic encryption in Go
Pros of Lattigo
- Established project with active development and community support
- Comprehensive documentation and examples for various use cases
- Regular updates and maintenance
Cons of Lattigo
- Learning curve for newcomers to homomorphic encryption
- Performance overhead compared to non-encrypted operations
Code Comparison
Both repositories appear to be the same project, so there isn't a relevant code comparison to make. The Lattigo library provides implementations for homomorphic encryption schemes. Here's a small example of using Lattigo for basic operations:
params := bfv.NewDefaultParams()
encoder := bfv.NewEncoder(params)
encryptor := bfv.NewEncryptor(params, pk)
plaintext := bfv.NewPlaintext(params)
encoder.EncodeUint([]uint64{1, 2, 3, 4}, plaintext)
ciphertext := encryptor.EncryptNew(plaintext)
This code snippet demonstrates initializing parameters, creating an encoder and encryptor, and performing a basic encryption operation using the BFV scheme in Lattigo.
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
Pros of SEAL
- More mature and widely adopted project with extensive documentation
- Supports a broader range of homomorphic encryption schemes
- Offers bindings for multiple programming languages (C++, C#, Python)
Cons of SEAL
- Steeper learning curve for beginners
- Less focus on lattice-based cryptography specifically
- Larger codebase, which may be overwhelming for some users
Code Comparison
SEAL (C++):
Encryptor encryptor(context, public_key);
Ciphertext encrypted;
encryptor.encrypt(plaintext, encrypted);
Lattigo (Go):
encryptor := ckks.NewEncryptor(params, pk)
ciphertext := encryptor.EncryptNew(plaintext)
Key Differences
- Lattigo is written in Go, while SEAL is primarily C++
- Lattigo focuses on lattice-based cryptography, SEAL covers broader HE schemes
- Lattigo has a simpler API, making it more accessible for newcomers
- SEAL offers more advanced features and optimizations
- Lattigo is better suited for Go developers and lattice-specific applications
Both libraries provide robust homomorphic encryption capabilities, but they cater to different use cases and developer preferences. Choose based on your specific requirements, programming language preference, and desired level of complexity.
HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
Pros of HElib
- More mature and widely used in industry and research
- Supports a broader range of homomorphic encryption schemes
- Extensive documentation and academic publications
Cons of HElib
- Steeper learning curve due to complexity
- Slower performance in some operations compared to Lattigo
- Less focus on lattice-based cryptography
Code Comparison
HElib (C++):
#include <helib/helib.h>
Ctxt encrypted = pk.Encrypt(ptxt);
ea.rotate(encrypted, 1);
Ptxt<BGV> result;
secretKey.Decrypt(result, encrypted);
Lattigo (Go):
import "github.com/tuneinsight/lattigo/v4/rlwe"
ciphertext := encryptor.EncryptNew(plaintext)
evaluator.Rotate(ciphertext, 1, ciphertext)
decryptor.Decrypt(ciphertext, plaintext)
Summary
HElib is a more established library with broader support for homomorphic encryption schemes, while Lattigo focuses on lattice-based cryptography and offers better performance in certain scenarios. HElib has a steeper learning curve but provides extensive documentation, whereas Lattigo is more accessible for developers familiar with Go. The choice between the two depends on specific project requirements, performance needs, and the preferred programming language.
This is the development repository for the OpenFHE library. The current development version is 1.4.0 (released on August 18, 2025). The current stable version is 1.3.1 (released on July 11, 2025).
Pros of OpenFHE
- More comprehensive documentation and examples
- Supports a wider range of FHE schemes (BFV, BGV, CKKS, TFHE)
- Active development with frequent updates and releases
Cons of OpenFHE
- Steeper learning curve due to more complex API
- Higher computational overhead for some operations
- Less focus on Go language support (primarily C++)
Code Comparison
OpenFHE (C++):
Ciphertext<DCRTPoly> ciphertext1, ciphertext2, ciphertextResult;
cc->EvalAdd(ciphertext1, ciphertext2, &ciphertextResult);
Lattigo (Go):
ciphertext1, ciphertext2 := new(rlwe.Ciphertext), new(rlwe.Ciphertext)
ciphertextResult := evaluator.Add(ciphertext1, ciphertext2)
Both libraries provide similar functionality for homomorphic operations, but OpenFHE offers a more extensive set of features and schemes. Lattigo, being Go-based, may be more appealing for developers working primarily with Go. OpenFHE's C++ implementation potentially offers better performance for complex operations, while Lattigo's simpler API might be easier for beginners to grasp. The choice between the two depends on specific project requirements, language preferences, and the desired level of control over FHE operations.
An FHE compiler for C++
Pros of fully-homomorphic-encryption
- Backed by Google, potentially offering more resources and support
- Focuses on practical applications with real-world examples
- Provides implementations in multiple programming languages
Cons of fully-homomorphic-encryption
- Less mature and comprehensive compared to Lattigo
- Limited to specific FHE schemes, primarily TFHE
- Smaller community and fewer contributions
Code Comparison
Lattigo (Go):
plaintext := ckks.NewPlaintext(params, params.MaxLevel())
encoder.Encode(complex(3.14, 0), plaintext, params.LogSlots())
ciphertext := encryptor.EncryptNew(plaintext)
fully-homomorphic-encryption (C++):
std::vector<double> input = {3.14};
auto plaintext = encoder.Encode(input);
auto ciphertext = encryptor.Encrypt(plaintext);
Summary
Lattigo is a more comprehensive FHE library with a focus on research and experimentation, while fully-homomorphic-encryption aims to provide practical implementations for real-world applications. Lattigo offers a wider range of FHE schemes and more advanced features, but fully-homomorphic-encryption benefits from Google's backing and multi-language support. The choice between the two depends on specific project requirements and the desired level of flexibility and support.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Lattigo: lattice-based multiparty homomorphic encryption library in Go
Lattigo is a Go module that implements full-RNS Ring-Learning-With-Errors-based homomorphic-encryption primitives and Multiparty-Homomorphic-Encryption-based secure protocols. The library features:
- Optimized arithmetic for power-of-two cyclotomic rings.
- Advanced and scheme-agnostic implementation of RLWE-based primitives, key-generation, and their multiparty version.
- Implementation of the BFV/BGV and CKKS schemes and their multiparty version.
- Support for RGSW, external product and LMKCDEY blind rotations.
- A pure Go implementation, enabling cross-platform builds, including WASM compilation for browser clients, with comparable performance to state-of-the-art C++ libraries.
Lattigo is meant to support HE in distributed systems and microservices architectures, for which Go is a common choice thanks to its natural concurrency model and portability.
Library overview
Lattigo is a strictly hierarchical library whose packages form a linear dependency chain ranging from low-level arithmetic functionalities to high-level homomorphic circuits. A graphical depiction of the Lattigo package organization is given in the Figure above.
-
lattigo/ring
: At the lowest level resides thering
package providing modular arithmetic operations for polynomials in the RNS basis, including: RNS basis extension; RNS rescaling; number theoretic transform (NTT); uniform, Gaussian and ternary sampling.-
lattigo/core
: This package implements the core cryptographic functionalities of the library and builds directly upon the arithmetic functionalities provided by thering
package:-
rlwe
: Common base for generic RLWE-based homomorphic encryption. It provides all homomorphic functionalities and defines all structs that are not scheme-specific. This includes plaintext, ciphertext, key-generation, encryption, decryption and key-switching, as well as other more advanced primitives such as RLWE-repacking. -
rgsw
: A Full-RNS variant of Ring-GSW ciphertexts and the external product.
-
-
-
lattigo/schemes
: The implementation of RLWE-based homomorphic encryption schemes are found in theschemes
package:-
bfv
: A Full-RNS variant of the Brakerski-Fan-Vercauteren scale-invariant homomorphic encryption scheme. This scheme is instantiated via a wrapper of thebgv
scheme. It provides modular arithmetic over the integers. -
bgv
: A Full-RNS generalization of the Brakerski-Fan-Vercauteren scale-invariant (BFV) and Brakerski-Gentry-Vaikuntanathan (BGV) homomorphic encryption schemes. It provides modular arithmetic over the integers. -
ckks
: A Full-RNS Homomorphic Encryption for Arithmetic for Approximate Numbers (HEAAN, a.k.a. CKKS) scheme. It provides fixed-point approximate arithmetic over the complex numbers (in its classic variant) and over the real numbers (in its conjugate-invariant variant).
-
-
lattigo/circuits
: The circuits package provides implementation of a select set of homomorphic circuits for thebgv
andckks
cryptosystems:-
bgv/lintrans
,ckks/lintrans
: Arbitrary linear transformations and slot permutations for bothbgv
andckks
. Scheme-generic objects and functions are part ofcommon/lintrans
. -
bgv/polynomial
,ckks/polynomial
: Polynomial evaluation circuits forbgv
andckks
. Scheme-generic objects and functions are part ofcommon/polynomial
. -
ckks/minimax
: Minimax composite polynomial evaluator forckks
. -
ckks/comparison
: Homomorphic comparison-based circuits such assign
,max
andstep
for theckks
scheme. -
ckks/inverse
: Homomorphic inverse circuit forckks
. -
ckks/mod1
: Homomorphic circuit for themod1
function using theckks
cryptosystem. -
ckks/dft
: Homomorphic Discrete Fourier Transform circuits for theckks
scheme. -
ckks/bootstrapping
: Bootstrapping for fixed-point approximate arithmetic over the real and complex numbers, i.e., theckks
scheme, with support for the Conjugate Invariant ring, batch bootstrapping with automatic packing/unpacking of sparsely packed/smaller ring degree ciphertexts, arbitrary precision bootstrapping, and advanced circuit customization/parameterization.
-
-
lattigo/multiparty
: Package for multiparty (a.k.a. distributed or threshold) key-generation and interactive ciphertext bootstrapping with secret-shared secret keys.-
mpckks
: Homomorphic decryption and re-encryption from and to Linear-Secret-Sharing-Shares, as well as interactive ciphertext bootstrapping for theschemes/ckks
package. -
mpbgv
: Homomorphic decryption and re-encryption from and to Linear-Secret-Sharing-Shares, as well as interactive ciphertext bootstrapping for theschemes/bgv
package.
-
-
lattigo/examples
: Executable Go programs that demonstrate the use of the Lattigo library. Each subpackage includes test files that further demonstrate the use of Lattigo primitives. -
lattigo/utils
: Generic utility methods. This package also contains the following sub-packages:bignum
: Arbitrary precision linear algebra and polynomial approximation.buffer
: Efficient methods to write/read onio.Writer
andio.Reader
.factorization
: Various factorization algorithms for medium-sized integers.sampling
: Secure bytes sampling.structs
: Generic structs for maps, vectors and matrices, including serialization.
Documentation
The full documentation of the individual packages can be browsed as a web page using official
Golang documentation rendering tool pkgsite
or browsing the Go doc.
$ go install golang.org/x/pkgsite/cmd/pkgsite@latest
$ cd lattigo
$ pkgsite -open .
Versions and Roadmap
The Lattigo library was originally exclusively developed by the EPFL Laboratory for Data Security until its version 2.4.0.
Starting with the release of version 3.0.0, Lattigo is maintained and supported by Tune Insight SA.
Also starting from version 3.0.0, the module name has changed to
github.com/tuneinsight/lattigo/v[X]
, and the official repository has been moved to
https://github.com/tuneinsight/lattigo. This has the following implications for modules that depend
on Lattigo:
- Modules that require
github.com/ldsec/lattigo/v2
will still build correctly. - To upgrade to a version X.y.z >= 3.0.0, depending modules must require
github.com/tuneinsight/lattigo/v[X]/
, for example by changing the imports togithub.com/tuneinsight/lattigo/v[X]/[package]
and by runninggo mod tidy
.
The current version of Lattigo (v6.x.x) is fast-evolving and in constant development. Consequently, there will still be backward-incompatible changes within this major version, in addition to many bug fixes and new features. Hence, we encourage all Lattigo users to update to the latest Lattigo version.
See CHANGELOG.md for the current and past versions.
Pull Requests
External pull requests should only be used to propose new functionalities that are substantial and would require a fair amount of work if done on our side. If you plan to open such a pull request, please contact us before doing so to make sure that the proposed changes are aligned with our development roadmap.
External pull requests only proposing small or trivial changes will be converted to an issue and closed.
External contributions will require the signature of a Contributor License Agreement (CLA). You can contact us using the following email to request a copy of the CLA: lattigo@tuneinsight.com.
Vulnerability Reports
Bug Reports
Lattigo welcomes bug/regression reports of any kind that conform to the preset template, which is automatically generated upon creation of a new empty issue. Nonconformity will result in the issue being closed without acknowledgement.
License
Lattigo is licensed under the Apache 2.0 License. See LICENSE.
Contact
Before contacting us directly, please make sure that your request cannot be handled through an issue.
If you want to contribute to Lattigo or report a security issue, you have a feature proposal or request, or you simply want to contact us directly, please do so using the following email: lattigo@tuneinsight.com.
Citing
Please use the following BibTex entry for citing Lattigo:
@misc{lattigo,
title = {Lattigo v6},
howpublished = {Online: \url{https://github.com/tuneinsight/lattigo}},
month = Aug,
year = 2024,
note = {EPFL-LDS, Tune Insight SA}
}
The Lattigo logo is a lattice-based version of the original Golang mascot by Renee French.
Top Related Projects
A library for lattice-based multiparty homomorphic encryption in Go
Microsoft SEAL is an easy-to-use and powerful homomorphic encryption library.
HElib is an open-source software library that implements homomorphic encryption. It supports the BGV scheme with bootstrapping and the Approximate Number CKKS scheme. HElib also includes optimizations for efficient homomorphic evaluation, focusing on effective use of ciphertext packing techniques and on the Gentry-Halevi-Smart optimizations.
This is the development repository for the OpenFHE library. The current development version is 1.4.0 (released on August 18, 2025). The current stable version is 1.3.1 (released on July 11, 2025).
An FHE compiler for C++
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot