Documentation ¶
Overview ¶
Package shamir is a port of the hashicorp/vault implementation of Shamir's Secret Sharing which has been modified to work with a finite field rather than arbitrary length content.
Their implementation splits every byte independently into shares and transposes the output together to form a single secret. For our purposes, we expect to be able to combine secrets using addition and then reconstruct a shared polynomial which doesn't work with the byte wise sharing.
This implementation IS NOT constant time as it leverages math/big for big number operations through the finitefield package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Combiner ¶
type Combiner struct {
// contains filtered or unexported fields
}
Combiner reconstructs the secret
func NewCombiner ¶
func NewCombiner(f *finitefield.Field) *Combiner
type Dealer ¶
type Dealer struct {
// contains filtered or unexported fields
}
Dealer knows the secret and constructs the polynomial
func NewDealer ¶
func NewDealer(f *finitefield.Field) *Dealer
func (Dealer) Split ¶
Split takes secret and generates a `parts` number of shares, `threshold` of which are required to reconstruct the secret. The parts and threshold must be at least 2, and less than 256. The returned shares are each one byte longer than the secret as they attach a tag used to reconstruct the secret.
type Polynomial ¶
type Polynomial struct {
Coefficients []*finitefield.Element
}
Polynomial represents a polynomial of arbitrary degree
type Share ¶
type Share struct {}
Share is a part of the split secret
func NewShare ¶
func NewShare(x byte, y []byte, f *finitefield.Field) *Share
NewShare is a Share constructor
func ShareFromBytes ¶
func ShareFromBytes(b []byte, f *finitefield.Field) *Share