Documentation ¶
Overview ¶
Package secp256k1fx is a generated GoMock package.
Index ¶
- Constants
- Variables
- func ExtractFromAndSigners(keys []*secp256k1.PrivateKey) (set.Set[ids.ShortID], []*secp256k1.PrivateKey)
- func TraverseAliases(out *OutputOwners, msig AliasGetter, callback TraverseAliasFunc) error
- func TraverseOwners(out *OutputOwners, msig AliasGetter, callback TraverseOwnerFunc) (uint32, error)
- type AliasGetter
- type CaminoFx
- func (fx *CaminoFx) Initialize(vmIntf interface{}) error
- func (fx *CaminoFx) VerifyOperation(txIntf, opIntf, credIntf interface{}, utxosIntf []interface{}) error
- func (fx *CaminoFx) VerifyPermission(txIntf, inIntf, credIntf, ownerIntf interface{}) error
- func (fx *CaminoFx) VerifyTransfer(txIntf, inIntf, credIntf, utxoIntf interface{}) error
- type Credential
- type CredentialIntf
- type CrossTransferOutput
- type Factory
- type Fx
- func (fx *Fx) Bootstrapped() error
- func (*Fx) Bootstrapping() error
- func (*Fx) CollectMultisigAliases(ownerIntf, msigIntf interface{}) ([]interface{}, error)
- func (*Fx) CreateOutput(amount uint64, ownerIntf interface{}) (interface{}, error)
- func (fx *Fx) Initialize(vmIntf interface{}) error
- func (fx *Fx) InitializeVM(vmIntf interface{}) error
- func (*Fx) IsNestedMultisig(ownerIntf interface{}, msigIntf interface{}) (bool, error)
- func (fx *Fx) RecoverAddresses(msg []byte, verifies []verify.Verifiable) (RecoverMap, error)
- func (fx *Fx) VerifyCredentials(utx UnsignedTx, in *Input, cred *Credential, out *OutputOwners) error
- func (fx *Fx) VerifyMultisigMessage(msg []byte, inIntf, credIntf, ownerIntf, msigIntf interface{}) error
- func (fx *Fx) VerifyMultisigOutputOwner(outIntf, msigIntf interface{}) error
- func (*Fx) VerifyMultisigOwner(ownerIntf, msigIntf interface{}) error
- func (fx *Fx) VerifyMultisigPermission(txIntf, inIntf, credIntf, ownerIntf, msigIntf interface{}) error
- func (fx *Fx) VerifyMultisigTransfer(txIntf, inIntf, credIntf, utxoIntf, msigIntf interface{}) error
- func (fx *Fx) VerifyOperation(txIntf, opIntf, credIntf interface{}, utxosIntf []interface{}) error
- func (fx *Fx) VerifyPermission(txIntf, inIntf, credIntf, ownerIntf interface{}) error
- func (fx *Fx) VerifySpend(utx UnsignedTx, in *TransferInput, cred *Credential, utxo *TransferOutput) error
- func (fx *Fx) VerifyTransfer(txIntf, inIntf, credIntf, utxoIntf interface{}) error
- type Input
- type Keychain
- func (kc *Keychain) Add(key *secp256k1.PrivateKey)
- func (kc Keychain) Addresses() set.Set[ids.ShortID]
- func (kc Keychain) Get(id ids.ShortID) (keychain.Signer, bool)
- func (kc *Keychain) Match(owners *OutputOwners, time uint64) ([]uint32, []*secp256k1.PrivateKey, bool)
- func (kc *Keychain) New() (*secp256k1.PrivateKey, error)
- func (kc *Keychain) PrefixedString(prefix string) string
- func (kc *Keychain) Spend(out verify.Verifiable, time uint64) (verify.Verifiable, []*secp256k1.PrivateKey, error)
- func (kc *Keychain) SpendMultiSig(out verify.Verifiable, time uint64, msigIntf interface{}) (verify.Verifiable, []*secp256k1.PrivateKey, error)
- func (kc *Keychain) String() string
- type MintOperation
- type MintOutput
- type MockAliasGetter
- type MockAliasGetterMockRecorder
- type MultisigCredential
- type OutputOwners
- func (out *OutputOwners) Addresses() [][]byte
- func (out *OutputOwners) AddressesSet() set.Set[ids.ShortID]
- func (out *OutputOwners) Equals(other *OutputOwners) bool
- func (out *OutputOwners) Fields() (map[string]interface{}, error)
- func (out *OutputOwners) InitCtx(ctx *snow.Context)
- func (out *OutputOwners) IsZero() bool
- func (out *OutputOwners) MarshalJSON() ([]byte, error)
- func (out *OutputOwners) Sort()
- func (out *OutputOwners) Verify() error
- func (out *OutputOwners) VerifyState() error
- type Owned
- type RecoverMap
- type TestTx
- type TestVM
- type TransferInput
- type TransferOutput
- type TransferOutputIntf
- type TraverseAliasFunc
- type TraverseOwnerFunc
- type UnsignedTx
- type VM
Constants ¶
const (
CostPerSignature uint64 = 1000
)
const MaxSignatures = 256
Variables ¶
var ( ErrNotAliasGetter = errors.New("state isn't msig alias getter") ErrMsigCombination = errors.New("msig combinations not supported") )
var ( ErrWrongVMType = errors.New("wrong vm type") ErrWrongTxType = errors.New("wrong tx type") ErrWrongOpType = errors.New("wrong operation type") ErrWrongUTXOType = errors.New("wrong utxo type") ErrWrongInputType = errors.New("wrong input type") ErrWrongCredentialType = errors.New("wrong credential type") ErrWrongOwnerType = errors.New("wrong owner type") ErrMismatchedAmounts = errors.New("utxo amount and input amount are not equal") ErrWrongNumberOfUTXOs = errors.New("wrong number of utxos for the operation") ErrWrongMintCreated = errors.New("wrong mint output created from the operation") ErrTimelocked = errors.New("output is time locked") ErrTooManySigners = errors.New("input has more signers than expected") ErrTooFewSigners = errors.New("input has less signers than expected") ErrInputOutputIndexOutOfBounds = errors.New("input referenced a nonexistent address in the output") ErrInputCredentialSignersMismatch = errors.New("input expected a different number of signers than provided in the credential") ErrWrongSig = errors.New("wrong signature") )
var (
ErrEmptyRecipient = errors.New("receipient cannot be empty")
)
var ErrNilCredential = errors.New("nil credential")
var ErrNoValueInput = errors.New("input has no value")
var (
ErrNoValueOutput = errors.New("output has no value")
)
var ( // ID that this Fx uses when labeled ID = ids.ID{'s', 'e', 'c', 'p', '2', '5', '6', 'k', '1', 'f', 'x'} )
Functions ¶
func ExtractFromAndSigners ¶
func ExtractFromAndSigners(keys []*secp256k1.PrivateKey) (set.Set[ids.ShortID], []*secp256k1.PrivateKey)
ExtractFromAndSigners splits an array of PrivateKeys into `from` and `signers` The delimiter is a `nil` PrivateKey. If no delimiter exists, the given PrivateKeys are used for both from and signing Having different sets of `from` and `signer` allows multisignature feature
func TraverseAliases ¶
func TraverseAliases(out *OutputOwners, msig AliasGetter, callback TraverseAliasFunc) error
func TraverseOwners ¶
func TraverseOwners(out *OutputOwners, msig AliasGetter, callback TraverseOwnerFunc) (uint32, error)
TraverseOwners traverses through owners, visits every address and callbacks in case a non-multisig address is visited. Nested multisig alias are excluded from sigIndex concept.
Types ¶
type AliasGetter ¶
type AliasGetter interface {
GetMultisigAlias(ids.ShortID) (*multisig.AliasWithNonce, error)
}
type CaminoFx ¶
type CaminoFx struct {
Fx
}
func (*CaminoFx) Initialize ¶
func (*CaminoFx) VerifyOperation ¶
func (*CaminoFx) VerifyPermission ¶
func (*CaminoFx) VerifyTransfer ¶
type Credential ¶
type Credential struct {
Sigs [][secp256k1.SignatureLen]byte `serialize:"true" json:"signatures"`
}
func (*Credential) MarshalJSON ¶
func (cr *Credential) MarshalJSON() ([]byte, error)
MarshalJSON marshals [cr] to JSON The string representation of each signature is created using the hex formatter
func (*Credential) SignatureIndices ¶
func (*Credential) SignatureIndices() []uint32
func (*Credential) Signatures ¶
func (cr *Credential) Signatures() [][secp256k1.SignatureLen]byte
func (*Credential) Verify ¶
func (cr *Credential) Verify() error
type CredentialIntf ¶
type CredentialIntf interface { verify.Verifiable Signatures() [][secp256k1.SignatureLen]byte SignatureIndices() []uint32 }
type CrossTransferOutput ¶
type CrossTransferOutput struct { TransferOutput `serialize:"true"` // The recipient address Recipient ids.ShortID `serialize:"true" json:"recipient"` }
Used in a cross transfer, this output can be used to specify the recipient on the target chain at export time
func (*CrossTransferOutput) MarshalJSON ¶
func (out *CrossTransferOutput) MarshalJSON() ([]byte, error)
func (*CrossTransferOutput) Verify ¶
func (out *CrossTransferOutput) Verify() error
type Fx ¶
Fx describes the secp256k1 feature extension
func (*Fx) Bootstrapped ¶
func (*Fx) Bootstrapping ¶
func (*Fx) CollectMultisigAliases ¶
func (*Fx) CreateOutput ¶
CreateOutput creates a new output with the provided control group worth the specified amount
func (*Fx) Initialize ¶
func (*Fx) InitializeVM ¶
func (*Fx) IsNestedMultisig ¶
func (*Fx) RecoverAddresses ¶
func (fx *Fx) RecoverAddresses(msg []byte, verifies []verify.Verifiable) (RecoverMap, error)
func (*Fx) VerifyCredentials ¶
func (fx *Fx) VerifyCredentials(utx UnsignedTx, 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) VerifyMultisigMessage ¶
func (*Fx) VerifyMultisigOutputOwner ¶
func (*Fx) VerifyMultisigOwner ¶
func (*Fx) VerifyMultisigPermission ¶
func (*Fx) VerifyMultisigTransfer ¶
func (*Fx) VerifyOperation ¶
func (*Fx) VerifyPermission ¶
VerifyPermission returns nil iff [credIntf] proves that [controlGroup] assents to [txIntf]
func (*Fx) VerifySpend ¶
func (fx *Fx) VerifySpend(utx UnsignedTx, in *TransferInput, cred *Credential, utxo *TransferOutput) error
VerifySpend ensures that the utxo can be sent to any address
func (*Fx) VerifyTransfer ¶
type Input ¶
type Input struct { // This input consumes an output, which has an owner list. // This input will be spent with a list of signatures. // SignatureList[i] is the signature of OwnerList[i] SigIndices []uint32 `serialize:"true" json:"signatureIndices"` }
type Keychain ¶
type Keychain struct { // These can be used to iterate over. However, they should not be modified externally. Addrs set.Set[ids.ShortID] Keys []*secp256k1.PrivateKey // contains filtered or unexported fields }
Keychain is a collection of keys that can be used to spend outputs
func NewKeychain ¶
func NewKeychain(keys ...*secp256k1.PrivateKey) *Keychain
NewKeychain returns a new keychain containing [keys]
func (*Keychain) Add ¶
func (kc *Keychain) Add(key *secp256k1.PrivateKey)
Add a new key to the key chain
func (Keychain) Get ¶
Get a key from the keychain. If the key is unknown, return a pointer to an empty key. In both cases also return a boolean telling whether the key is known.
func (*Keychain) Match ¶
func (kc *Keychain) Match(owners *OutputOwners, time uint64) ([]uint32, []*secp256k1.PrivateKey, bool)
Match attempts to match a list of addresses up to the provided threshold
func (*Keychain) New ¶
func (kc *Keychain) New() (*secp256k1.PrivateKey, error)
New returns a newly generated private key
func (*Keychain) PrefixedString ¶
PrefixedString returns the key chain as a string representation with [prefix] added before every line.
func (*Keychain) Spend ¶
func (kc *Keychain) Spend(out verify.Verifiable, time uint64) (verify.Verifiable, []*secp256k1.PrivateKey, error)
Spend attempts to create an input
func (*Keychain) SpendMultiSig ¶
func (kc *Keychain) SpendMultiSig( out verify.Verifiable, time uint64, msigIntf interface{}, ) ( verify.Verifiable, []*secp256k1.PrivateKey, error, )
SpendMultisig attempts to create an input from outputowners which can contain multisig aliases Multisig alias are resolved into addresses and the sigIdxs returned are counted global. Multisig occurrences itself do not count in any way in sigIdxs, only addresses do.
type MintOperation ¶
type MintOperation struct { MintInput Input `serialize:"true" json:"mintInput"` MintOutput MintOutput `serialize:"true" json:"mintOutput"` TransferOutput TransferOutput `serialize:"true" json:"transferOutput"` }
func (*MintOperation) Cost ¶
func (op *MintOperation) Cost() (uint64, error)
func (*MintOperation) InitCtx ¶
func (op *MintOperation) InitCtx(ctx *snow.Context)
func (*MintOperation) Outs ¶
func (op *MintOperation) Outs() []verify.State
func (*MintOperation) Verify ¶
func (op *MintOperation) Verify() error
type MintOutput ¶
type MintOutput struct {
OutputOwners `serialize:"true"`
}
func (*MintOutput) Verify ¶
func (out *MintOutput) Verify() error
func (*MintOutput) VerifyState ¶
func (out *MintOutput) VerifyState() error
type MockAliasGetter ¶
type MockAliasGetter struct {
// contains filtered or unexported fields
}
MockAliasGetter is a mock of AliasGetter interface.
func NewMockAliasGetter ¶
func NewMockAliasGetter(ctrl *gomock.Controller) *MockAliasGetter
NewMockAliasGetter creates a new mock instance.
func (*MockAliasGetter) EXPECT ¶
func (m *MockAliasGetter) EXPECT() *MockAliasGetterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockAliasGetter) GetMultisigAlias ¶
func (m *MockAliasGetter) GetMultisigAlias(arg0 ids.ShortID) (*multisig.AliasWithNonce, error)
GetMultisigAlias mocks base method.
type MockAliasGetterMockRecorder ¶
type MockAliasGetterMockRecorder struct {
// contains filtered or unexported fields
}
MockAliasGetterMockRecorder is the mock recorder for MockAliasGetter.
func (*MockAliasGetterMockRecorder) GetMultisigAlias ¶
func (mr *MockAliasGetterMockRecorder) GetMultisigAlias(arg0 interface{}) *gomock.Call
GetMultisigAlias indicates an expected call of GetMultisigAlias.
type MultisigCredential ¶
type MultisigCredential struct { Credential `serialize:"true"` // Overwrites sigIdx in inputs of a tx // Must be same length as sigIdx in input SigIdxs []uint32 `serialize:"true"` }
func (*MultisigCredential) MarshalJSON ¶
func (mcr *MultisigCredential) MarshalJSON() ([]byte, error)
MarshalJSON marshals [cr] to JSON The string representation of each signature is created using the hex formatter
func (*MultisigCredential) SignatureIndices ¶
func (mcr *MultisigCredential) SignatureIndices() []uint32
func (*MultisigCredential) Verify ¶
func (mcr *MultisigCredential) Verify() error
type OutputOwners ¶
type OutputOwners struct { Locktime uint64 `serialize:"true" json:"locktime"` Threshold uint32 `serialize:"true" json:"threshold"` Addrs []ids.ShortID `serialize:"true" json:"addresses"` // contains filtered or unexported fields }
func (*OutputOwners) Addresses ¶
func (out *OutputOwners) Addresses() [][]byte
Addresses returns the addresses that manage this output
func (*OutputOwners) AddressesSet ¶
func (out *OutputOwners) AddressesSet() set.Set[ids.ShortID]
AddressesSet returns addresses as a set
func (*OutputOwners) Equals ¶
func (out *OutputOwners) Equals(other *OutputOwners) bool
Equals returns true if the provided owners create the same condition
func (*OutputOwners) Fields ¶
func (out *OutputOwners) Fields() (map[string]interface{}, error)
Fields returns JSON keys in a map that can be used with marshal JSON to serialise OutputOwners struct
func (*OutputOwners) InitCtx ¶
func (out *OutputOwners) InitCtx(ctx *snow.Context)
InitCtx assigns the OutputOwners.ctx object to given [ctx] object Must be called at least once for MarshalJSON to work successfully
func (*OutputOwners) IsZero ¶
func (out *OutputOwners) IsZero() bool
func (*OutputOwners) MarshalJSON ¶
func (out *OutputOwners) MarshalJSON() ([]byte, error)
MarshalJSON marshals OutputOwners as JSON with human readable addresses. OutputOwners.InitCtx must be called before marshalling this or one of the parent objects to json. Uses the OutputOwners.ctx method to format the addresses. Returns errMarshal error if OutputOwners.ctx is not set.
func (*OutputOwners) Sort ¶
func (out *OutputOwners) Sort()
func (*OutputOwners) Verify ¶
func (out *OutputOwners) Verify() error
func (*OutputOwners) VerifyState ¶
func (out *OutputOwners) VerifyState() error
type RecoverMap ¶
type RecoverMap map[ids.ShortID][secp256k1.SignatureLen]byte
type TransferInput ¶
func (*TransferInput) Amount ¶
func (in *TransferInput) Amount() uint64
Amount returns the quantity of the asset this input produces
func (*TransferInput) Equal ¶
func (in *TransferInput) Equal(to any) bool
Used in vms/platformvm/txs/executor/camino_tx_executor.go func inputsAreEqual
func (*TransferInput) InitCtx ¶
func (*TransferInput) InitCtx(*snow.Context)
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"` OutputOwners `serialize:"true"` }
func (*TransferOutput) Amount ¶
func (out *TransferOutput) Amount() uint64
Amount returns the quantity of the asset this output consumes
func (*TransferOutput) Equal ¶
func (out *TransferOutput) Equal(to any) bool
Used in vms/platformvm/txs/executor/camino_tx_executor.go func outputsAreEqual
func (*TransferOutput) MarshalJSON ¶
func (out *TransferOutput) MarshalJSON() ([]byte, error)
MarshalJSON marshals Amt and the embedded OutputOwners struct into a JSON readable format If OutputOwners cannot be serialized then this will return error
func (*TransferOutput) Owners ¶
func (out *TransferOutput) Owners() interface{}
func (*TransferOutput) Verify ¶
func (out *TransferOutput) Verify() error
func (*TransferOutput) VerifyState ¶
func (out *TransferOutput) VerifyState() error
type TransferOutputIntf ¶
type TransferOutputIntf interface { verify.Verifiable Amount() uint64 Owners() interface{} }
type TraverseAliasFunc ¶
type TraverseAliasFunc func( alias *multisig.AliasWithNonce, )
type TraverseOwnerFunc ¶
type UnsignedTx ¶
type UnsignedTx interface {
Bytes() []byte
}
UnsignedTx that this Fx is supporting