secretsharing

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 2 Imported by: 9

README

Secure Secret Sharing

secret-sharing Go Reference codecov

  import "github.com/bytemare/secret-sharing"

This package implements Shamir's Secret Sharing extended with Feldman's Verifiable Secret Sharing over elliptic curve groups. It is aimed to be very easy to use.

Secret sharing enables to shard (or split) a secret key into an arbitrary number of shares n and to recover that same key with any subset of at minimum t of these key shares in a (t,n)-threshold scheme.

Note that the key distribution (sharding) algorithm used in this package is a trusted dealer (i.e. centralised). If you need a truly decentralized key generation, you can use the dkg package which builds on this package.

Documentation Go Reference

You can find the documentation and usage examples in the package doc.

Versioning

SemVer is used for versioning. For the versions available, see the tags on the repository.

Contributing

Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Overview

Package secretsharing provides Shamir Secret Sharing operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combine

func Combine(g group.Group, shares []*KeyShare) (*group.Scalar, error)

Combine recovers the constant secret by combining the key shares.

func PolynomialInterpolateConstant

func PolynomialInterpolateConstant(g group.Group, shares []*KeyShare) (*group.Scalar, error)

PolynomialInterpolateConstant recovers the constant term of the interpolating polynomial defined by the set of key shares.

func ShardReturnPolynomial added in v0.1.1

func ShardReturnPolynomial(
	g group.Group,
	secret *group.Scalar,
	threshold, total uint,
	polynomial ...*group.Scalar,
) ([]*KeyShare, Polynomial, error)

ShardReturnPolynomial splits the secret into total shares, recoverable by a subset of threshold shares, and returns the constructed polynomial. Unless you know what you are doing, you probably want to use Shard() instead.

func Verify

func Verify(g group.Group, id uint64, pk *group.Element, coms Commitment) bool

Verify allows verification of a participant's secret share given its public key and the VSS commitment to the secret polynomial.

Types

type Commitment

type Commitment []*group.Element

Commitment is the tuple defining a Verifiable Secret Sharing Commitment.

func Commit

func Commit(g group.Group, polynomial Polynomial) Commitment

Commit builds a VSS vector commitment to each of the coefficients (of threshold length which uniquely determines the polynomial).

type KeyShare

type KeyShare struct {
	// SecretKey is the participant's secret share.
	SecretKey *group.Scalar

	// Identifier uniquely identifies a key share within secret sharing instance.
	Identifier uint64
}

KeyShare identifies the sharded key share for a given participant.

func Shard added in v0.1.1

func Shard(
	g group.Group,
	secret *group.Scalar,
	threshold, total uint,
	polynomial ...*group.Scalar,
) ([]*KeyShare, error)

Shard splits the secret into total shares, recoverable by a subset of threshold shares. This is the function you should probably use.

type Polynomial

type Polynomial []*group.Scalar

Polynomial over scalars, represented as a list of t+1 coefficients, where t is the threshold. The constant term is in the first position and the highest degree coefficient is in the last position.

func NewPolynomial

func NewPolynomial(coefficients uint) Polynomial

NewPolynomial returns a slice of Scalars with the capacity to hold the desired coefficients.

func (Polynomial) DeriveInterpolatingValue

func (p Polynomial) DeriveInterpolatingValue(g group.Group, id *group.Scalar) (*group.Scalar, error)

DeriveInterpolatingValue derives a value used for polynomial interpolation. id and all the coefficients must be non-zero scalars.

func (Polynomial) Evaluate

func (p Polynomial) Evaluate(x *group.Scalar) *group.Scalar

Evaluate evaluates the polynomial p at point x using Horner's method.

Jump to

Keyboard shortcuts

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