shamir

package module
v0.0.0-...-7aee472 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Based on Hashicorp Vault (v1.4.0-rc1) implementation of Shamir's Secret Sharing. Modified to support io.Reader and io.Writer interfaces.

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 one byte tag to the share.
	ShareOverhead = 1
)

Variables

This section is empty.

Functions

func Combine

func Combine(parts [][]byte) ([]byte, error)

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

func CombineReader

func CombineReader(part ...io.Reader) (*combine, error)

CombineReader produces an io.Reader which combines a secret that has previously been split (see SplitWriter).

func Split

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

Split 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.

func SplitWriter

func SplitWriter(threshold int, part ...io.Writer) (*split, error)

SplitWriter creates an io.Writer where written data is split into parts using Shamir's Secret Sharing. The first byte written to each part is a tag used to reconstruct the secret (see also Split, which writes the tag byte at the end of byte slice).

Types

This section is empty.

Jump to

Keyboard shortcuts

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