hashlock

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package hashlock implements token locking.

> A Hashlock is a type of encumbrance that restricts the spending of an output > until a specified piece of data is publicly revealed. Hashlocks have the useful > property that once any hashlock is opened publicly, any other hashlock secured > using the same key can also be opened. This makes it possible to create > multiple outputs that are all encumbered by the same hashlock and which all > become spendable at the same time. Hashlocks have been used independently (see > below) but are most commonly described as part of a system such as Hashed > Timelock Contracts.

https://en.bitcoinwiki.org/wiki/Hashlock

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PreimageCondition

func PreimageCondition(preimage []byte) weave.Condition

PreimageCondition calculates a sha256 hash and then

Types

type Authenticate

type Authenticate struct{}

Authenticate implements x.Authenticator and provides authentication based on public-key signatures.

func (Authenticate) GetConditions

func (a Authenticate) GetConditions(ctx weave.Context) []weave.Condition

GetConditions returns which preimages have authorized the current Context. May be nil

func (Authenticate) HasAddress

func (a Authenticate) HasAddress(ctx weave.Context, addr weave.Address) bool

HasAddress returns true if the given address had the preimage permission in the current Context.

type Decorator

type Decorator struct{}

Decorator adds permissions to context based on preimages

func NewDecorator

func NewDecorator() Decorator

NewDecorator returns a default hashlock decorator

func (Decorator) Check

func (d Decorator) Check(ctx weave.Context, store weave.KVStore, tx weave.Tx, next weave.Checker) (weave.CheckResult, error)

Check verifies signatures before calling down the stack.

func (Decorator) Deliver

func (d Decorator) Deliver(ctx weave.Context, store weave.KVStore, tx weave.Tx, next weave.Deliverer) (weave.DeliverResult, error)

Deliver verifies signatures before calling down the stack.

type HashKeyTx

type HashKeyTx interface {
	// GetPreimage should return a hash preimage if provided
	// or nil if not included in this tx
	GetPreimage() []byte
}

HashKeyTx is an optional interface for a Tx that allows it to provide Keys (Preimages) to open HashLocks

Jump to

Keyboard shortcuts

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