Help us shape the future of Go! Take the 2026 Go Developer Survey

timelock

package module
v0.0.0-...-740ea88 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Overview

Package tlock provides an API for encrypting/decrypting data using drand time lock encryption. This allows data to be encrypted and only decrypted in the future.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPublicKey = errors.New("the public key received from the network to encrypt this was infinity and thus insecure")
View Source
var ErrTooEarly = errors.New("too early to decrypt")

ErrTooEarly represents an error when a decryption operation happens early.

View Source
var ErrWrongChainhash = errors.New("invalid chainhash")

Functions

func BytesToCiphertext

func BytesToCiphertext(scheme crypto.Scheme, b []byte) (*ibe.Ciphertext, error)

BytesToCiphertext converts bytes to a ciphertext.

func CiphertextToBytes

func CiphertextToBytes(scheme crypto.Scheme, ciphertext *ibe.Ciphertext) ([]byte, error)

CiphertextToBytes converts a ciphertext value to a set of bytes.

func TimeLock

func TimeLock(scheme crypto.Scheme, publicKey kyber.Point, roundNumber uint64, data []byte) (*ibe.Ciphertext, error)

TimeLock encrypts the specified data for the given round number. The data can't be decrypted until the specified round is reached by the network in use.

func TimeUnlock

func TimeUnlock(scheme crypto.Scheme, publicKey kyber.Point, beacon chain.Beacon, ciphertext *ibe.Ciphertext) ([]byte, error)

TimeUnlock decrypts the specified ciphertext for the given beacon. The ciphertext can't be decrypted until the specified round is reached by the network in use.

Types

type Network

type Network interface {
	ChainHash() string
	Current(time.Time) uint64
	PublicKey() kyber.Point
	Scheme() crypto.Scheme
	Signature(roundNumber uint64) ([]byte, error)
	SwitchChainHash(string) error
}

Network represents a system that provides support for encrypting/decrypting a DEK based on a future time.

type Tlock

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

Tlock provides an API for time lock encryption and decryption.

func New

func New(network Network) Tlock

New constructs a tlock for the specified network which can encrypt data that can be decrypted until the future. By default a new network will trust the chainhash it sees in ciphertexts and try and use these unless Strict was called to prevent it.

func (Tlock) Decrypt

func (t Tlock) Decrypt(dst io.Writer, src io.Reader) error

Decrypt will decrypt the source and write that to the destination. The decrypted data will not be decryptable unless the specified round from the encrypt call is reached by the network.

func (Tlock) Encrypt

func (t Tlock) Encrypt(dst io.Writer, src io.Reader, roundNumber uint64) (err error)

Encrypt will encrypt the source and write that to the destination. The encrypted data will not be decryptable until the specified round is reached by the network.

func (Tlock) Metadata

func (t Tlock) Metadata(dst io.Writer) (err error)

Metadata will return details about the drand network

func (Tlock) Strict

func (t Tlock) Strict() Tlock

Directories

Path Synopsis
cmd
tle command
tle/commands
Package commands implements the processing of the command line flags and processing of the encryption operation.
Package commands implements the processing of the command line flags and processing of the encryption operation.
networks
http
Package http implements the Network interface for the tlock package.
Package http implements the Network interface for the tlock package.

Jump to

Keyboard shortcuts

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