Categorygithub.com/lafriks/go-shamir
modulepackage
1.2.0
Repository: https://github.com/lafriks/go-shamir.git
Documentation: pkg.go.dev

# README

Shamir's Secret Sharing

Go Reference Coverage Status

Based on github.com/codahale/sss

A pure Go implementation of Shamir's Secret Sharing algorithm

Supports from Go 1.14

Usage

go get -u github.com/lafriks/go-shamir

Example

package main

import (
    "fmt"

    "github.com/lafriks/go-shamir"
)

func main() {
    secret := []byte("example")

    // Split secret to 5 shares and require 3 shares to reconstruct secret
    shares, err := shamir.Split(secret, 5, 3)
    if err != nil {
        panic(err)
    }

    // Reconstruct secret from shares
    reconstructed, err := shamir.Combine(shares[0], shares[2], shares[4])
    if err != nil {
        panic(err)
    }

    // secret == reconstructed
}

# Functions

Combine the given shares into the original secret.
Split the given secret into N shares of which K are required to recover the secret.

# Variables

ErrEmptySecret is returned when provided secret is empty.
ErrInvalidCount is returned when the count parameter is invalid.
ErrInvalidShares is returned when not required minimum shares are provided or shares does not have same length.
ErrInvalidThreshold is returned when the threshold parameter is invalid.