Documentation
¶
Overview ¶
Package wire is the cross-VM ZAP-native wire format for the fxs (feature-extension) primitives shared by P-chain (platformvm) and X-chain (xvm). It replaces the legacy luxfi/codec.Manager registry with a (TypeKind, ShapeKind) discriminator pair on every primitive's wire envelope.
Activation: 2025-12-25T16:20:00-08:00 (LP-023). New final Lux network. No backwards compatibility — legacy codec-encoded fxs primitives on the wire are a protocol-violation reject after activation.
Wire envelope per primitive: [TypeKind:1][ShapeKind:1][ZAP message: N].
The TypeKind byte names the fx family (secp256k1fx, mldsafx, ...) and the ShapeKind byte names the primitive shape within that family (TransferOutput, TransferInput, MintOutput, MintOperation, Credential, AttestationOutput, AttestationInput, OutputOwners). The remaining bytes are a ZAP message describing the shape's fields.
This is decomposed from the legacy codec.Manager slot map (which braided "is this an Output? is this an Input? which fx?" into a single dense uint32 slot id). TypeKind + ShapeKind separates the two values cleanly — composition over inheritance.
Index ¶
- Constants
- Variables
- func NewAttestationInput(in AttestationInputInput) []byte
- func NewAttestationOutput(in AttestationOutputInput) []byte
- func NewCredential(in CredentialInput) []byte
- func NewLockedOutput(in LockedOutputInput) []byte
- func NewMintOperation(in MintOperationInput) []byte
- func NewMintOutput(in MintOutputInput) []byte
- func NewOutputOwners(in OutputOwnersInput) []byte
- func NewPChainOwner(in PChainOwnerInput) []byte
- func NewPQMintOutput(in PQMintOutputInput) []byte
- func NewPQOutputOwners(in PQOutputOwnersInput) []byte
- func NewPQTransferOutput(in PQTransferOutputInput) []byte
- func NewSignedTx(in SignedTxInput) []byte
- func NewTransferInput(in TransferInputInput) []byte
- func NewTransferOutput(in TransferOutputInput) []byte
- func NewUTXO(in UTXOInput) []byte
- func PeekDiscriminator(b []byte) (TypeKind, ShapeKind, error)
- func SignSecp256k1(unsignedBytes []byte, signers [][]*secp256k1.PrivateKey) ([]byte, error)
- type AddressList
- type AttestationInput
- type AttestationInputInput
- type AttestationOutput
- type AttestationOutputInput
- type Credential
- func (c Credential) IsZero() bool
- func (c Credential) PubKeyBytes() []byte
- func (c Credential) SecurityLevel() uint8
- func (c Credential) SignatureAt(i, sigSize int) []byte
- func (c Credential) SignatureBytes() []byte
- func (c Credential) SignatureCount(sigSize int) int
- func (c Credential) TypeKind() TypeKind
- type CredentialInput
- type LockedOutput
- type LockedOutputInput
- type MintOperation
- type MintOperationInput
- type MintOutput
- type MintOutputInput
- type OutputOwners
- type OutputOwnersInput
- type PChainOwner
- type PChainOwnerInput
- type PQMintOutput
- func (m PQMintOutput) IsZero() bool
- func (m PQMintOutput) Locktime() uint64
- func (m PQMintOutput) PubKeyStride() int
- func (m PQMintOutput) PubKeys() PQPubKeyList
- func (m PQMintOutput) SecurityLevel() uint8
- func (m PQMintOutput) SyntacticVerify() error
- func (m PQMintOutput) Threshold() uint32
- func (m PQMintOutput) TypeKind() TypeKind
- type PQMintOutputInput
- type PQOutputOwners
- func (o PQOutputOwners) IsZero() bool
- func (o PQOutputOwners) Locktime() uint64
- func (o PQOutputOwners) PubKeyStride() int
- func (o PQOutputOwners) PubKeys() PQPubKeyList
- func (o PQOutputOwners) SecurityLevel() uint8
- func (o PQOutputOwners) SyntacticVerify() error
- func (o PQOutputOwners) Threshold() uint32
- func (o PQOutputOwners) TypeKind() TypeKind
- type PQOutputOwnersInput
- type PQPubKeyList
- type PQTransferOutput
- func (t PQTransferOutput) Amount() uint64
- func (t PQTransferOutput) IsZero() bool
- func (t PQTransferOutput) Locktime() uint64
- func (t PQTransferOutput) PubKeyStride() int
- func (t PQTransferOutput) PubKeys() PQPubKeyList
- func (t PQTransferOutput) SecurityLevel() uint8
- func (t PQTransferOutput) SyntacticVerify() error
- func (t PQTransferOutput) Threshold() uint32
- func (t PQTransferOutput) TypeKind() TypeKind
- type PQTransferOutputInput
- type ShapeKind
- type SignedTx
- type SignedTxInput
- type TransferInput
- type TransferInputInput
- type TransferOutput
- func (t TransferOutput) AddressList() AddressList
- func (t TransferOutput) Amount() uint64
- func (t TransferOutput) IsZero() bool
- func (t TransferOutput) Locktime() uint64
- func (t TransferOutput) SyntacticVerify() error
- func (t TransferOutput) Threshold() uint32
- func (t TransferOutput) TypeKind() TypeKind
- type TransferOutputInput
- type TypeKind
- type UTXO
- type UTXOInput
Constants ¶
const ( BLS12381PubKeyLen = 48 BLS12381AggSigLen = 96 BLS12381AttestedHashLen = 32 )
BLS12381 attestation primitives. The bls12381fx is divergent from the classical / PQ pattern — it is attestation-only (no Mint primitives, no transfer-value semantics). The output records "this 32-byte commitment was attested to by the listed BLS public keys at the listed threshold". The input is a signer-bitmap selecting which committee members contributed.
BLS12381 sizes:
- PubKeyLen = 48 (compressed G1)
- AggSigLen = 96 (compressed G2)
- AttestedHashLen = 32
const ( OffsetAttestationOutput_AttestedHash = 0 // 32B OffsetAttestationOutput_Threshold = 32 // uint32 OffsetAttestationOutput_PubKeyList = 40 // list (8 bytes) SizeAttestationOutput = 48 )
AttestationOutput is the cross-fx ZAP schema for the bls12381fx AttestationOutput.
Fixed-section layout (size 48 bytes):
AttestedHash 32B @ 0 Threshold uint32 @ 32 _padding 4B @ 36 (reserved-zero, 8-aligned) PubKeyList list @ 40 (8 bytes; payload is stride-48 G1 pubkeys)
Wire prefix: TypeKind=0x07 (BLS12381), ShapeKind=0x07 (AttestationOutput).
const ( OffsetAttestationInput_SignerBitmap = 0 // bytes (8 bytes) SizeAttestationInput = 8 )
AttestationInput is the cross-fx ZAP schema for the bls12381fx AttestationInput.
Fixed-section layout (size 8 bytes):
SignerBitmap bytes @ 0 (8 bytes — relOffset + length)
The signer bitmap is a packed bit array where bit i (LSB of byte i/8) indicates that PubKeys[i] of the spent AttestationOutput contributed to the aggregate signature.
Wire prefix: TypeKind=0x07 (BLS12381), ShapeKind=0x08 (AttestationInput).
const ( OffsetCredential_SecurityLevel = 0 // uint8 OffsetCredential_SignatureList = 4 // list (8 bytes) OffsetCredential_PubKeyList = 12 SizeCredential = 20 )
Credential is the cross-fx ZAP schema for fxs signature credentials.
Classical fx credentials (secp256k1fx, schnorrfx) carry only signatures (the pubkey is recoverable from the sig or implicit from the spent output's address list). Modern fx credentials (ed25519fx, secp256r1fx) carry pubkeys alongside signatures because those schemes are not pubkey-recoverable from a single signature. Post-quantum credentials (mldsafx, slhdsafx) carry a SecurityLevel byte selecting the parameter set, then variable-length signatures.
Fixed-section layout (size 12 bytes):
SecurityLevel uint8 @ 0 (0=L1, 1=L2, 2=L3, ... — fx-specific; 0 for classical) _padding 3B @ 1 (reserved-zero for 4-byte alignment) SignatureList list @ 4 (8 bytes; payload is concatenated signature blobs)
Wire prefix: TypeKind names the fx; ShapeKind is ShapeKindCredential (0x06). The SignatureList payload is a stride-N byte run where N is the per-fx signature size (e.g. 65 for secp256k1, 64 for Ed25519/Schnorr, 3309 for ML-DSA-65). Length field counts CONCATENATED BYTES, not number of signatures — divide by per-fx stride to recover sig count.
PubKeys (when an fx ships them on the wire alongside sigs) live in a trailing PubKeyList field; classical and PQ fxs leave it empty.
const ( OffsetLockedOutput_Locktime = 0 // uint64 OffsetLockedOutput_TransferOutBytes = 8 // bytes (8 bytes) SizeLockedOutput = 16 )
LockedOutput is the cross-fx ZAP schema for stakeable-locked outputs (the platformvm/stakeable.LockOut primitive). Carries a Locktime and an inner TransferableOut wire envelope (any fx's TransferOutput). Operationally: an output that cannot be spent until block.Timestamp >= Locktime, wrapping any fx's transfer output.
Fixed-section layout (size 16 bytes):
Locktime uint64 @ 0 (8 bytes — unlock unix time) TransferOutBytes bytes @ 8 (8 bytes — inner wire envelope)
Wire prefix: TypeKind is TypeKindReserved (lock is fx-agnostic; inner envelope carries its own fx TypeKind). ShapeKind is ShapeKindLockedOutput (0x0F). The inner TransferOutBytes carries its own discriminator pair — consumers dispatch via WrapTransferOutput or the fx-specific wrap.
const ( OffsetMintOperation_SigIndicesList = 0 // list (8 bytes) OffsetMintOperation_MintOutputBytes = 8 // bytes (8 bytes) OffsetMintOperation_TransferOutputBytes = 16 // bytes (8 bytes) SizeMintOperation = 24 )
MintOperation is the cross-fx ZAP schema for the MintOperation primitive (Input { SigIndices } + MintOutput + TransferOutput). Operationally: an asset-minting authority (the MintInput's SigIndices) produces a new TransferOutput (value) and updates/re-confirms the MintOutput (mint authority continuation).
Fixed-section layout (size 24 bytes):
SigIndicesList list @ 0 (8 bytes — for the mint authority signatures) MintOutputBytes bytes @ 8 (8 bytes — wire envelope of MintOutput) TransferOutputBytes bytes @ 16 (8 bytes — wire envelope of TransferOutput)
Wire prefix: TypeKind names the fx; ShapeKind is ShapeKindMintOperation (0x05). The inner MintOutputBytes and TransferOutputBytes carry their own discriminator pairs — consumers dispatch via WrapMintOutput / WrapTransferOutput.
const ( OffsetMintOutput_Locktime = OffsetOutputOwners_Locktime // 0 OffsetMintOutput_Threshold = OffsetOutputOwners_Threshold // 8 OffsetMintOutput_AddressList = OffsetOutputOwners_AddressList // 12 SizeMintOutput = SizeOutputOwners // 20 )
MintOutput is the cross-fx ZAP schema for the MintOutput primitive (`OutputOwners`). Same shape as OutputOwners — MintOutput identifies a mint-authority owner group, not a value-bearing output.
Fixed-section layout (size 20 bytes; identical to OutputOwners):
Locktime uint64 @ 0 Threshold uint32 @ 8 AddressList list @ 12 (4-byte relOffset + 4-byte length, 8 bytes)
Wire prefix: TypeKind names the fx; ShapeKind is ShapeKindMintOutput (0x03). Same payload bytes as a TransferOutput owner section — only the ShapeKind discriminator distinguishes "mint authority" from "spending output".
const ( OffsetOutputOwners_Locktime = 0 // uint64 OffsetOutputOwners_Threshold = 8 // uint32 OffsetOutputOwners_AddressList = 12 // list (8 bytes) SizeOutputOwners = 20 )
OutputOwners is the cross-VM ZAP schema for github.com/luxfi/utxo/secp256k1fx.OutputOwners. Carries a Locktime, a signature-threshold count, and a variable-length list of 20-byte addresses (the addresses that may co-sign to spend an output owned by this group).
Fixed-section layout (size 20 bytes; uint64 reads alignment-tolerant):
Locktime uint64 @ 0 Threshold uint32 @ 8 AddressList list @ 12 (4-byte relOffset + 4-byte length, 8 bytes)
Total fixed section = 20 bytes. AddressList payload is stride-20 in the variable section.
Semantically equivalent to message.PChainOwner when Locktime=0; the PChainOwner wire envelope uses ShapeKindPChainOwner and skips the Locktime field entirely (see WrapPChainOwner below).
const ( OffsetPChainOwner_Threshold = 0 // uint32 OffsetPChainOwner_AddressList = 4 // list (8 bytes) SizePChainOwner = 12 )
PChainOwner is the cross-VM ZAP schema for github.com/luxfi/node/vms/platformvm/warp/message.PChainOwner. Strict subset of OutputOwners: Threshold + Addresses, no Locktime.
Used in warp validator registration where locktime is not a meaningful gate (validator weight changes happen at known points in the permissionless validator pipeline).
Fixed-section layout (size 12 bytes):
Threshold uint32 @ 0 AddressList list @ 4 (4-byte relOffset + 4-byte length, 8 bytes)
Total fixed section = 12 bytes.
const ( OffsetPQMintOutput_SecurityLevel = OffsetPQOutputOwners_SecurityLevel // 0 OffsetPQMintOutput_Locktime = OffsetPQOutputOwners_Locktime // 8 OffsetPQMintOutput_Threshold = OffsetPQOutputOwners_Threshold // 16 OffsetPQMintOutput_PubKeyList = OffsetPQOutputOwners_PubKeyList // 24 SizePQMintOutput = SizePQOutputOwners // 32 )
PQMintOutput is the cross-PQ-fx ZAP schema for the MintOutput primitive carrying variable-length PQ pubkeys (mldsafx, slhdsafx).
Same payload as PQOutputOwners — MintOutput identifies a mint-authority owner group, not a value-bearing output. Only the ShapeKind discriminator distinguishes "mint authority" from "spending owner".
const ( OffsetPQOutputOwners_SecurityLevel = 0 // uint8 OffsetPQOutputOwners_Locktime = 8 // uint64 OffsetPQOutputOwners_Threshold = 16 // uint32 OffsetPQOutputOwners_PubKeyList = 24 // list (8 bytes) SizePQOutputOwners = 32 )
PQOutputOwners is the cross-PQ-fx ZAP schema for fx-specific OutputOwners that carry FULL post-quantum public keys (not the 20-byte hashed ShortIDs used by classical fxs). Both mldsafx and slhdsafx are pubkey-on-chain (no hash address derivation in the owner set), so they need a wire schema that varies the pubkey stride by the SecurityLevel byte.
Fixed-section layout (size 28 bytes; uint64 alignment-tolerant):
SecurityLevel uint8 @ 0
_padding 7B @ 1 (reserved-zero, 8-aligned)
Locktime uint64 @ 8
Threshold uint32 @ 16
_padding 4B @ 20 (reserved-zero, 8-aligned)
PubKeyList list @ 24 (8 bytes; payload stride is fx-specific —
mldsafx: 1312/1952/2592, slhdsafx: 32/48/64)
Wire prefix: TypeKind names the fx (mldsafx, slhdsafx); ShapeKind is ShapeKindPQOutputOwners (0x0F).
const ( OffsetPQTransferOutput_SecurityLevel = 0 // uint8 OffsetPQTransferOutput_Amount = 8 // uint64 OffsetPQTransferOutput_Locktime = 16 // uint64 OffsetPQTransferOutput_Threshold = 24 // uint32 OffsetPQTransferOutput_PubKeyList = 32 // list (8 bytes) SizePQTransferOutput = 40 )
PQTransferOutput is the cross-PQ-fx ZAP schema for the TransferOutput primitive carrying variable-length PQ pubkeys (mldsafx, slhdsafx).
Fixed-section layout (size 40 bytes; uint64 alignment-tolerant):
SecurityLevel uint8 @ 0 _padding 7B @ 1 (reserved-zero, 8-aligned) Amount uint64 @ 8 Locktime uint64 @ 16 Threshold uint32 @ 24 _padding 4B @ 28 (reserved-zero, 8-aligned) PubKeyList list @ 32 (8 bytes; payload stride is fx-specific)
Wire prefix: TypeKind names the fx; ShapeKind is ShapeKindPQTransferOutput (0x10).
const ( OffsetSignedTx_UnsignedBytes = 0 // bytes (8 bytes) OffsetSignedTx_CredentialCount = 8 // uint32 (number of credentials) OffsetSignedTx_CredentialBytes = 12 // bytes (8 bytes — all credential envelopes concatenated) SizeSignedTx = 20 )
SignedTx is the ZAP-native replacement for the legacy `txs.Tx{Unsigned UnsignedTx; Creds []verify.Verifiable}` envelope used by both platformvm and xvm. It wraps:
- UnsignedBytes: the canonical wire bytes the signature was computed over
- Credentials: a list of fxs Credential wire envelopes (one per input)
The unsigned bytes already carry a TxKind discriminator at offset 0 (see vms/platformvm/txs/zap_native/kind.go). The Credentials list indices align with the UnsignedTx's input list indices (1:1 by index) just like the legacy Tx.Creds slice.
Fixed-section layout (size 16 bytes):
UnsignedBytes bytes @ 0 (8 bytes — relOffset + length)
Credentials list @ 8 (8 bytes — relOffset + length; stride is
the per-credential ENVELOPE size, variable)
Wire prefix: TypeKind=0x00 (reserved/cross-VM envelope), ShapeKind=0x0E (SignedTx).
Because credentials are variable-stride byte envelopes (each carries its own TypeKind+ShapeKind+ZAP message of independent length), the credential list is encoded as a packed sequence of length-prefixed envelopes rather than a fixed-stride ZAP list. See SignedTx.CredentialAt for the parser.
const ( OffsetTransferInput_Amount = 0 // uint64 OffsetTransferInput_SigIndicesList = 8 // list (8 bytes) SizeTransferInput = 16 )
TransferInput is the cross-fx ZAP schema for the TransferInput primitive (`Amt uint64 + SigIndices []uint32`). The semantics are uniform across classical and PQ fxs — only the matching Credential's signature size varies.
Fixed-section layout (size 16 bytes):
Amount uint64 @ 0 SigIndicesList list @ 8 (4-byte relOffset + 4-byte length, 8 bytes)
SigIndicesList payload is stride-4 (each entry is a uint32).
Wire prefix discriminator: TypeKind names the fx; ShapeKind is ShapeKindTransferInput (0x02).
const ( OffsetTransferOutput_Amount = 0 // uint64 OffsetTransferOutput_Locktime = 8 // uint64 OffsetTransferOutput_Threshold = 16 // uint32 OffsetTransferOutput_AddressList = 20 // list (8 bytes) SizeTransferOutput = 28 )
TransferOutput is the cross-fx ZAP schema for the TransferOutput primitive (`Amt uint64 + OutputOwners`). Every classical fx (secp256k1fx, ed25519fx, secp256r1fx, schnorrfx) and post-quantum fx (mldsafx, slhdsafx) use this same shape — they differ only in the Credential's signature size, not in the spending-output layout.
Fixed-section layout (size 28 bytes; uint64 reads alignment-tolerant):
Amount uint64 @ 0 Locktime uint64 @ 8 Threshold uint32 @ 16 AddressList list @ 20 (4-byte relOffset + 4-byte length, 8 bytes)
Total fixed section = 28 bytes. The TypeKind discriminator byte in the 2-byte wire prefix names the owning fx (e.g. 0x01=secp256k1fx, 0x02=mldsafx). The ShapeKind byte is always ShapeKindTransferOutput (0x01).
const ( OffsetUTXO_TxID = 0 OffsetUTXO_OutputIndex = 32 // uint32 OffsetUTXO_AssetID = 36 // 32B OffsetUTXO_Output = 68 // bytes (relOffset + length, 8 bytes) SizeUTXO = 76 )
UTXO is the cross-VM ZAP schema for github.com/luxfi/utxo.UTXO. Carries the spent TxID + OutputIndex (UTXOID), the asset identifier, and the concrete output payload (a fxs primitive — TransferOutput, MintOutput, AttestationOutput). The output payload is itself a wire envelope with its own (TypeKind, ShapeKind) discriminator pair, written as a bytes field in the parent UTXO message.
Fixed-section layout (size 76 bytes; uint64 reads alignment-tolerant):
TxID 32B @ 0 OutputIndex uint32 @ 32 AssetID 32B @ 36 Output bytes @ 68 (relOffset + length, 8 bytes)
Total fixed section = 32 + 4 + 32 + 8 = 76 bytes.
The Output bytes field carries the inner fxs primitive's wire envelope (2-byte discriminator prefix + ZAP message). Consumers parse it via WrapTransferableOutput / WrapMintOutput / WrapAttestationOutput, dispatching on the discriminator pair.
const AddressStride = ids.ShortIDLen
AddressStride is the per-element width of an AddressList in the OutputOwners variable section. Each address is a 20-byte ids.ShortID.
const EnvelopePrefix = 2
EnvelopePrefix is the 2-byte discriminator prefix that every fxs primitive's wire envelope begins with. The remainder of the envelope is a ZAP message describing the shape's fields.
const SigIndexStride = 4
SigIndexStride is the per-element width of the SigIndices list (one uint32 per index).
Variables ¶
var ( ErrWrongTypeKind = errors.New("wire: TypeKind discriminator does not match expected fx family") ErrWrongShapeKind = errors.New("wire: ShapeKind discriminator does not match expected primitive shape") ErrShortEnvelope = errors.New("wire: envelope shorter than 2-byte discriminator prefix") )
Errors returned by every Wrap*Primitive accessor when the discriminator pair on the wire does not match the expected (TypeKind, ShapeKind) for the function being called. This closes the cross-type confusion surface where a TransferInput buffer could be Wrap'd as a TransferOutput and return garbage-but-deterministic field reads.
var ( ErrOwnerThresholdZero = errors.New("wire: OutputOwners.Threshold must be > 0; threshold=0 disables authorization") ErrOwnerThresholdExceedsAddrs = errors.New("wire: OutputOwners.Threshold exceeds Addresses.Len() — unsatisfiable signer quorum") ErrOwnerAddrsEmpty = errors.New("wire: OutputOwners.Addresses is empty — signer set undefined") ErrOwnerAddrZero = errors.New("wire: OutputOwners.Addresses contains the zero ShortID — phantom signer") )
Semantic-verification errors. The wire layer (ZAP) is permissive by design — semantic gates live here. Mirrors the zap_native/owner.go Owner.SyntacticVerify error set so cross-VM consumers see a single canonical error set.
var ( ErrPQOwnerPubKeysEmpty = errors.New("wire: PQOutputOwners.PubKeys is empty — signer set undefined") ErrPQOwnerThresholdZero = errors.New("wire: PQOutputOwners.Threshold must be > 0; threshold=0 disables authorization") ErrPQOwnerThresholdExceeds = errors.New("wire: PQOutputOwners.Threshold exceeds PubKeys.Len() — unsatisfiable signer quorum") ErrPQOwnerPubKeyWrongStride = errors.New("wire: PQOutputOwners.PubKeys entry does not match SecurityLevel's pubkey stride") ErrPQOwnerPubKeysNotSortedUq = errors.New("wire: PQOutputOwners.PubKeys not sorted lexicographically and unique") ErrPQAmountZero = errors.New("wire: PQTransferOutput.Amount must be > 0; zero-value transfers are not permitted") )
Semantic-verification errors for PQ owners.
Functions ¶
func NewAttestationInput ¶
func NewAttestationInput(in AttestationInputInput) []byte
NewAttestationInput builds an AttestationInput wire envelope.
func NewAttestationOutput ¶
func NewAttestationOutput(in AttestationOutputInput) []byte
NewAttestationOutput builds an AttestationOutput wire envelope.
func NewCredential ¶
func NewCredential(in CredentialInput) []byte
NewCredential builds a Credential wire envelope.
func NewLockedOutput ¶ added in v0.3.6
func NewLockedOutput(in LockedOutputInput) []byte
NewLockedOutput builds a LockedOutput wire envelope.
func NewMintOperation ¶
func NewMintOperation(in MintOperationInput) []byte
NewMintOperation builds a MintOperation wire envelope.
func NewMintOutput ¶
func NewMintOutput(in MintOutputInput) []byte
NewMintOutput builds a MintOutput wire envelope.
func NewOutputOwners ¶
func NewOutputOwners(in OutputOwnersInput) []byte
NewOutputOwners builds an OutputOwners wire envelope.
func NewPChainOwner ¶
func NewPChainOwner(in PChainOwnerInput) []byte
NewPChainOwner builds a PChainOwner wire envelope.
func NewPQMintOutput ¶
func NewPQMintOutput(in PQMintOutputInput) []byte
NewPQMintOutput builds a PQMintOutput wire envelope.
func NewPQOutputOwners ¶
func NewPQOutputOwners(in PQOutputOwnersInput) []byte
NewPQOutputOwners builds a PQOutputOwners wire envelope.
func NewPQTransferOutput ¶
func NewPQTransferOutput(in PQTransferOutputInput) []byte
NewPQTransferOutput builds a PQTransferOutput wire envelope.
func NewSignedTx ¶
func NewSignedTx(in SignedTxInput) []byte
NewSignedTx builds a SignedTx wire envelope. The unsigned bytes are stored verbatim, and the credentials slice is concatenated into a single byte run — the per-credential ZAP header carries each envelope's length so the parser can walk them.
func NewTransferInput ¶
func NewTransferInput(in TransferInputInput) []byte
NewTransferInput builds a TransferInput wire envelope.
func NewTransferOutput ¶
func NewTransferOutput(in TransferOutputInput) []byte
NewTransferOutput builds a TransferOutput wire envelope.
func NewUTXO ¶
NewUTXO builds a UTXO wire envelope (2-byte discriminator prefix + ZAP message) from the input fields. The returned slice is the canonical on-wire representation.
func PeekDiscriminator ¶ added in v0.3.7
PeekDiscriminator returns the (TypeKind, ShapeKind) of a wire envelope without consuming the ZAP body. Used by composite-shape dispatchers (e.g. LockedOutput) that need to recurse on an inner envelope's discriminator without committing to a Wrap*. Returns ErrShortEnvelope when the buffer is shorter than the 2-byte prefix.
func SignSecp256k1 ¶
func SignSecp256k1(unsignedBytes []byte, signers [][]*secp256k1.PrivateKey) ([]byte, error)
SignSecp256k1 is the ZAP-native replacement for the legacy `txs.Tx.Sign(c codec.Manager, ...)` method. It takes the unsigned tx bytes (already ZAP-encoded by the txs.zap_native build path) plus a list of signer groups (one group per input, like the legacy API), and returns a fully-formed SignedTx wire envelope.
The signing target is hash(unsignedBytes) — same as the legacy Sign. Each signer group produces one Credential whose Signatures field is the concatenation of all per-key secp256k1 signatures.
This is the canonical secp256k1fx signing entry point. For multi-fx signing (mixing secp256k1 + ML-DSA + Ed25519 credentials), build the per-input credentials individually with NewCredential and pass them directly to NewSignedTx.
Returns:
- signedTxBytes: the canonical wire envelope (SignedTx{unsigned, creds})
- err: a typed error from secp256k1.PrivateKey.SignHash on failure
Types ¶
type AddressList ¶
type AddressList struct {
// contains filtered or unexported fields
}
AddressList is the zero-copy view over the address list inside an OutputOwners. Stride is 20 bytes (ids.ShortIDLen).
func (AddressList) All ¶
func (a AddressList) All() []ids.ShortID
All returns a fresh []ShortID copy of every address in the list.
func (AddressList) At ¶
func (a AddressList) At(i int) ids.ShortID
At returns the i'th address. Returns the zero ShortID when out of range.
CONSUMER SAFETY (RED-HIGH-3): when i >= the actual entry count (a malicious encoder published a length-padded list), this returns the zero ShortID which is a phantom signer. Always call OutputOwners.SyntacticVerify() before iterating.
func (AddressList) IsNull ¶
func (a AddressList) IsNull() bool
IsNull returns true if no list pointer was set.
type AttestationInput ¶
type AttestationInput struct {
// contains filtered or unexported fields
}
AttestationInput is the zero-copy typed accessor.
func WrapAttestationInput ¶
func WrapAttestationInput(b []byte) (AttestationInput, error)
WrapAttestationInput parses an AttestationInput wire envelope.
func (AttestationInput) IsZero ¶
func (a AttestationInput) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (AttestationInput) SignerBitmap ¶
func (a AttestationInput) SignerBitmap() []byte
SignerBitmap returns the signer-selection bitmap.
READ-ONLY: aliases the underlying buffer.
type AttestationInputInput ¶
type AttestationInputInput struct {
SignerBitmap []byte
}
AttestationInputInput is the constructor input.
type AttestationOutput ¶
type AttestationOutput struct {
// contains filtered or unexported fields
}
AttestationOutput is the zero-copy typed accessor.
func WrapAttestationOutput ¶
func WrapAttestationOutput(b []byte) (AttestationOutput, error)
WrapAttestationOutput parses an AttestationOutput wire envelope.
func (AttestationOutput) AttestedHash ¶
func (a AttestationOutput) AttestedHash() [BLS12381AttestedHashLen]byte
AttestedHash returns the 32-byte commitment.
func (AttestationOutput) IsZero ¶
func (a AttestationOutput) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (AttestationOutput) PubKeys ¶
func (a AttestationOutput) PubKeys() [][]byte
PubKeys returns the committee pubkeys as a fresh [][]byte slice (each inner []byte is BLS12381PubKeyLen = 48 bytes).
func (AttestationOutput) Threshold ¶
func (a AttestationOutput) Threshold() uint32
Threshold returns the minimum number of pubkeys required.
type AttestationOutputInput ¶
type AttestationOutputInput struct {
AttestedHash [BLS12381AttestedHashLen]byte
Threshold uint32
// PubKeys MUST each be BLS12381PubKeyLen bytes; the constructor does
// not pad or truncate. Sort lexicographically before passing in —
// AttestationOutput.Verify requires sorted-unique pubkeys.
PubKeys [][]byte
}
AttestationOutputInput is the constructor input.
type Credential ¶
type Credential struct {
// contains filtered or unexported fields
}
Credential is the zero-copy typed accessor.
func WrapCredential ¶
func WrapCredential(b []byte) (Credential, error)
WrapCredential parses a Credential wire envelope.
func (Credential) IsZero ¶
func (c Credential) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (Credential) PubKeyBytes ¶
func (c Credential) PubKeyBytes() []byte
PubKeyBytes returns the concatenated pubkey blob, for fxs that ship pubkeys on the wire (Ed25519, secp256r1, Schnorr). Classical (secp256k1) and PQ (ML-DSA, SLH-DSA) leave this empty.
func (Credential) SecurityLevel ¶
func (c Credential) SecurityLevel() uint8
SecurityLevel returns the fx-specific security level byte. 0 for classical fxs; (0,1,2) for ML-DSA (-44/-65/-87) and SLH-DSA variants.
func (Credential) SignatureAt ¶
func (c Credential) SignatureAt(i, sigSize int) []byte
SignatureAt returns the i'th signature, given the per-fx signature size. Returns nil when i is out of range or sigSize doesn't divide cleanly.
func (Credential) SignatureBytes ¶
func (c Credential) SignatureBytes() []byte
SignatureBytes returns the concatenated signature blob as a single fresh []byte. Divide len()/sigSize to get the signature count.
READ-ONLY: aliases the underlying buffer when used via the List accessor. The returned slice is a copy.
func (Credential) SignatureCount ¶
func (c Credential) SignatureCount(sigSize int) int
SignatureCount returns the number of signatures, given the per-fx signature size. Returns 0 if sigSize is 0 or the total bytes don't divide cleanly.
func (Credential) TypeKind ¶
func (c Credential) TypeKind() TypeKind
TypeKind returns the fx family of this credential.
type CredentialInput ¶
type CredentialInput struct {
TypeKind TypeKind
SecurityLevel uint8
// Signatures is the concatenated signature blob: e.g. 2 secp256k1
// signatures = 2*65 = 130 bytes.
Signatures []byte
// PubKeys is the concatenated pubkey blob (empty for classical fxs
// and ML-DSA/SLH-DSA).
PubKeys []byte
}
CredentialInput is the constructor input. Signatures and PubKeys MUST already be concatenated by the caller — the constructor does not split or pad. For classical fxs, PubKeys should be nil.
type LockedOutput ¶ added in v0.3.6
type LockedOutput struct {
// contains filtered or unexported fields
}
LockedOutput is the zero-copy typed accessor.
func WrapLockedOutput ¶ added in v0.3.6
func WrapLockedOutput(b []byte) (LockedOutput, error)
WrapLockedOutput parses a LockedOutput wire envelope.
func (LockedOutput) IsZero ¶ added in v0.3.6
func (l LockedOutput) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (LockedOutput) Locktime ¶ added in v0.3.6
func (l LockedOutput) Locktime() uint64
Locktime returns the unix timestamp before which the inner output cannot be spent.
func (LockedOutput) TransferOutBytes ¶ added in v0.3.6
func (l LockedOutput) TransferOutBytes() []byte
TransferOutBytes returns the inner TransferableOut wire envelope. Pass to the appropriate fx's WrapTransferOutput for typed access.
READ-ONLY: aliases the underlying buffer.
type LockedOutputInput ¶ added in v0.3.6
type LockedOutputInput struct {
Locktime uint64
TransferOutBytes []byte // wire envelope from any fx's NewTransferOutput
}
LockedOutputInput is the constructor input.
type MintOperation ¶
type MintOperation struct {
// contains filtered or unexported fields
}
MintOperation is the zero-copy typed accessor.
func WrapMintOperation ¶
func WrapMintOperation(b []byte) (MintOperation, error)
WrapMintOperation parses a MintOperation wire envelope.
func (MintOperation) IsZero ¶
func (m MintOperation) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (MintOperation) MintOutputBytes ¶
func (m MintOperation) MintOutputBytes() []byte
MintOutputBytes returns the inner MintOutput wire envelope. Pass to WrapMintOutput for typed access.
READ-ONLY: aliases the underlying buffer.
func (MintOperation) SigIndices ¶
func (m MintOperation) SigIndices() []uint32
SigIndices returns the mint-authority signature indices.
func (MintOperation) TransferOutputBytes ¶
func (m MintOperation) TransferOutputBytes() []byte
TransferOutputBytes returns the inner TransferOutput wire envelope. Pass to WrapTransferOutput for typed access.
READ-ONLY: aliases the underlying buffer.
func (MintOperation) TypeKind ¶
func (m MintOperation) TypeKind() TypeKind
TypeKind returns the fx family that owns this operation.
type MintOperationInput ¶
type MintOperationInput struct {
TypeKind TypeKind
SigIndices []uint32
MintOutput []byte // wire envelope from NewMintOutput
TransferOutput []byte // wire envelope from NewTransferOutput
}
MintOperationInput is the constructor input.
type MintOutput ¶
type MintOutput struct {
// contains filtered or unexported fields
}
MintOutput is the zero-copy typed accessor.
func WrapMintOutput ¶
func WrapMintOutput(b []byte) (MintOutput, error)
WrapMintOutput parses a MintOutput wire envelope.
func (MintOutput) AddressList ¶
func (m MintOutput) AddressList() AddressList
AddressList returns the mint authority address list.
func (MintOutput) IsZero ¶
func (m MintOutput) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (MintOutput) Locktime ¶
func (m MintOutput) Locktime() uint64
Locktime returns the unix timestamp before which mint cannot fire.
func (MintOutput) SyntacticVerify ¶
func (m MintOutput) SyntacticVerify() error
SyntacticVerify enforces the same gates as OutputOwners.
func (MintOutput) Threshold ¶
func (m MintOutput) Threshold() uint32
Threshold returns the signatures-required count for mint authority.
func (MintOutput) TypeKind ¶
func (m MintOutput) TypeKind() TypeKind
TypeKind returns the fx family that owns this mint authority.
type MintOutputInput ¶
type MintOutputInput struct {
TypeKind TypeKind
Locktime uint64
Threshold uint32
Addresses []ids.ShortID
}
MintOutputInput is the constructor input.
type OutputOwners ¶
type OutputOwners struct {
// contains filtered or unexported fields
}
OutputOwners is the zero-copy typed accessor over a ZAP-encoded OutputOwners wire envelope.
READ-ONLY: each address aliases the underlying ZAP buffer.
func WrapOutputOwners ¶
func WrapOutputOwners(b []byte) (OutputOwners, error)
WrapOutputOwners parses an OutputOwners wire envelope into a typed accessor. The discriminator is (TypeKindReserved, ShapeKindOutputOwners) — owners are not fx-owned, every fx with multi-address ownership shares the same wire schema.
func (OutputOwners) AddressList ¶
func (o OutputOwners) AddressList() AddressList
AddressList returns the variable-stride address list view.
func (OutputOwners) IsZero ¶
func (o OutputOwners) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (OutputOwners) Locktime ¶
func (o OutputOwners) Locktime() uint64
Locktime returns the unix timestamp before which the output cannot be spent.
func (OutputOwners) SyntacticVerify ¶
func (o OutputOwners) SyntacticVerify() error
SyntacticVerify enforces every executor-side semantic gate on an OutputOwners read from an untrusted wire buffer:
- Addresses non-empty
- Threshold > 0
- Threshold <= len(Addresses)
- Every Address is non-zero
Returns one of the typed sentinel errors above, or nil when valid. Every consumer that treats Threshold/Addresses as a quorum gate MUST call SyntacticVerify before trusting the values.
func (OutputOwners) Threshold ¶
func (o OutputOwners) Threshold() uint32
Threshold returns the number of signatures required to spend.
type OutputOwnersInput ¶
OutputOwnersInput is the constructor input for NewOutputOwners.
type PChainOwner ¶
type PChainOwner struct {
// contains filtered or unexported fields
}
PChainOwner is the zero-copy typed accessor over a ZAP-encoded PChainOwner wire envelope.
func WrapPChainOwner ¶
func WrapPChainOwner(b []byte) (PChainOwner, error)
WrapPChainOwner parses a PChainOwner wire envelope into a typed accessor.
func (PChainOwner) AddressList ¶
func (p PChainOwner) AddressList() AddressList
AddressList returns the variable-stride address list view.
func (PChainOwner) IsZero ¶
func (p PChainOwner) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (PChainOwner) SyntacticVerify ¶
func (p PChainOwner) SyntacticVerify() error
SyntacticVerify enforces the executor-side semantic gates: non-empty addresses, non-zero threshold, threshold <= len(addresses), every address non-zero. Returns one of the OutputOwners error sentinels.
func (PChainOwner) Threshold ¶
func (p PChainOwner) Threshold() uint32
Threshold returns the signatures-required count.
type PChainOwnerInput ¶
PChainOwnerInput is the constructor input for NewPChainOwner.
type PQMintOutput ¶
type PQMintOutput struct {
// contains filtered or unexported fields
}
PQMintOutput is the zero-copy typed accessor.
func WrapPQMintOutput ¶
func WrapPQMintOutput(b []byte, stride int) (PQMintOutput, error)
WrapPQMintOutput parses a PQMintOutput wire envelope.
func (PQMintOutput) IsZero ¶
func (m PQMintOutput) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (PQMintOutput) Locktime ¶
func (m PQMintOutput) Locktime() uint64
Locktime returns the unix timestamp before which mint cannot fire.
func (PQMintOutput) PubKeyStride ¶
func (m PQMintOutput) PubKeyStride() int
PubKeyStride returns the per-element width of the PubKeys list.
func (PQMintOutput) PubKeys ¶
func (m PQMintOutput) PubKeys() PQPubKeyList
PubKeys returns the variable-stride pubkey list view.
func (PQMintOutput) SecurityLevel ¶
func (m PQMintOutput) SecurityLevel() uint8
SecurityLevel returns the fx-specific security level byte.
func (PQMintOutput) SyntacticVerify ¶
func (m PQMintOutput) SyntacticVerify() error
SyntacticVerify enforces the same gates as PQOutputOwners.
func (PQMintOutput) Threshold ¶
func (m PQMintOutput) Threshold() uint32
Threshold returns the signatures-required count for mint authority.
func (PQMintOutput) TypeKind ¶
func (m PQMintOutput) TypeKind() TypeKind
TypeKind returns the PQ fx family.
type PQMintOutputInput ¶
type PQMintOutputInput struct {
TypeKind TypeKind
SecurityLevel uint8
Locktime uint64
Threshold uint32
PubKeyStride int
PubKeys [][]byte
}
PQMintOutputInput is the constructor input.
type PQOutputOwners ¶
type PQOutputOwners struct {
// contains filtered or unexported fields
}
PQOutputOwners is the zero-copy typed accessor over a ZAP-encoded PQOutputOwners wire envelope.
READ-ONLY: each pubkey aliases the underlying ZAP buffer.
func WrapPQOutputOwners ¶
func WrapPQOutputOwners(b []byte, stride int) (PQOutputOwners, error)
WrapPQOutputOwners parses a PQOutputOwners wire envelope. The stride argument names the fx-specific pubkey size — the wire layer does not infer it from SecurityLevel because the fx-to-stride mapping lives in the fx package (mldsafx.SecurityLevel.PubKeyLen, slhdsafx.SecurityLevel.PubKeyLen).
func (PQOutputOwners) IsZero ¶
func (o PQOutputOwners) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (PQOutputOwners) Locktime ¶
func (o PQOutputOwners) Locktime() uint64
Locktime returns the unix timestamp before which the output cannot be spent.
func (PQOutputOwners) PubKeyStride ¶
func (o PQOutputOwners) PubKeyStride() int
PubKeyStride returns the per-element width of the PubKeys list, as passed to WrapPQOutputOwners. The caller is responsible for resolving SecurityLevel → stride; the wire layer is stride-agnostic.
func (PQOutputOwners) PubKeys ¶
func (o PQOutputOwners) PubKeys() PQPubKeyList
PubKeys returns the variable-stride pubkey list view.
READ-ONLY: each pubkey aliases the underlying ZAP buffer.
func (PQOutputOwners) SecurityLevel ¶
func (o PQOutputOwners) SecurityLevel() uint8
SecurityLevel returns the fx-specific security level byte.
func (PQOutputOwners) SyntacticVerify ¶
func (o PQOutputOwners) SyntacticVerify() error
SyntacticVerify enforces the executor-side semantic gates on a PQ owner set read from an untrusted wire buffer. Stride is taken from the WrapPQOutputOwners call; per-entry stride mismatches are rejected, as are zero-threshold and threshold-exceeds-pubkeys.
func (PQOutputOwners) Threshold ¶
func (o PQOutputOwners) Threshold() uint32
Threshold returns the number of signatures required to spend.
func (PQOutputOwners) TypeKind ¶
func (o PQOutputOwners) TypeKind() TypeKind
TypeKind returns the PQ fx family that owns this owner set.
type PQOutputOwnersInput ¶
type PQOutputOwnersInput struct {
TypeKind TypeKind
SecurityLevel uint8
Locktime uint64
Threshold uint32
// PubKeyStride names the per-entry width of the PubKeys list. The
// caller is responsible for the SecurityLevel → stride mapping.
PubKeyStride int
// PubKeys MUST each be exactly PubKeyStride bytes. The constructor
// does not pad or truncate.
PubKeys [][]byte
}
PQOutputOwnersInput is the constructor input for NewPQOutputOwners.
type PQPubKeyList ¶
type PQPubKeyList struct {
// contains filtered or unexported fields
}
PQPubKeyList is the zero-copy view over the pubkey list inside a PQOutputOwners. Stride is fx-specific.
func (PQPubKeyList) All ¶
func (p PQPubKeyList) All() [][]byte
All returns a fresh [][]byte copy of every pubkey in the list.
func (PQPubKeyList) At ¶
func (p PQPubKeyList) At(i int) []byte
At returns the i'th pubkey as a fresh []byte copy of length stride. Returns nil when i is out of range.
func (PQPubKeyList) IsNull ¶
func (p PQPubKeyList) IsNull() bool
IsNull returns true if no list pointer was set.
type PQTransferOutput ¶
type PQTransferOutput struct {
// contains filtered or unexported fields
}
PQTransferOutput is the zero-copy typed accessor.
func WrapPQTransferOutput ¶
func WrapPQTransferOutput(b []byte, stride int) (PQTransferOutput, error)
WrapPQTransferOutput parses a PQTransferOutput wire envelope.
func (PQTransferOutput) Amount ¶
func (t PQTransferOutput) Amount() uint64
Amount returns the asset amount this output is worth.
func (PQTransferOutput) IsZero ¶
func (t PQTransferOutput) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (PQTransferOutput) Locktime ¶
func (t PQTransferOutput) Locktime() uint64
Locktime returns the unix timestamp before which the output cannot be spent.
func (PQTransferOutput) PubKeyStride ¶
func (t PQTransferOutput) PubKeyStride() int
PubKeyStride returns the per-element width of the PubKeys list.
func (PQTransferOutput) PubKeys ¶
func (t PQTransferOutput) PubKeys() PQPubKeyList
PubKeys returns the variable-stride pubkey list view.
func (PQTransferOutput) SecurityLevel ¶
func (t PQTransferOutput) SecurityLevel() uint8
SecurityLevel returns the fx-specific security level byte.
func (PQTransferOutput) SyntacticVerify ¶
func (t PQTransferOutput) SyntacticVerify() error
SyntacticVerify enforces Amount > 0 plus the PQOutputOwners gates.
func (PQTransferOutput) Threshold ¶
func (t PQTransferOutput) Threshold() uint32
Threshold returns the signatures-required count.
func (PQTransferOutput) TypeKind ¶
func (t PQTransferOutput) TypeKind() TypeKind
TypeKind returns the PQ fx family.
type PQTransferOutputInput ¶
type PQTransferOutputInput struct {
TypeKind TypeKind
SecurityLevel uint8
Amount uint64
Locktime uint64
Threshold uint32
PubKeyStride int
PubKeys [][]byte
}
PQTransferOutputInput is the constructor input.
type ShapeKind ¶
type ShapeKind uint8
ShapeKind names the primitive shape within a fx family. Dense values, 0x00 reserved.
const ( ShapeKindReserved ShapeKind = 0x00 ShapeKindTransferOutput ShapeKind = 0x01 ShapeKindTransferInput ShapeKind = 0x02 ShapeKindMintOutput ShapeKind = 0x03 ShapeKindMintInput ShapeKind = 0x04 ShapeKindMintOperation ShapeKind = 0x05 ShapeKindCredential ShapeKind = 0x06 ShapeKindAttestationOut ShapeKind = 0x07 ShapeKindAttestationIn ShapeKind = 0x08 ShapeKindOutputOwners ShapeKind = 0x09 ShapeKindUTXO ShapeKind = 0x0A ShapeKindTransferableOut ShapeKind = 0x0B ShapeKindTransferableIn ShapeKind = 0x0C ShapeKindPChainOwner ShapeKind = 0x0D ShapeKindSignedTx ShapeKind = 0x0E ShapeKindLockedOutput ShapeKind = 0x0F )
const ShapeKindPQMintOutput ShapeKind = 0x11
ShapeKindPQMintOutput is the discriminator for PQ-fx MintOutput.
const ShapeKindPQOutputOwners ShapeKind = 0x0F
ShapeKindPQOutputOwners is the discriminator for PQ-fx OutputOwners.
const ShapeKindPQTransferOutput ShapeKind = 0x10
ShapeKindPQTransferOutput is the discriminator for PQ-fx TransferOutput.
type SignedTx ¶
type SignedTx struct {
// contains filtered or unexported fields
}
SignedTx is the zero-copy typed accessor.
func WrapSignedTx ¶
WrapSignedTx parses a SignedTx wire envelope.
func (SignedTx) AllCredentials ¶
func (s SignedTx) AllCredentials() ([]Credential, error)
AllCredentials parses every credential into a fresh slice. Use this when the caller needs to iterate all credentials (the executor's VerifyTransfer pass).
func (SignedTx) CredentialAt ¶
func (s SignedTx) CredentialAt(i uint32) (Credential, error)
CredentialAt parses the i'th credential envelope from the concatenated blob and returns its typed accessor. Returns the zero Credential (IsZero=true) if i is out of range or the blob is malformed.
Walking is O(i) because each ZAP credential carries its own length in the wire header. For a hot-loop verifier, prefetch all credentials once into a []Credential slice.
func (SignedTx) CredentialBytes ¶
CredentialBytes returns the concatenated credential envelopes blob. Each credential is a self-describing wire envelope (2-byte prefix + length-prefixed ZAP message); see CredentialAt for the index walk.
func (SignedTx) CredentialCount ¶
CredentialCount returns the number of credentials.
func (SignedTx) UnsignedBytes ¶
UnsignedBytes returns the unsigned tx bytes. This is the canonical signing target — every fxs signature was computed over a hash of these bytes.
READ-ONLY: aliases the underlying buffer. Use append([]byte(nil), ...) to take ownership.
type SignedTxInput ¶
type SignedTxInput struct {
UnsignedBytes []byte
// Credentials is the slice of credential wire envelopes (each one
// already prefixed with its own TypeKind+ShapeKind+ZAP message).
// The constructor concatenates them — order is preserved and aligns
// 1:1 with the unsigned tx's input list.
Credentials [][]byte
}
SignedTxInput is the constructor input.
type TransferInput ¶
type TransferInput struct {
// contains filtered or unexported fields
}
TransferInput is the zero-copy typed accessor.
func WrapTransferInput ¶
func WrapTransferInput(b []byte) (TransferInput, error)
WrapTransferInput parses a TransferInput wire envelope.
func (TransferInput) Amount ¶
func (t TransferInput) Amount() uint64
Amount returns the amount being spent.
func (TransferInput) IsZero ¶
func (t TransferInput) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (TransferInput) SigIndices ¶
func (t TransferInput) SigIndices() []uint32
SigIndices returns the SigIndices view as a fresh []uint32.
func (TransferInput) SigIndicesLen ¶
func (t TransferInput) SigIndicesLen() int
SigIndicesLen returns the number of signature indices.
func (TransferInput) TypeKind ¶
func (t TransferInput) TypeKind() TypeKind
TypeKind returns the fx family that owns this input.
type TransferInputInput ¶
TransferInputInput is the constructor input.
type TransferOutput ¶
type TransferOutput struct {
// contains filtered or unexported fields
}
TransferOutput is the zero-copy typed accessor over a ZAP-encoded TransferOutput wire envelope.
func WrapTransferOutput ¶
func WrapTransferOutput(b []byte) (TransferOutput, error)
WrapTransferOutput parses a TransferOutput wire envelope into a typed accessor. Accepts any TypeKind (classical or PQ); ShapeKind must be ShapeKindTransferOutput.
func (TransferOutput) AddressList ¶
func (t TransferOutput) AddressList() AddressList
AddressList returns the address list view.
func (TransferOutput) Amount ¶
func (t TransferOutput) Amount() uint64
Amount returns the asset amount this output is worth.
func (TransferOutput) IsZero ¶
func (t TransferOutput) IsZero() bool
IsZero reports whether the accessor wraps a parsed message.
func (TransferOutput) Locktime ¶
func (t TransferOutput) Locktime() uint64
Locktime returns the unix timestamp before which the output cannot be spent.
func (TransferOutput) SyntacticVerify ¶
func (t TransferOutput) SyntacticVerify() error
SyntacticVerify enforces the same gates as OutputOwners.SyntacticVerify plus Amount > 0.
func (TransferOutput) Threshold ¶
func (t TransferOutput) Threshold() uint32
Threshold returns the signatures-required count.
func (TransferOutput) TypeKind ¶
func (t TransferOutput) TypeKind() TypeKind
TypeKind returns the fx family that owns this output.
type TransferOutputInput ¶
type TransferOutputInput struct {
TypeKind TypeKind
Amount uint64
Locktime uint64
Threshold uint32
Addresses []ids.ShortID
}
TransferOutputInput is the constructor input.
type TypeKind ¶
type TypeKind uint8
TypeKind names the fx family that owns the primitive. Dense values, 0x00 reserved (rejected by every Wrap*).
type UTXO ¶
type UTXO struct {
// contains filtered or unexported fields
}
UTXO is the zero-copy typed accessor over a ZAP-encoded UTXO wire envelope.
READ-ONLY: every field aliases the underlying ZAP buffer. Mutation corrupts any UTXOID = hash(buffer) computed downstream and breaks cross-VM atomic UTXO transfer semantics. Use append([]byte(nil), ...) to take ownership of the Output bytes when handing off to a different goroutine.
func WrapUTXO ¶
WrapUTXO parses a UTXO wire envelope into a typed accessor.
Returns ErrShortEnvelope when the buffer is shorter than the 2-byte discriminator prefix; ErrWrongShapeKind when the prefix names a non-UTXO shape.
func (UTXO) Bytes ¶
Bytes returns the full wire envelope (2-byte discriminator prefix + ZAP message) for the UTXO. Stable across calls — backed by the originally-parsed buffer.
func (UTXO) OutputBytes ¶
OutputBytes returns the inner fxs primitive's wire envelope (2-byte discriminator prefix + ZAP message). Use WrapTransferableOutput, WrapMintOutput, etc. to parse the bytes into a typed accessor after dispatching on the (TypeKind, ShapeKind) pair.
READ-ONLY: aliases the underlying ZAP buffer.
func (UTXO) OutputDiscriminator ¶
OutputDiscriminator returns the (TypeKind, ShapeKind) pair embedded at the head of OutputBytes(). Returns (0, 0) when OutputBytes is shorter than the 2-byte prefix.
func (UTXO) OutputIndex ¶
OutputIndex returns the spent UTXO's output index.
type UTXOInput ¶
type UTXOInput struct {
TxID ids.ID
OutputIndex uint32
AssetID ids.ID
// Output is the inner fxs primitive's wire envelope (already
// prefixed with its own discriminator). The constructor stores
// these bytes verbatim in the Output field.
Output []byte
}
UTXOInput is the constructor input for NewUTXO.