secp256k1fx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ID = ids.NewID([32]byte{'s', 'e', 'c', 'p', '2', '5', '6', 'k', '1', 'f', 'x'})
)

ID that this Fx uses when labeled

Functions

This section is empty.

Types

type Credential

type Credential struct {
	Sigs [][crypto.SECP256K1RSigLen]byte `serialize:"true" json:"signatures"`
}

Credential ...

func (*Credential) Verify

func (cr *Credential) Verify() error

Verify ...

type Factory

type Factory struct{}

Factory ...

func (*Factory) New

func (f *Factory) New() (interface{}, error)

New ...

type Fx

type Fx struct {
	VM          VM
	SECPFactory crypto.FactorySECP256K1R
}

Fx describes the secp256k1 feature extension

func (*Fx) Initialize

func (fx *Fx) Initialize(vmIntf interface{}) error

Initialize ...

func (*Fx) InitializeVM

func (fx *Fx) InitializeVM(vmIntf interface{}) error

InitializeVM ...

func (*Fx) VerifyCredentials

func (fx *Fx) VerifyCredentials(tx Tx, in *Input, cred *Credential, out *OutputOwners) error

VerifyCredentials ensures that the output can be spent by the input with the credential. A nil return values means the output can be spent.

func (*Fx) VerifyOperation

func (fx *Fx) VerifyOperation(txIntf, opIntf, credIntf interface{}, utxosIntf []interface{}) error

VerifyOperation ...

func (*Fx) VerifySpend

func (fx *Fx) VerifySpend(tx Tx, in *TransferInput, cred *Credential, utxo *TransferOutput) error

VerifySpend ensures that the utxo can be sent to any address

func (*Fx) VerifyTransfer

func (fx *Fx) VerifyTransfer(txIntf, inIntf, credIntf, utxoIntf interface{}) error

VerifyTransfer ...

type Input

type Input struct {
	SigIndices []uint32 `serialize:"true" json:"signatureIndices"`
}

Input ...

func (*Input) Verify

func (in *Input) Verify() error

Verify this input is syntactically valid

type Keychain

type Keychain struct {

	// These can be used to iterate over. However, they should not be modified externally.
	Addrs ids.ShortSet
	Keys  []*crypto.PrivateKeySECP256K1R
	// contains filtered or unexported fields
}

Keychain is a collection of keys that can be used to spend outputs

func NewKeychain

func NewKeychain() *Keychain

NewKeychain returns a new, empty, keychain

func (*Keychain) Add

func (kc *Keychain) Add(key *crypto.PrivateKeySECP256K1R)

Add a new key to the key chain

func (Keychain) Addresses

func (kc Keychain) Addresses() ids.ShortSet

Addresses returns a list of addresses this keychain manages

func (Keychain) Get

Get a key from the keychain. If the key is unknown, the

func (*Keychain) Match

func (kc *Keychain) Match(owners *OutputOwners) ([]uint32, []*crypto.PrivateKeySECP256K1R, bool)

Match attempts to match a list of addresses up to the provided threshold

func (*Keychain) New

func (kc *Keychain) New() (*crypto.PrivateKeySECP256K1R, error)

New returns a newly generated private key

func (*Keychain) PrefixedString

func (kc *Keychain) PrefixedString(prefix string) string

PrefixedString returns the key chain as a string representation with [prefix] added before every line.

func (*Keychain) Spend

Spend attempts to create an input

func (*Keychain) String

func (kc *Keychain) String() string

type MintInput

type MintInput struct {
	Input `serialize:"true"`
}

MintInput ...

type MintOperation

type MintOperation struct {
	MintInput      Input          `serialize:"true" json:"mintInput"`
	MintOutput     MintOutput     `serialize:"true" json:"mintOutput"`
	TransferOutput TransferOutput `serialize:"true" json:"transferOutput"`
}

MintOperation ...

func (*MintOperation) Outs

func (op *MintOperation) Outs() []verify.Verifiable

Outs ...

func (*MintOperation) Verify

func (op *MintOperation) Verify() error

Verify ...

type MintOutput

type MintOutput struct {
	OutputOwners `serialize:"true"`
}

MintOutput ...

func (*MintOutput) Verify

func (out *MintOutput) Verify() error

Verify ...

type OutputOwners

type OutputOwners struct {
	Threshold uint32        `serialize:"true" json:"threshold"`
	Addrs     []ids.ShortID `serialize:"true" json:"addresses"`
}

OutputOwners ...

func (*OutputOwners) Addresses

func (out *OutputOwners) Addresses() [][]byte

Addresses returns the addresses that manage this output

func (*OutputOwners) Equals

func (out *OutputOwners) Equals(other *OutputOwners) bool

Equals returns true if the provided owners create the same condition

func (*OutputOwners) Sort

func (out *OutputOwners) Sort()

Sort ...

func (*OutputOwners) Verify

func (out *OutputOwners) Verify() error

Verify ...

type TestTx

type TestTx struct{ Bytes []byte }

TestTx is a minimal implementation of a Tx

func (*TestTx) UnsignedBytes

func (tx *TestTx) UnsignedBytes() []byte

UnsignedBytes returns Bytes

type TestVM

type TestVM struct {
	CLK  *timer.Clock
	Code codec.Codec
	Log  logging.Logger
}

TestVM is a minimal implementation of a VM

func (*TestVM) Clock

func (vm *TestVM) Clock() *timer.Clock

Clock returns CLK

func (*TestVM) Codec

func (vm *TestVM) Codec() codec.Codec

Codec returns Code

func (*TestVM) Logger

func (vm *TestVM) Logger() logging.Logger

Logger returns Log

type TransferInput

type TransferInput struct {
	Amt   uint64 `serialize:"true" json:"amount"`
	Input `serialize:"true"`
}

TransferInput ...

func (*TransferInput) Amount

func (in *TransferInput) Amount() uint64

Amount returns the quantity of the asset this input produces

func (*TransferInput) Verify

func (in *TransferInput) Verify() error

Verify this input is syntactically valid

type TransferOutput

type TransferOutput struct {
	Amt      uint64 `serialize:"true" json:"amount"`
	Locktime uint64 `serialize:"true" json:"locktime"`

	OutputOwners `serialize:"true"`
}

TransferOutput ...

func (*TransferOutput) Amount

func (out *TransferOutput) Amount() uint64

Amount returns the quantity of the asset this output consumes

func (*TransferOutput) Verify

func (out *TransferOutput) Verify() error

Verify ...

type Tx

type Tx interface {
	UnsignedBytes() []byte
}

Tx that this Fx is supporting

type VM

type VM interface {
	Codec() codec.Codec
	Clock() *timer.Clock
	Logger() logging.Logger
}

VM that this Fx must be run by

Jump to

Keyboard shortcuts

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