examples

package
v5.0.0-...-72ea290 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 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 hefloat and hebin 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 hefloat.
  • int: a template for heint.

Tutorials

Tutorials are examples showcasing the basic capabilities of the library.

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

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 heint and hefloat. 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 Lattice 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 (

	// HEIntParamsN12QP109 is an example parameter set for the `heint` 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).
	HEIntParamsN12QP109 = heint.ParametersLiteral{
		LogN:             12,
		LogQ:             []int{39, 31},
		LogP:             []int{39},
		PlaintextModulus: 0x10001,
	}

	// HEIntParamsN13QP218 is an example parameter set for the `heint` 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).
	HEIntParamsN13QP218 = heint.ParametersLiteral{
		LogN:             13,
		LogQ:             []int{42, 33, 33, 33, 33},
		LogP:             []int{44},
		PlaintextModulus: 0x10001,
	}

	// HEIntParamsN14QP438 is an example parameter set for the `heint` 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).
	HEIntParamsN14QP438 = heint.ParametersLiteral{
		LogN:             14,
		LogQ:             []int{44, 34, 34, 34, 34, 34, 34, 34, 34, 34},
		LogP:             []int{44, 44},
		PlaintextModulus: 0x10001,
	}

	// HEIntParamsN15QP880 is an example parameter set for the `heint` 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).
	HEIntParamsN15QP880 = heint.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,
	}

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

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

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

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

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

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

	// HEFloatComplexParamsN15QP880 is an example parameter set for the `hefloat` package with logN=15 and logQP=881.
	// These parameters instantiate `hefloat` over the complex field with N/2 SIMD slots.
	HEFloatComplexParamsN15QP881 = hefloat.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,
	}
	// HEFloatComplexParamsPN16QP1761 is an example parameter set for the `hefloat` package with logN=16 and logQP = 1761.
	// These parameters instantiate `hefloat` over the complex field with N/2 SIMD slots.
	HEFloatComplexParamsPN16QP1761 = hefloat.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,
	}

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

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

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

	// HEFloatRealParamsN15QP880 is an example parameter set for the `hefloat` package with logN=15 and logQP=881.
	// These parameters instantiate `hefloat` over the real field with N SIMD slots.
	HEFloatRealParamsN15QP881 = hefloat.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,
	}

	// HEFloatRealParamsPN16QP1761 is an example parameter set for the `hefloat` package with logN=16 and logQP = 1761
	// These parameters instantiate `hefloat` over the real field with N SIMD slots.
	HEFloatRealParamsPN16QP1761 = hefloat.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
multi_party
single_party
applications/bin_blind_rotations
Package main implements an example of Blind Rotation (a.k.a.
Package main implements an example of Blind Rotation (a.k.a.
applications/reals_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.
applications/reals_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.
applications/reals_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.
applications/reals_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.
applications/reals_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.
applications/reals_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.
applications/reals_vectorized_polynomial_evaluation
Package main implements an example of vectorized polynomial evaluation.
Package main implements an example of vectorized polynomial evaluation.
templates/int
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/reals
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