lagrange

package
v3.0.0-...-c5b601e Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var N, _ = new(big.Int).SetString("115792089237316195423570985008687907852837564279074904382605163141518161494337", 10)

N is the order of the secp256k1 elliptic curve group, represented as a big.Int.

View Source
var PRECOMPUTED_POWERS = [...][]int64{
	2:  {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144},
	3:  {1, 3, 9, 27, 81, 243, 729, 2187, 6561},
	5:  {1, 5, 25, 125, 625},
	7:  {1, 7, 49},
	11: {1, 11},
	13: {1, 13},
	17: {1, 17},
	19: {1, 19},
}

PRECOMPUTED_POWERS contains pre-computed powers of certain prime numbers.

View Source
var PRIME_FACTORS = [...][][2]int64{
	2:  {{2, 1}},
	3:  {{3, 1}},
	4:  {{2, 2}},
	5:  {{5, 1}},
	6:  {{2, 1}, {3, 1}},
	7:  {{7, 1}},
	8:  {{2, 3}},
	9:  {{3, 2}},
	10: {{2, 1}, {5, 1}},
	11: {{11, 1}},
	12: {{2, 2}, {3, 1}},
	13: {{13, 1}},
	14: {{2, 1}, {7, 1}},
	15: {{3, 1}, {5, 1}},
	16: {{2, 4}},
	17: {{17, 1}},
	18: {{2, 1}, {3, 2}},
	19: {{19, 1}},
	20: {{2, 2}, {5, 1}},
}

PRIME_FACTORS contains pre-computed prime factors for the numbers up to 20.

Functions

func ComputeCoefficient

func ComputeCoefficient(i int64, s []int64) *big.Int

ComputeCoefficient calculates the Lagrange coefficient for a given index and set of indices. The formula used is 𝚷(j/(j-i)) for all j in S-{i}, where: - 𝚷 denotes the product of the following statement - S ⊂ {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} - i ∈ S - j ∈ S-{i} The Lagrange coefficient is used in polynomial interpolation in threshold secret sharing schemes.

func ComputeCoefficientPreCompute

func ComputeCoefficientPreCompute(i int64, s []int64) *big.Int

ComputeCoefficientPreCompute computes the Lagrange coefficient for a given index i and a set S of indices. The function optimizes computations by using pre-computed prime factors and powers of numbers. The formula used is 𝚷(j/(j-i)) for all j in S-{i}, where: - 𝚷 denotes the product of the following statement - S ⊂ {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} - i ∈ S - j ∈ S-{i} The Lagrange coefficient is used in polynomial interpolation in threshold secret sharing schemes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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