sssa

package
v0.0.0-...-a360f25 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPrimeStr = "115792089237316195423570985008687907852837564279074904382605163141518161494337"
)

*

  • DefaultPrimeStr is based on encryption curve, equals to the 'N'
  • The current curve is secp256k1

*

Variables

View Source
var (
	ErrCannotRequireMoreShares = errors.New("cannot require more shares then existing")
	ErrOneOfTheSharesIsInvalid = errors.New("one of the shares is invalid")
	ErrInvalidPubkey           = errors.New("Invalid publick key")
)

Functions

func Combine

func Combine(shares []string) (string, error)

*

  • Takes a string array of shares encoded in base64 created via Shamir's
  • Algorithm; each string must be of equal length of a multiple of 88 characters
  • as a single 88 character share is a pair of 256-bit numbers (x, y). *
  • Note: the polynomial will converge if the specified minimum number of shares
  • or more are passed to this function. Passing thus does not affect it
  • Passing fewer however, simply means that the returned secret is wrong.

*

func Combine256Bit

func Combine256Bit(shares []string) (*big.Int, error)

*

  • Takes a string array of shares encoded in base64 created via Shamir's
  • Algorithm; each string must be of equal length of a multiple of 88 characters
  • as a single 88 character share is a pair of 256-bit numbers (x, y). *
  • Note: the polynomial will converge if the specified minimum number of shares
  • or more are passed to this function. Passing thus does not affect it
  • Passing fewer however, simply means that the returned secret is wrong.

*

func CombineECDSAPubkey

func CombineECDSAPubkey(shares []string) (*ecdsa.PublicKey, error)

*

  • Takes a string array of shares encoded in base64 created via Shamir's
  • Algorithm; each string must be of equal length of a multiple of 88 characters
  • as a single 88 character share is a pair of 256-bit numbers (x, y). *
  • Note: the polynomial will converge if the specified minimum number of shares
  • or more are passed to this function. Passing thus does not affect it
  • Passing fewer however, simply means that the returned secret is wrong.

*

func Create

func Create(minimum int, shares int, raw string) ([]string, error)

*

  • Returns a new arary of secret shares (encoding x,y pairs as base64 strings)
  • created by Shamir's Secret Sharing Algorithm requring a minimum number of
  • share to recreate, of length shares, from the input secret raw as a string

*

func Create256Bit

func Create256Bit(minimum int, shares int, raw *big.Int) ([]string, []*big.Int, []*big.Int, error)

*

  • Returns a new array of secret shares and polynomial
  • created by Shamir's Secret Sharing Algorithm requring a minimum number of
  • share to recreate, of length shares, from the input secret raw as a big.Int

*

func ExtractPrivateShare

func ExtractPrivateShare(privshare string) *ecdsa.PrivateKey

Extract private share from string

func GenerateCommitteePublicKey

func GenerateCommitteePublicKey(polynomials [][]*ecdsa.PublicKey) *ecdsa.PublicKey

Generate multi-sssa public key from public key shares

func GeneratePrivKey

func GeneratePrivKey(key *big.Int) *ecdsa.PrivateKey

func GenerateSssaKey

func GenerateSssaKey(shares []string) *big.Int

Generate multi-sssa private key from key shares

func IsValidShare

func IsValidShare(candidate string) bool

*

  • Takes in a given string to check if it is a valid secret *
  • Requirements:
  • Length multiple of 88
  • Can decode each 44 character block as base64 *
  • Returns only success/failure (bool)

*

func IsValidShare256Bit

func IsValidShare256Bit(candidate string) bool

*

  • Takes in a given string to check if it is a valid secret *
  • Requirements:
  • Length 88
  • Can decode each 44 character block as base64 *
  • Returns only success/failure (bool)

*

func ScanPubSharesA1

func ScanPubSharesA1(bA *ecdsa.PublicKey, S *ecdsa.PublicKey) ecdsa.PublicKey

GenerateA1 generate one pulic key of AB account A1=[hash([b]A)]G+S

func ToECDSAPubArray

func ToECDSAPubArray(privs []*big.Int) []*ecdsa.PublicKey

Generate public key array from a private big.int keys array

func VerifyCreatedAndPolynomial

func VerifyCreatedAndPolynomial(shares []string, pubkeyArray []*ecdsa.PublicKey) bool

*

*Returns the created shares and polynomials whether match
* For: f(x) = a0 + a1x + a2x^2 + ... + a(k-1)x^k-1
*		If get a point (m, f(m)) on line
*		Should have
*			f(m)G = a0G + m * a1G + ... + m^(k-1) * a(k-1)G
* The input share is m + f(m)G Shares Array, the pubkeyArray is the Polynomial Pubkey

*

func VerifyPolynomial

func VerifyPolynomial(share string, pubkeyArray []*ecdsa.PublicKey) bool

*

*Returns the created shares and polynomials whether match
* For: f(x) = a0 + a1x + a2x^2 + ... + a(k-1)x^k-1
*		If get a point (m, f(m)) on line
*		Should have
*			f(m)G = a0G + m * a1G + ... + m^(k-1) * a(k-1)G
* The input share is m + f(m)G share string, the pubkeyArray is the Polynomial Pubkey

*

Types

type PrivateShare

type PrivateShare struct {
	Index *big.Int
	Key   *big.Int
}

func NewPrivateShare

func NewPrivateShare(share string) *PrivateShare

Import an privateShare

Jump to

Keyboard shortcuts

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