conditions

package
v0.0.0-...-0872f49 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2017 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Params
	HASH_SIZE         = 32
	MAX_PAYLOAD_SIZE  = 0xfff
	SUPPORTED_BITMASK = 0x3f

	PREIMAGE_ID      = 0
	PREIMAGE_BITMASK = 0x03

	PREFIX_ID      = 1
	PREFIX_BITMASK = 0x05

	THRESHOLD_ID      = 2
	THRESHOLD_BITMASK = 0x09

	RSA_ID      = 3
	RSA_BITMASK = 0x11
	RSA_SIZE    = rsa.KEY_SIZE + rsa.SIGNATURE_SIZE

	ED25519_ID      = 4
	ED25519_BITMASK = 0x20
	ED25519_SIZE    = ed25519.PUBKEY_SIZE + ed25519.SIGNATURE_SIZE

	TIMEOUT_ID      = 5
	TIMEOUT_BITMASK = 0x00
)

Variables

This section is empty.

Functions

func ConditionURI

func ConditionURI(p []byte) (string, error)

func DefaultFulfillmentEd25519

func DefaultFulfillmentEd25519(pubkey *ed25519.PublicKey, sig *ed25519.Signature) *fulfillmentEd25519

func DefaultFulfillmentThreshold

func DefaultFulfillmentThreshold(subs Fulfillments) *fulfillmentThreshold

func DefaultFulfillmentThresholdFromPrivkeys

func DefaultFulfillmentThresholdFromPrivkeys(msg []byte, privkeys ...crypto.PrivateKey) (_ *fulfillmentThreshold, err error)

For testing..

func DefaultFulfillmentThresholdFromPubkeys

func DefaultFulfillmentThresholdFromPubkeys(pubkeys []crypto.PublicKey) (*fulfillmentThreshold, error)

func FulfillWithPrivkey

func FulfillWithPrivkey(f Fulfillment, msg []byte, privkey crypto.PrivateKey) error

func FulfillmentThresholdFromPubkeys

func FulfillmentThresholdFromPubkeys(pubkeys []crypto.PublicKey, threshold, weight int, weights []int) (*fulfillmentThreshold, error)

func FulfillmentURI

func FulfillmentURI(p []byte) (string, error)

func NewFulfillment

func NewFulfillment(id int, outer Fulfillment, payload []byte, weight int) *fulfillment

func NewFulfillmentEd25519

func NewFulfillmentEd25519(pubkey *ed25519.PublicKey, sig *ed25519.Signature, weight int) *fulfillmentEd25519

func NewFulfillmentPreImage

func NewFulfillmentPreImage(preimage []byte, weight int) *fulfillmentPreImage

func NewFulfillmentPrefix

func NewFulfillmentPrefix(prefix []byte, sub Fulfillment, weight int) *fulfillmentPrefix

func NewFulfillmentRSA

func NewFulfillmentRSA(pubkey *rsa.PublicKey, sig *rsa.Signature, weight int) *fulfillmentRSA

func NewFulfillmentThreshold

func NewFulfillmentThreshold(subs Fulfillments, threshold, weight int) *fulfillmentThreshold

func NewFulfillmentTimeout

func NewFulfillmentTimeout(expires int64, weight int) *fulfillmentTimeout

func Sum256

func Sum256(p []byte) []byte

func ThresholdBitmask

func ThresholdBitmask(subs Fulfillments) int

func ThresholdHash

func ThresholdHash(subs Fulfillments, threshold int) []byte

Sort subconditions then hash them..

func ThresholdPayload

func ThresholdPayload(subs Fulfillments, threshold int) []byte

func ThresholdSize

func ThresholdSize(subs Fulfillments, threshold int) int

Types

type Condition

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

func GetCondition

func GetCondition(f Fulfillment) *Condition

func NewCondition

func NewCondition(bitmask int, hash []byte, id int, pubkey crypto.PublicKey, size, weight int) *Condition

func NilCondition

func NilCondition() *Condition

func (Condition) Bitmask

func (f Condition) Bitmask() int

func (Condition) Data

func (f Condition) Data() Data

func (*Condition) FromString

func (c *Condition) FromString(uri string) (err error)

func (Condition) Hash

func (f Condition) Hash() []byte

func (Condition) Id

func (f Condition) Id() int

func (Condition) Init

func (f Condition) Init()

func (*Condition) IsCondition

func (c *Condition) IsCondition() bool

func (*Condition) MarshalBinary

func (c *Condition) MarshalBinary() ([]byte, error)

func (Condition) PublicKey

func (f Condition) PublicKey() crypto.PublicKey

func (Condition) Signature

func (f Condition) Signature() crypto.Signature

func (Condition) Size

func (f Condition) Size() int

func (*Condition) String

func (c *Condition) String() string

func (Condition) Subfulfillments

func (f Condition) Subfulfillments() Fulfillments

func (*Condition) UnmarshalBinary

func (c *Condition) UnmarshalBinary(p []byte) (err error)

func (Condition) Validate

func (f Condition) Validate(p []byte) bool

func (Condition) Weight

func (f Condition) Weight() int

type Fulfillment

type Fulfillment interface {
	Bitmask() int
	Data() Data
	FromString(string) error
	Hash() []byte
	Id() int
	Init()
	IsCondition() bool
	MarshalBinary() ([]byte, error)
	PublicKey() crypto.PublicKey
	Signature() crypto.Signature
	Size() int
	String() string
	Subfulfillments() Fulfillments
	UnmarshalBinary([]byte) error
	Validate([]byte) bool
	Weight() int
}

func DefaultFulfillmentFromPrivkey

func DefaultFulfillmentFromPrivkey(msg []byte, privkey crypto.PrivateKey) (Fulfillment, error)

func DefaultFulfillmentFromPubkey

func DefaultFulfillmentFromPubkey(pubkey crypto.PublicKey) (Fulfillment, error)

func DefaultUnmarshalBinary

func DefaultUnmarshalBinary(p []byte) (Fulfillment, error)

func DefaultUnmarshalURI

func DefaultUnmarshalURI(uri string) (Fulfillment, error)

func FulfillmentFromPrivkey

func FulfillmentFromPrivkey(msg []byte, privkey crypto.PrivateKey, weight int) (Fulfillment, error)

func FulfillmentFromPubKey

func FulfillmentFromPubKey(pubkey crypto.PublicKey, weight int) (Fulfillment, error)

func UnmarshalBinary

func UnmarshalBinary(p []byte, weight int) (f Fulfillment, err error)

func UnmarshalURI

func UnmarshalURI(uri string, weight int) (f Fulfillment, err error)

type Fulfillments

type Fulfillments []Fulfillment

func DefaultFulfillmentsFromPrivkeys

func DefaultFulfillmentsFromPrivkeys(msgs [][]byte, privkeys []crypto.PrivateKey) (_ Fulfillments, err error)

func DefaultFulfillmentsFromPubkeys

func DefaultFulfillmentsFromPubkeys(pubkeys []crypto.PublicKey) (_ Fulfillments, err error)

func FulfillmentsFromPrivkeys

func FulfillmentsFromPrivkeys(msgs [][]byte, privkeys []crypto.PrivateKey, weights []int) (_ Fulfillments, err error)

func FulfillmentsFromPubkeys

func FulfillmentsFromPubkeys(pubkeys []crypto.PublicKey, weights []int) (_ Fulfillments, err error)

func ThresholdSubs

func ThresholdSubs(p []byte) (Fulfillments, int, error)

func (Fulfillments) Len

func (fs Fulfillments) Len() int

func (Fulfillments) Less

func (fs Fulfillments) Less(i, j int) bool

sort in `descending` order by weights, then lexicographically

func (Fulfillments) Swap

func (fs Fulfillments) Swap(i, j int)

Jump to

Keyboard shortcuts

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