complex_secret_share

package
v0.0.0-...-ebe581b Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidTotalShareNumberError = errors.New("totalShareNumber must be greater than one")
	InvalidShareNumberError      = errors.New("minimumShareNumber must be smaller than the totalShareNumber")
)

Functions

func ComplexSecretRetrieve

func ComplexSecretRetrieve(shares map[int]*big.Int, curve elliptic.Curve) ([]byte, error)

Shamir's Secret Sharing algorithm, can be considered as: A way to split a secret to W shares, the secret can only be retrieved if more than T(T <= W) shares are combined together.

This is the retrieve process:

  1. Decode each share i.e. the byte slice to a (x, y) pair
  2. Use lagrange interpolation formula, take the (x, y) pairs as input points to compute a polynomial f(x) which is able to match all the given points.
  3. Give x = 0, then the secret number S can be computed
  4. Now decode number S, then the secret is retrieved

func ComplexSecretSplit

func ComplexSecretSplit(totalShareNumber, minimumShareNumber int, secret []byte, curve elliptic.Curve) (shares map[int]*big.Int, err error)

Shamir's Secret Sharing algorithm, can be considered as: A way to split a secret to W shares, the secret can only be retrieved if more than T(T <= W) shares are combined together.

This is the split process:

  1. Encode the secret to a number S
  2. Choose a lot of random numbers as coefficients, in order to make a random polynomials F(x) of degree T-1, the variable is X, the const(x-intercept) is S
  3. For this polynomial, Give x different values, for example, x++ each time, then compute y = F(x)
  4. So we get W shares, which are (x, y) pairs
  5. Now encode each pair to a byte slice

func ComplexSecretSplitWithVerifyPoints

func ComplexSecretSplitWithVerifyPoints(totalShareNumber, minimumShareNumber int, secret []byte, curve elliptic.Curve) (shares map[int]*big.Int, points []*ecc.Point, err error)

ComplexSecretSplitWithVerifyPoints 生成带验证点的秘密碎片

func ComplexSecretToPolynomial

func ComplexSecretToPolynomial(totalShareNumber, minimumShareNumber int, secret []byte, curve elliptic.Curve) ([]*big.Int, error)

ComplexSecretToPolynomial 根据指定的碎片数量和门限值,随机生成多项式

func GetSpecifiedSecretShareByPolynomial

func GetSpecifiedSecretShareByPolynomial(poly []*big.Int, index *big.Int, curve elliptic.Curve) *big.Int

GetSpecifiedSecretShareByPolynomial 为产生本地秘密的私钥碎片做准备,通过目标多项式和节点index生成对应的碎片

func GetVerifyPointByPolynomial

func GetVerifyPointByPolynomial(poly []*big.Int, curve elliptic.Curve) (*ecc.Point, error)

GetVerifyPointByPolynomial 为产生本地秘密的私钥碎片做准备,通过目标多项式生成验证点

Types

This section is empty.

Jump to

Keyboard shortcuts

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