shamir

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package shamir implements Shamir's Secret Sharing over GF(256).

Each byte of a secret is split independently using a random polynomial of degree (threshold-1) over GF(256) with the irreducible polynomial x^8 + x^4 + x^3 + x + 1 (0x11b, the AES field).

Shares are encoded as [x-coordinate (1 byte)] + [y-values (len(secret) bytes)]. x-coordinates are 1-indexed to avoid evaluating at 0 (which would leak the secret).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combine

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

Combine reconstructs a secret from shares using Lagrange interpolation at x=0 in GF(256). All shares must have the same length and distinct x-coordinates.

func Split

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

Split divides secret into n shares such that any threshold shares can reconstruct the original. threshold must be >= 2, n >= threshold, n <= 255. Returns n shares, each of length 1 + len(secret).

func Verify

func Verify(shares [][]byte, expected []byte) bool

Verify checks that a set of shares can reconstruct a known secret. Uses constant-time comparison.

Types

This section is empty.

Jump to

Keyboard shortcuts

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