shamir

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MPL-2.0 Imports: 5 Imported by: 0

README

This code is modified version of Shamir's algorithm from: https://github.com/hashicorp/vault/tree/master/shamir.

Original code was using GF(2^8) while we are using GF(2^16) to be able to split secret to more than 255 parts.

Furhtermore, parallelization with go routines was added, and a simple code to generate and verify lookup tables for arbitrary polynomial and generator.

Documentation

Index

Constants

View Source
const (
	// ShareOverhead is the byte size overhead of each share
	// when using Split on a secret. This is caused by appending
	// a word-long tag to the share.
	ShareOverhead = 2

	SizeGF16     = 65536
	ModuloGF16   = SizeGF16 - 1
	MaxPartsGF16 = SizeGF16 - 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Part

type Part []byte

func Split

func Split(secret Secret, parts, threshold int) ([]Part, error)

Split takes an arbitrarily long secret with even length 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 'sizeGF16'. The returned shares are each one word longer than the secret as they attach a tag used to reconstruct the secret.

type Secret

type Secret []byte

func Combine

func Combine(parts []Part) (Secret, error)

Combine is used to reverse a Split and reconstruct a secret once a `threshold` number of parts are available.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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