examples

package
v6.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

README

Single Party Examples

Applications

Application examples are examples showcasing specific capabilities of the library on scaled-down real world scenarios.

Binary
  • bin_blind_rotations: an example showcasing the evaluation of the sign function using blind rotations on RLWE ciphertexts.
Integers
  • int_ride_hailing: an example on privacy preserving ride hailing.
  • int_vectorized_OLE: an example on vectorized oblivious linear evaluation using an RLWE trapdoor.
Reals/Complexes
  • reals_bootstrapping: a series of examples showcasing the capabilities of the bootstrapping for fixed point arithmetic.

    • basics: an example showcasing the basic capabilities of the bootstrapping.
    • high_precision: an example showcasing high-precision bootstrapping.
    • slim: an example showcasing slim bootstrapping, i.e. re-ordering the steps of the bootstrapping.
  • reals_scheme_switching: an example showcasing scheme switching between ckks and rgsw to complement fixed-point arithmetic with lookup tables.

  • reals_sigmoid_chebyshev: an example showcasing polynomial evaluation of a Chebyshev approximation of the sigmoid.

  • reals_sigmoid_minimax: an example showcasing polynomial evaluation of a minimax approximation of the sigmoid.

  • reals_vectorized_polynomial_evaluation: an example showcasing vectorized polynomial evaluation, i.e. evaluating different polynomials in parallel on specific slots.

Templates

Templates are files containing the basic instantiation, i.e. parameters, key-generation, encoding, encryption and decryption.

  • reals: a template for ckks.
  • int: a template for bgv.

Tutorials

Tutorials are examples showcasing the basic capabilities of the library.

  • reals: a tutorial on all the basic capabilities of the package ckks.

Multi Party Examples

  • int_pir: an example showcasing multi-party private information retrieval.
  • int_psi: an example showcasing multi-party private set intersection.
  • thresh_eval_key_gen: an example showcasing multi-party threshold key-generation.

Parameters

The params.go file contains several sets of example parameters for both bgv and ckks. These parameter are chosen to represent several degrees of homomorphic capacity for a fixed 128-bit security (according to the standard estimates at the time of writing). They do not represent a set of default parameters to be used in real HE applications. Rather, they are meant to facilitate quick tests and experimentation with the library.

Documentation

Overview

Package examples contains several example Go applications that use Lattigo in both the single- and multiparty settings, as well as several example parameter sets. See examples/README.md for more information about the examples.

Note that the code in this package, including the example parameter sets, is solely meant to illustrate the use of the library and facilitate quick experiments. It should not be depended upon and may at any time be changed or be removed.

Index

Constants

This section is empty.

Variables

View Source
var (

	// BGVParamsN12QP109 is an example parameter set for the `bgv` package logN=12 and logQP=109.
	// These parameters expect the user to use the regular tensoring (i.e. Evaluator.Mul) followed
	// by the rescaling (i.e. Evaluator.Rescale).
	BGVParamsN12QP109 = bgv.ParametersLiteral{
		LogN:             12,
		LogQ:             []int{39, 31},
		LogP:             []int{39},
		PlaintextModulus: 0x10001,
	}

	// BGVParamsN13QP218 is an example parameter set for the `bgv` package with logN=13 and logQP=218.
	// These parameters expect the user to use the regular tensoring (i.e. Evaluator.Mul) followed
	// by the rescaling (i.e. Evaluator.Rescale).
	BGVParamsN13QP218 = bgv.ParametersLiteral{
		LogN:             13,
		LogQ:             []int{42, 33, 33, 33, 33},
		LogP:             []int{44},
		PlaintextModulus: 0x10001,
	}

	// BGVParamsN14QP438 is an example parameter set for the `bgv` package with logN=14 and logQP=438.
	// These parameters expect the user to use the regular tensoring (i.e. Evaluator.Mul) followed
	// by the rescaling (i.e. Evaluator.Rescale).
	BGVParamsN14QP438 = bgv.ParametersLiteral{
		LogN:             14,
		LogQ:             []int{44, 34, 34, 34, 34, 34, 34, 34, 34, 34},
		LogP:             []int{44, 44},
		PlaintextModulus: 0x10001,
	}

	// BGVParamsN15QP880 is an example parameter set for the `bgv` package with logN=15 and logQP=881.
	// These parameters expect the user to use the regular tensoring (i.e. Evaluator.Mul) followed
	// by the rescaling (i.e. Evaluator.Rescale).
	BGVParamsN15QP880 = bgv.ParametersLiteral{
		LogN:             15,
		LogQ:             []int{47, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34},
		LogP:             []int{47, 47, 47, 47},
		PlaintextModulus: 0x10001,
	}

	// BGVScaleInvariantParamsN12QP109 is an example parameter set for the `bgv` package logN=12 and logQP=109.
	// These parameters expect the user to use the scale invariant tensoring (i.e. Evaluator.MulScaleInvariant).
	BGVScaleInvariantParamsN12QP109 = bgv.ParametersLiteral{
		LogN:             12,
		LogQ:             []int{39, 39},
		LogP:             []int{31},
		PlaintextModulus: 0x10001,
	}

	// BGVScaleInvariantParamsN13QP218 is an example parameter set for the `bgv` package with logN=13 and logQP=218.
	// These parameters expect the user to use the scale invariant tensoring (i.e. Evaluator.MulScaleInvariant).
	BGVScaleInvariantParamsN13QP218 = bgv.ParametersLiteral{
		LogN:             13,
		LogQ:             []int{55, 54, 54},
		LogP:             []int{55},
		PlaintextModulus: 0x10001,
	}

	// BGVScaleInvariantParamsN14QP438 is an example parameter set for the `bgv` package with logN=14 and logQP=438.
	// These parameters expect the user to use the scale invariant tensoring (i.e. Evaluator.MulScaleInvariant).
	BGVScaleInvariantParamsN14QP438 = bgv.ParametersLiteral{
		LogN:             14,
		LogQ:             []int{55, 55, 55, 54, 54, 54},
		LogP:             []int{56, 55},
		PlaintextModulus: 0x10001,
	}

	// BGVScaleInvariantParamsN15QP880 is an example parameter set for the `bgv` package with logN=15 and logQP=881.
	// These parameters expect the user to use the scale invariant tensoring (i.e. Evaluator.MulScaleInvariant).
	BGVScaleInvariantParamsN15QP880 = bgv.ParametersLiteral{
		LogN:             15,
		LogQ:             []int{60, 60, 59, 58, 58, 58, 58, 58, 58, 58, 58, 58},
		LogP:             []int{60, 60, 60},
		PlaintextModulus: 0x10001,
	}

	// CKKSComplexParamsN12QP109 is an example parameter set for the `ckks` package with logN=12 and logQP=109.
	// These parameters instantiate `ckks` over the complex field with N/2 SIMD slots.
	CKKSComplexParamsN12QP109 = ckks.ParametersLiteral{
		LogN:            12,
		LogQ:            []int{38, 32},
		LogP:            []int{39},
		LogDefaultScale: 32,
	}

	// CKKSComplexParamsN13QP218 is an example parameter set for the `ckks` package with logN=13 and logQP=218.
	// These parameters instantiate `ckks` over the complex field with N/2 SIMD slots.
	CKKSComplexParamsN13QP218 = ckks.ParametersLiteral{
		LogN:            13,
		LogQ:            []int{33, 30, 30, 30, 30, 30},
		LogP:            []int{35},
		LogDefaultScale: 30,
	}
	// CKKSComplexParamsN14QP438 is an example parameter set for the `ckks` package with logN=14 and logQP=438.
	// These parameters instantiate `ckks` over the complex field with N/2 SIMD slots.
	CKKSComplexParamsN14QP438 = ckks.ParametersLiteral{
		LogN:            14,
		LogQ:            []int{45, 34, 34, 34, 34, 34, 34, 34, 34, 34},
		LogP:            []int{44, 43},
		LogDefaultScale: 34,
	}

	// CKKSComplexParamsN15QP880 is an example parameter set for the `ckks` package with logN=15 and logQP=881.
	// These parameters instantiate `ckks` over the complex field with N/2 SIMD slots.
	CKKSComplexParamsN15QP881 = ckks.ParametersLiteral{
		LogN:            15,
		LogQ:            []int{51, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40},
		LogP:            []int{50, 50, 50},
		LogDefaultScale: 40,
	}
	// CKKSComplexParamsPN16QP1761 is an example parameter set for the `ckks` package with logN=16 and logQP = 1761.
	// These parameters instantiate `ckks` over the complex field with N/2 SIMD slots.
	CKKSComplexParamsPN16QP1761 = ckks.ParametersLiteral{
		LogN:            16,
		LogQ:            []int{56, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45},
		LogP:            []int{55, 55, 55, 55},
		LogDefaultScale: 45,
	}

	// CKKSRealParamsN12QP109 is an example parameter set for the `ckks` package with conjugate-invariant CKKS and logN=12 and logQP=109.
	// These parameters instantiate `ckks` over the real field with N SIMD slots.
	CKKSRealParamsN12QP109 = ckks.ParametersLiteral{
		LogN:            12,
		LogQ:            []int{38, 32},
		LogP:            []int{39},
		LogDefaultScale: 32,
		RingType:        ring.ConjugateInvariant,
	}

	// CKKSRealParamsN13QP218 is an example parameter set for the `ckks` package with conjugate-invariant CKKS and logN=13 and logQP=218
	// These parameters instantiate `ckks` over the real field with N SIMD slots.
	CKKSRealParamsN13QP218 = ckks.ParametersLiteral{
		LogN:            13,
		LogQ:            []int{33, 30, 30, 30, 30, 30},
		LogP:            []int{35},
		LogDefaultScale: 30,
		RingType:        ring.ConjugateInvariant,
	}

	// CKKSRealParamsN14QP438 is an example parameter set for the `ckks` package with logN=14 and logQP=438.
	// These parameters instantiate `ckks` over the real field with N SIMD slots.
	CKKSRealParamsN14QP438 = ckks.ParametersLiteral{
		LogN:            14,
		LogQ:            []int{46, 34, 34, 34, 34, 34, 34, 34, 34, 34},
		LogP:            []int{43, 43},
		LogDefaultScale: 34,
		RingType:        ring.ConjugateInvariant,
	}

	// CKKSRealParamsN15QP880 is an example parameter set for the `ckks` package with logN=15 and logQP=881.
	// These parameters instantiate `ckks` over the real field with N SIMD slots.
	CKKSRealParamsN15QP881 = ckks.ParametersLiteral{
		LogN:            15,
		LogQ:            []int{51, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40},
		LogP:            []int{50, 50, 50},
		LogDefaultScale: 40,
		RingType:        ring.ConjugateInvariant,
	}

	// CKKSRealParamsPN16QP1761 is an example parameter set for the `ckks` package with logN=16 and logQP = 1761
	// These parameters instantiate `ckks` over the real field with N SIMD slots.
	CKKSRealParamsPN16QP1761 = ckks.ParametersLiteral{
		LogN:            16,
		LogQ:            []int{56, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45},
		LogP:            []int{55, 55, 55, 55},
		LogDefaultScale: 45,
		RingType:        ring.ConjugateInvariant,
	}
)

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
multiparty
singleparty
ckks_bootstrapping/basics
Package main implements an example showcasing the basics of the bootstrapping for fixed-point approximate arithmetic over the reals/complexes.
Package main implements an example showcasing the basics of the bootstrapping for fixed-point approximate arithmetic over the reals/complexes.
ckks_bootstrapping/high_precision
Package main implements an example showcasing high-precision bootstrapping for high-precision fixed- point approximate arithmetic over the reals/complexes.
Package main implements an example showcasing high-precision bootstrapping for high-precision fixed- point approximate arithmetic over the reals/complexes.
ckks_bootstrapping/slim
Package main implements an example showcasing slim for bootstrapping for fixed-point approximate arithmetic over the reals/complexes numbers.
Package main implements an example showcasing slim for bootstrapping for fixed-point approximate arithmetic over the reals/complexes numbers.
ckks_scheme_switching
Package main showcases how lookup tables can complement fixed-point approximate homomorphic encryption to compute non-linear functions such as sign.
Package main showcases how lookup tables can complement fixed-point approximate homomorphic encryption to compute non-linear functions such as sign.
ckks_sigmoid_chebyshev
Package main implements an example of smooth function approximation using Chebyshev polynomial interpolation.
Package main implements an example of smooth function approximation using Chebyshev polynomial interpolation.
ckks_sigmoid_minimax
Package main implements an example of smooth function approximation using minimax polynomial interpolation.
Package main implements an example of smooth function approximation using minimax polynomial interpolation.
ckks_vectorized_polynomial_evaluation
Package main implements an example of vectorized polynomial evaluation.
Package main implements an example of vectorized polynomial evaluation.
rgsw_blind_rotations
Package main implements an example of Blind Rotation (a.k.a.
Package main implements an example of Blind Rotation (a.k.a.
templates/bgv
Package main is a template encrypted modular arithmetic integers, with a set of example parameters, key generation, encoding, encryption, decryption and decoding.
Package main is a template encrypted modular arithmetic integers, with a set of example parameters, key generation, encoding, encryption, decryption and decoding.
templates/ckks
Package main is a template encrypted arithmetic with floating point values, with a set of example parameters, key generation, encoding, encryption, decryption and decoding.
Package main is a template encrypted arithmetic with floating point values, with a set of example parameters, key generation, encoding, encryption, decryption and decoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL