complex_secret_share

package
v0.0.0-...-aafbcf9 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvaildTotalShareNumberError = errors.New("The totalShareNumber must be greater than one.")
	InvaildShareNumberError      = errors.New("The minimumShareNumber must be smaller than the totalShareNumber.")
)
View Source
var (
	EmptyMessageError = errors.New("The message to be signed should not be empty")
)

Functions

func ComplexSecretRetrieve

func ComplexSecretRetrieve(shares map[int]*big.Int) ([]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) (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 diffent 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

Types

This section is empty.

Jump to

Keyboard shortcuts

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