Documentation ¶
Index ¶
- Variables
- func ComplexSecretRetrieve(shares map[int]*big.Int, curve elliptic.Curve) ([]byte, error)
- func ComplexSecretSplit(totalShareNumber, minimumShareNumber int, secret []byte, curve elliptic.Curve) (shares map[int]*big.Int, err error)
- func ComplexSecretSplitWithVerifyPoints(totalShareNumber, minimumShareNumber int, secret []byte, curve elliptic.Curve) (shares map[int]*big.Int, points []*ecc.Point, err error)
- func ComplexSecretToPolynomial(totalShareNumber, minimumShareNumber int, secret []byte, curve elliptic.Curve) ([]*big.Int, error)
- func GetSpecifiedSecretShareByPolynomial(poly []*big.Int, index *big.Int, curve elliptic.Curve) *big.Int
- func GetVerifyPointByPolynomial(poly []*big.Int, curve elliptic.Curve) (*ecc.Point, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ()
Functions ¶
func ComplexSecretRetrieve ¶
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:
- Decode each share i.e. the byte slice to a (x, y) pair
- 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.
- Give x = 0, then the secret number S can be computed
- 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:
- Encode the secret to a number S
- 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
- For this polynomial, Give x different values, for example, x++ each time, then compute y = F(x)
- So we get W shares, which are (x, y) pairs
- 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 根据指定的碎片数量和门限值,随机生成多项式
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.