Documentation
¶
Index ¶
- Variables
- func CalculateBetaDelta(p uint64, B float64, q uint64) *big.Int
- func CompareSecrets(r *ring.Ring, reconstructed, original structs.Vector[ring.Poly]) bool
- func ConvertMatrixFromNTT(r *ring.Ring, M structs.Matrix[ring.Poly])
- func ConvertMatrixToNTT(r *ring.Ring, M structs.Matrix[ring.Poly])
- func ConvertVectorFromNTT(r *ring.Ring, vec structs.Vector[ring.Poly])
- func ConvertVectorToNTT(r *ring.Ring, vec structs.Vector[ring.Poly])
- func CopyMatrixMap(original map[int]structs.Matrix[ring.Poly]) map[int]structs.Matrix[ring.Poly]
- func CopyVectorMap(original map[int]structs.Vector[ring.Poly]) map[int]structs.Vector[ring.Poly]
- func FormatBigIntSlice(slice []*big.Int) string
- func GaussianEliminationModQ(mat [][]*big.Int, q *big.Int) bool
- func GetRandomBytes(n int) []byte
- func GetRandomInt(q *big.Int) *big.Int
- func InitializeMatrix(r *ring.Ring, rows, cols int) structs.Matrix[ring.Poly]
- func InitializeVector(r *ring.Ring, length int) structs.Vector[ring.Poly]
- func MatrixAdd(r *ring.Ring, M1, M2, result structs.Matrix[ring.Poly])
- func MatrixMatrixMul(r *ring.Ring, M1, M2 structs.Matrix[ring.Poly], ...)
- func MatrixMatrixMulNTT(r *ring.Ring, M1, M2 structs.Matrix[ring.Poly], ...)
- func MatrixMatrixMulNaive(r *ring.Ring, M1, M2 structs.Matrix[ring.Poly], ...)
- func MatrixVectorMul(r *ring.Ring, M structs.Matrix[ring.Poly], vec structs.Vector[ring.Poly], ...)
- func MatrixVectorMulNTT(r *ring.Ring, M structs.Matrix[ring.Poly], vec structs.Vector[ring.Poly], ...)
- func MatrixVectorMulNaive(r *ring.Ring, M structs.Matrix[ring.Poly], vec structs.Vector[ring.Poly], ...)
- func MulCoeffsNTT(r *ring.Ring, p1, p2, result ring.Poly)
- func MulPolyNTT(r *ring.Ring, p1 ring.Poly, p2 ring.Poly, p3 ring.Poly)
- func MulPolyNaive(r *ring.Ring, p1 ring.Poly, p2 ring.Poly, p3 ring.Poly)
- func PanicHandler(op string)
- func PrecomputeRandomness(size int, key []byte)
- func PrintBigIntVector(label string, vector structs.Vector[[]*big.Int])
- func PrintMatrix(label string, matrix structs.Matrix[ring.Poly])
- func PrintPolynomial(label string, poly ring.Poly)
- func PrintSignRepresentation(r *ring.Ring, poly ring.Poly, modulus uint64)
- func PrintSignRepresentationMatrix(r *ring.Ring, matrix structs.Matrix[ring.Poly], modulus uint64)
- func PrintSignRepresentationVector(r *ring.Ring, vec structs.Vector[ring.Poly], modulus uint64)
- func PrintVector(label string, vector structs.Vector[ring.Poly])
- func ReconstructSecret(r *ring.Ring, shares map[int]structs.Vector[ring.Poly], ...) structs.Vector[ring.Poly]
- func RestoreCoefficients(r *ring.Ring, newRing *ring.Ring, poly ring.Poly, roundingVal uint) ring.Poly
- func RestoreVector(r *ring.Ring, newRing *ring.Ring, v structs.Vector[ring.Poly], ...) structs.Vector[ring.Poly]
- func RoundCoefficients(r *ring.Ring, newRing *ring.Ring, poly ring.Poly, roundingVal uint) ring.Poly
- func RoundVector(r *ring.Ring, newRing *ring.Ring, v structs.Vector[ring.Poly], ...) structs.Vector[ring.Poly]
- func SamplePolyMatrix(r *ring.Ring, rows, cols int, sampler ring.Sampler, NTT bool, montgomery bool) structs.Matrix[ring.Poly]
- func SamplePolyVector(r *ring.Ring, length int, sampler ring.Sampler, NTT bool, montgomery bool) structs.Vector[ring.Poly]
- func SignedRepresentation(coeffs []*big.Int, Q uint64)
- func VectorAdd(r *ring.Ring, v1, v2, result structs.Vector[ring.Poly])
- func VectorPolyMul(r *ring.Ring, vec structs.Vector[ring.Poly], poly ring.Poly, ...)
- func VectorPolyMulNTT(r *ring.Ring, vec structs.Vector[ring.Poly], poly ring.Poly, ...)
- func VectorPolyMulNaive(r *ring.Ring, vec structs.Vector[ring.Poly], poly ring.Poly, ...)
- func VectorSub(r *ring.Ring, v1, v2, result structs.Vector[ring.Poly])
- func WrapError(op string, kind string, err error) error
- type Error
Constants ¶
This section is empty.
Variables ¶
var PrecomputedRandomness []byte
Global variable to hold precomputed randomness
var RandomnessIndex int
Functions ¶
func CalculateBetaDelta ¶
CalculateBetaDelta computes ((B * p) - q) / (2 * q) as a big.Int
func CompareSecrets ¶
CompareSecrets compares the reconstructed secret with the original.
func ConvertMatrixFromNTT ¶
ConvertMatrixFromNTT converts a matrix of polynomials from the NTT domain back to the standard domain.
func ConvertMatrixToNTT ¶
ConvertMatrixToNTT converts a matrix of polynomials to the NTT domain.
func ConvertVectorFromNTT ¶
ConvertVectorFromNTT converts a vector of polynomials from the NTT domain back to the standard domain.
func ConvertVectorToNTT ¶
ConvertVectorToNTT converts a vector of polynomials to the NTT domain.
func CopyMatrixMap ¶
func CopyVectorMap ¶
func FormatBigIntSlice ¶
func GaussianEliminationModQ ¶
GaussianEliminationModQ performs Gaussian elimination mod q and checks if the matrix is full rank
func GetRandomBytes ¶
GetRandomBytes returns the next n bytes of precomputed randomness
func GetRandomInt ¶
GetRandomInt returns a random integer from the precomputed randomness
func InitializeMatrix ¶
InitializeMatrix creates and returns a matrix of the given dimensions, initializing each element as a new polynomial.
func InitializeVector ¶
InitializeVector creates and returns a vector of the given length, initializing each element as a new polynomial.
func MatrixAdd ¶
MatrixAdd adds two matrices of ring.Poly element-wise and stores the result in a given result matrix.
func MatrixMatrixMul ¶
func MatrixMatrixMul(r *ring.Ring, M1, M2 structs.Matrix[ring.Poly], result structs.Matrix[ring.Poly])
MatrixMatrixMul performs matrix-matrix multiplication.
func MatrixMatrixMulNTT ¶
func MatrixMatrixMulNTT(r *ring.Ring, M1, M2 structs.Matrix[ring.Poly], result structs.Matrix[ring.Poly])
MatrixMatrixMul performs matrix-matrix multiplication.
func MatrixMatrixMulNaive ¶
func MatrixMatrixMulNaive(r *ring.Ring, M1, M2 structs.Matrix[ring.Poly], result structs.Matrix[ring.Poly])
MatrixMatrixMul performs matrix-matrix multiplication. It takes two matrices of ring.Poly pointers, M1 of dimensions m x p and M2 of dimensions p x n, and outputs the result in a given result matrix of dimensions m x n.
func MatrixVectorMul ¶
func MatrixVectorMul(r *ring.Ring, M structs.Matrix[ring.Poly], vec structs.Vector[ring.Poly], result structs.Vector[ring.Poly])
MatrixVectorMul performs matrix-vector multiplication.
func MatrixVectorMulNTT ¶
func MatrixVectorMulNTT(r *ring.Ring, M structs.Matrix[ring.Poly], vec structs.Vector[ring.Poly], result structs.Vector[ring.Poly])
MatrixVectorMul performs matrix-vector multiplication.
func MatrixVectorMulNaive ¶
func MatrixVectorMulNaive(r *ring.Ring, M structs.Matrix[ring.Poly], vec structs.Vector[ring.Poly], result structs.Vector[ring.Poly])
MatrixVectorMul performs matrix-vector multiplication. It takes a matrix of ring.Poly pointers, a vector of ring.Poly pointers, and outputs the result in a given result vector.
func MulCoeffsNTT ¶
MulCoeffsNTT performs coefficient-wise multiplication of two polynomials in the NTT domain.
func MulPolyNTT ¶
Sets p3 = p1 * p2 by first converting into NTT, multiplying coefficient-wise, and then converting out of NTT with INTT
func PanicHandler ¶
func PanicHandler(op string)
PanicHandler recovers from panics and converts them to errors
func PrecomputeRandomness ¶
PrecomputeRandomness precomputes all necessary randomness and stores it in the global variable
func PrintBigIntVector ¶
PrintBigIntVector prints a vector of slices of *big.Int elements
func PrintPolynomial ¶
func PrintSignRepresentation ¶
func ReconstructSecret ¶
func ReconstructSecret(r *ring.Ring, shares map[int]structs.Vector[ring.Poly], lagrangeCoeffs map[int]ring.Poly) structs.Vector[ring.Poly]
ReconstructSecret reconstructs the secret using the shares and Lagrange coefficients.
func RestoreCoefficients ¶
func RestoreCoefficients(r *ring.Ring, newRing *ring.Ring, poly ring.Poly, roundingVal uint) ring.Poly
RestoreCoefficients multiplies each coefficient of the polynomial by 2^roundingVal
func RestoreVector ¶
func RestoreVector(r *ring.Ring, newRing *ring.Ring, v structs.Vector[ring.Poly], roundingVal uint) structs.Vector[ring.Poly]
RestoreVector multiplies each polynomial in the vector by 2^roundingVal
func RoundCoefficients ¶
func RoundCoefficients(r *ring.Ring, newRing *ring.Ring, poly ring.Poly, roundingVal uint) ring.Poly
RoundCoefficients rounds each coefficient of the polynomial as specified
func RoundVector ¶
func RoundVector(r *ring.Ring, newRing *ring.Ring, v structs.Vector[ring.Poly], roundingVal uint) structs.Vector[ring.Poly]
RoundVector rounds each polynomial in the vector
func SamplePolyMatrix ¶
func SamplePolyMatrix(r *ring.Ring, rows, cols int, sampler ring.Sampler, NTT bool, montgomery bool) structs.Matrix[ring.Poly]
SamplePolyMatrix samples a matrix of polynomials with given dimensions (rows and cols) using the provided sampler.
func SamplePolyVector ¶
func SamplePolyVector(r *ring.Ring, length int, sampler ring.Sampler, NTT bool, montgomery bool) structs.Vector[ring.Poly]
SamplePolyVector samples a vector of polynomials of a given length using the provided sampler.
func SignedRepresentation ¶
Convert to signed representation
func VectorAdd ¶
VectorAdd adds two vectors of ring.Poly element-wise and stores the result in a result vector.
func VectorPolyMul ¶
func VectorPolyMul(r *ring.Ring, vec structs.Vector[ring.Poly], poly ring.Poly, result structs.Vector[ring.Poly])
VectorPolyMul performs element-wise multiplication of a vector by a polynomial.
func VectorPolyMulNTT ¶
func VectorPolyMulNTT(r *ring.Ring, vec structs.Vector[ring.Poly], poly ring.Poly, result structs.Vector[ring.Poly])
VectorPolyMul performs element-wise multiplication of a vector by a polynomial.
func VectorPolyMulNaive ¶
func VectorPolyMulNaive(r *ring.Ring, vec structs.Vector[ring.Poly], poly ring.Poly, result structs.Vector[ring.Poly])
VectorPolyMulNaive performs element-wise multiplication of a vector by a polynomial. It takes a vector of ring.Poly pointers, a single ring.Poly pointer, and outputs the result in a given result vector.