Skip to content

A pure Go implementation of Shamir's Secret Sharing algorithm

License

Notifications You must be signed in to change notification settings

lafriks/go-shamir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

37388b7 · Aug 14, 2024

History

13 Commits
Aug 14, 2024
May 22, 2022
Jan 5, 2021
Aug 14, 2024
Jan 5, 2021
Dec 11, 2021
Aug 14, 2024
Jan 5, 2021
Dec 11, 2021
Aug 14, 2024
Dec 11, 2021

Repository files navigation

Shamir's Secret Sharing

Go Reference Coverage Status

Based on github.com/codahale/sss

A pure Go implementation of Shamir's Secret Sharing algorithm

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
}