tdh2easy

package
v0.0.0-...-e6634ab Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

Package tdh2easy implements an easy interface of TDH2-based hybrid encryption.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aggregate

func Aggregate(c *Ciphertext, shares []*DecryptionShare, n int) ([]byte, error)

Aggregate decrypts the TDH2-encrypted key and using it recovers the symmetrically encrypted plaintext. It takes decryption shares and the total number of participants as the arguments. Ciphertext and shares MUST be verified before calling Aggregate, all the shares have to be distinct and their number has to be at least k (the scheme's threshold).

func GenerateKeys

func GenerateKeys(k, n int) (*MasterSecret, *PublicKey, []*PrivateShare, error)

GenerateKeys generates and returns, the master secret, public key, and private shares. It takes the total number of nodes n and a threshold k (the number of shares sufficient for decryption).

func Redeal

func Redeal(pk *PublicKey, ms *MasterSecret, k, n int) (*PublicKey, []*PrivateShare, error)

Redeal re-deals private shares such that new quorums can decrypt old ciphertexts. It takes the previous public key and master secret as well as the number of nodes sufficient for decrypt k, and the total number of nodes n. It returns a new public key and private shares. The master secret passed corresponds to the public key returned. The old public key can still be used for encryption but it cannot be used for share verification (the new key has to be used instead).

func VerifyShare

func VerifyShare(c *Ciphertext, pk *PublicKey, share *DecryptionShare) error

VerifyShare checks if the share matches the ciphertext and public key.

Types

type Ciphertext

type Ciphertext struct {
	// contains filtered or unexported fields
}

Ciphertext encodes hybrid ciphertext.

func Encrypt

func Encrypt(pk *PublicKey, msg []byte) (*Ciphertext, error)

Encrypt generates a fresh symmetric key, encrypts and authenticates the message with it, and encrypts the key using TDH2. It returns a struct encoding the generated ciphertexts.

func (*Ciphertext) Marshal

func (c *Ciphertext) Marshal() ([]byte, error)

func (*Ciphertext) UnmarshalVerify

func (c *Ciphertext) UnmarshalVerify(data []byte, pk *PublicKey) error

UnmarshalVerify unmarshals ciphertext and verifies if it matches the public key.

type DecryptionShare

type DecryptionShare struct {
	// contains filtered or unexported fields
}

DecryptionShare encodes TDH2 decryption share.

func Decrypt

func Decrypt(c *Ciphertext, x_i *PrivateShare) (*DecryptionShare, error)

Decrypt returns a decryption share for the ciphertext.

func (*DecryptionShare) Index

func (d *DecryptionShare) Index() int

Index returns private share index.

func (DecryptionShare) Marshal

func (d DecryptionShare) Marshal() ([]byte, error)

func (DecryptionShare) MarshalJSON

func (d DecryptionShare) MarshalJSON() ([]byte, error)

func (*DecryptionShare) Unmarshal

func (d *DecryptionShare) Unmarshal(data []byte) error

func (*DecryptionShare) UnmarshalJSON

func (d *DecryptionShare) UnmarshalJSON(data []byte) error

type MasterSecret

type MasterSecret struct {
	// contains filtered or unexported fields
}

MasterSecret encodes TDH2 master key.

func (*MasterSecret) Clear

func (m *MasterSecret) Clear()

func (MasterSecret) Marshal

func (m MasterSecret) Marshal() ([]byte, error)

func (MasterSecret) MarshalJSON

func (m MasterSecret) MarshalJSON() ([]byte, error)

func (*MasterSecret) Unmarshal

func (m *MasterSecret) Unmarshal(data []byte) error

func (MasterSecret) UnmarshalJSON

func (m MasterSecret) UnmarshalJSON(data []byte) error

type PrivateShare

type PrivateShare struct {
	// contains filtered or unexported fields
}

PrivateShare encodes TDH2 private share.

func (*PrivateShare) Clear

func (p *PrivateShare) Clear()

func (*PrivateShare) Index

func (p *PrivateShare) Index() int

Index returns private share index.

func (PrivateShare) Marshal

func (p PrivateShare) Marshal() ([]byte, error)

func (*PrivateShare) MarshalJSON

func (p *PrivateShare) MarshalJSON() ([]byte, error)

func (*PrivateShare) Unmarshal

func (p *PrivateShare) Unmarshal(data []byte) error

func (*PrivateShare) UnmarshalJSON

func (p *PrivateShare) UnmarshalJSON(data []byte) error

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey encodes TDH2 public key.

func (PublicKey) Marshal

func (p PublicKey) Marshal() ([]byte, error)

func (*PublicKey) MarshalJSON

func (p *PublicKey) MarshalJSON() ([]byte, error)

func (*PublicKey) Unmarshal

func (p *PublicKey) Unmarshal(data []byte) error

func (*PublicKey) UnmarshalJSON

func (p *PublicKey) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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