crypto

package
v1.0.3-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

This package is a copy of <https://github.com/Wollac/async.go/tree/main/pkg/acss/crypto>

Index

Constants

View Source
const (
	// AEADKeySize denotes the size of the AEAD keys in bytes.
	AEADKeySize = chacha20poly1305.KeySize
	// AEADOverhead denotes the number of additional bytes required.
	AEADOverhead = chacha20poly1305.Overhead
)

Variables

View Source
var (
	ErrNotCanonical       = errors.New("not canonical")
	ErrSmallOrder         = errors.New("small order")
	ErrInvalidInputLength = errors.New("invalid input length")
	ErrDecryptionFailed   = errors.New("decryption failed")
	ErrVerificationFailed = errors.New("verification failed")
)

errors returned by the package

Functions

func CheckImplicate

func CheckImplicate(g kyber.Group, dealerPublic, peerPublic kyber.Point, data []byte) ([]byte, error)

CheckImplicate verifies whether data is a correct implicate from peer. It returns the secret which can then be used to decrypt the corresponding share.

func DealLen

func DealLen(g kyber.Group, n int) int

DealLen returns the length of Deal in bytes.

func DecryptShare

func DecryptShare(g kyber.Group, deal *Deal, index int, secret []byte) (*share.PriShare, error)

DecryptShare decrypts and validates the encrypted share with the given index using the given secret. An error is returned if no valid share could be decrypted.

func Implicate

func Implicate(suite suites.Suite, dealerPublic kyber.Point, ownPrivate kyber.Scalar) []byte

Implicate returns the secret as well as a proof of correctness. The proof is a NIZK that sk∗G=pk ∧ sk∗pk_d=secret.

func ImplicateLen

func ImplicateLen(g kyber.Group) int

ImplicateLen returns the length of Implicate in bytes.

func PointUnmarshalFrom

func PointUnmarshalFrom(P kyber.Point, r io.Reader) (int, error)

PointUnmarshalFrom decodes the content of the point P by reading from an io.Reader. It performs all additional sanity checks, if present.

func ScalarUnmarshalFrom

func ScalarUnmarshalFrom(s kyber.Scalar, r io.Reader) (int, error)

ScalarUnmarshalFrom decodes the content of the scalar s by reading from an io.Reader. It performs all additional sanity checks, if present.

func Secret

func Secret(g kyber.Group, remotePublic kyber.Point, ownPrivate kyber.Scalar) []byte

Secret computes and returns the shared ephemeral secret.

func SecretLen

func SecretLen(g kyber.Group) int

SecretLen returns the length of Secret in bytes.

func ShareLen

func ShareLen(g kyber.Group) int

ShareLen returns the length of an encrypted share in bytes.

Types

type Commits

type Commits []kyber.Point

Commits represents the Feldman VSS commitments.

func (Commits) MarshalBinary

func (c Commits) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (Commits) MarshalTo

func (c Commits) MarshalTo(w io.Writer) (int, error)

MarshalTo encodes the receiver into binary and writes it to w.

type Deal

type Deal struct {
	Commits Commits     // Feldman VSS commitments
	PubKey  kyber.Point // ephemeral public key used to encrypt the shares
	Shares  [][]byte    // encrypted shares of all peers
}

Deal contains the information distributed by the dealer.

func DealUnmarshalBinary

func DealUnmarshalBinary(g kyber.Group, n int, data []byte) (*Deal, error)

DealUnmarshalBinary parses and verifies a deal. If an error is returned, the data is invalid and cannot be used by any peer. Otherwise, it returns the commitments C, public key pk_d and the encrypted shares.

func NewDeal

func NewDeal(suite suites.Suite, pubKeys []kyber.Point, scalar kyber.Scalar) *Deal

NewDeal creates data necessary to distribute scalar to the peers. It returns the commitments C, public key pk_d and the encrypted shares Z.

func (*Deal) MarshalBinary

func (d *Deal) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

type Share

type Share = share.PriShare

Share represents a private share of the secret.

func InterpolateShare

func InterpolateShare(g kyber.Group, shares []*Share, n, i int) (*Share, error)

InterpolateShare interpolates a new private share for index i.

Jump to

Keyboard shortcuts

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