cryptography

package
v0.1.2-0...-8dfc45d Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeySize = fmt.Errorf("key is not %d bytes long", ed25519PrivateSeedSize)

ErrKeySize indicates that the byte array used as entropy source is not 32 bytes long

Functions

func Decrypt

func Decrypt(key, nonce, associated, ciphertext []byte) (message []byte, err error)

Decrypt authenticates and decrypts a message that was encrypted with ChaCha20Poly1305.

func EdSign

func EdSign(key, message []byte) (signature []byte, pubkey ed25519.PublicKey, err error)

EdSign signs a message with a Ed25519 private key generated from 32 bytes of entropy.

func EdVerify

func EdVerify(pubkey, message, signature []byte) (ok bool)

EdVerify verifies a previously signed message with an Ed25519 signature.

func Encrypt

func Encrypt(key, nonce, associated, message []byte) (ciphertext []byte, err error)

Encrypt uses authenticated encryption with ChaCha20Poly1305 to encrypt a message.

func RandomKey

func RandomKey() (key []byte)

RandomKey reads randomness to generate a 32 byte key and panics if something went wrong.

func ReedSolomonEncode

func ReedSolomonEncode(data []byte, threshold, total int) (split [][]byte, err error)

ReedSolomonEncode splits and encodes data into $total shards, out of which $threshold are needed for reconstruction.

func ReedSolomonReconstruct

func ReedSolomonReconstruct(split [][]byte, threshold, total int) (data []byte, err error)

ReedSolomonReconstruct does

func ShamirCombine

func ShamirCombine(keyshares [][]byte) (key []byte, err error)

ShamirCombine reconstructs a 32 byte key from previously split keyshares. There is a minimum threshold required to recover the correct secret, however no error is emitted if you do not supply enough shares. You will simply receive a corrupted / wrong key.

func ShamirSplit

func ShamirSplit(key []byte, threshold, shares int) (keyshares [][]byte, err error)

ShamirSplit splits 32 bytes into keyshares using Shamir secret sharing. When later recombining the key, at least $threshold keyshares are required to construct the correct key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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