Documentation ¶
Index ¶
Constants ¶
const (
DefaultPrimeStr = "115792089237316195423570985008687907853269984665640564039457584007913129639747"
)
const ( // when using Get on a secret. This is caused by appending // a one byte tag to the share. ShareOverhead = 1 )
Variables ¶
var ()
Functions ¶
func Combine ¶
Combine is used to reverse a Get and reconstruct a secret once a `threshold` number of parts are available.
func Create ¶
*
- 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 IsValidShare ¶
*
- 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 Split ¶
Get takes an arbitrarily long 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.
Types ¶
type ShamirSharingScheme ¶
type ShamirSharingScheme struct { // N: the number of shares that each secret is split into N int // R: the minimum number of shares needed to reconstruct the secret R int // contains filtered or unexported fields }
In Shamir’s scheme, instead of picking random field elements that sum up to the secret x as we did above, to share x we sample a random polynomial f with the condition that f(0) = x and evaluate this polynomial at N non-zero points to obtain the shares as f(1), f(2), …, f(N).
func NewShamirSharingScheme ¶
func NewShamirSharingScheme(secret int, participants int, min int) ShamirSharingScheme
The essential idea of Adi Shamir's threshold scheme is that 2 points are sufficient to define a line, 3 points are sufficient to define a parabola, 4 points to define a cubic curve and so forth. That is, it takes k points to define a polynomial of degree k − 1
func (*ShamirSharingScheme) Generate ¶
func (as *ShamirSharingScheme) Generate()
split secret using shamir scheme into requested shares given that only 'minimumSplits' shares are needed to reconstruct
func (*ShamirSharingScheme) Print ¶
func (as *ShamirSharingScheme) Print()
it will print generated points using shamir secret schema
func (*ShamirSharingScheme) Reconstruct ¶
func (as *ShamirSharingScheme) Reconstruct(points []int) (error, int)
tries to reconstruct given secret from a set of points