Documentation ¶
Index ¶
- Variables
- func Decrypt(key *[32]byte, c *CipherText) ([]byte, bool)
- func NewChest(random io.Reader, payload []byte, time int, mod *big.Int) (chest *Chest, key *ChestKey, err error)
- func NewChestFromTimelock(random io.Reader, payload []byte, time int, timelock *Timelock, mod *big.Int) (chest *Chest, key *ChestKey, err error)
- func Verify(locked *big.Int, proof *TimelockProof, time int, mod *big.Int) bool
- type Chest
- type ChestKey
- type CipherText
- type Timelock
- type TimelockProof
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidArgument = errors.New("invalid argument") ErrVerification = errors.New("timelock tuple verification failed") )
Functions ¶
func NewChest ¶
func NewChest(random io.Reader, payload []byte, time int, mod *big.Int) (chest *Chest, key *ChestKey, err error)
Example ¶
time := 10_000 payload := []byte("message") chest, key, err := NewChest(rand.Reader, payload, time, nil) fmt.Println(err) var chestBytes, keyBytes bytes.Buffer err = encoding.Encode(&chestBytes, chest) fmt.Println(err) err = encoding.Encode(&keyBytes, key) fmt.Println(err)
Output: <nil> <nil> <nil>
func NewChestFromTimelock ¶
func NewChestFromTimelock(random io.Reader, payload []byte, time int, timelock *Timelock, mod *big.Int) (chest *Chest, key *ChestKey, err error)
Example ¶
time := 10_000 precomputed, err := PrecomputeTimelock(rand.Reader, time, nil) // can be cached fmt.Println(err) payload := []byte("message") chest, key, err := NewChestFromTimelock(rand.Reader, payload, time, precomputed, nil) fmt.Println(err) var chestBytes, keyBytes bytes.Buffer err = encoding.Encode(&chestBytes, chest) fmt.Println(err) err = encoding.Encode(&keyBytes, key) fmt.Println(err)
Output: <nil> <nil> <nil> <nil>
Types ¶
type Chest ¶
type Chest struct { LockedValue tz.BigUint `json:"locked_value"` CipherText CipherText `json:"ciphertext"` }
type ChestKey ¶
type ChestKey = TimelockProof
type CipherText ¶
type Timelock ¶
type Timelock struct { LockedValue tz.BigUint `json:"locked_value"` UnlockedValue tz.BigUint `json:"unlocked_value"` VDFProof tz.BigUint `json:"vdf_proof"` }
func PrecomputeTimelock ¶
type TimelockProof ¶
func UnlockAndProve ¶
func UnlockAndProve(time int, locked, mod *big.Int) *TimelockProof
func (*TimelockProof) SymmetricKey ¶
func (p *TimelockProof) SymmetricKey(mod *big.Int) [32]byte
Click to show internal directories.
Click to hide internal directories.