Documentation
¶
Index ¶
- Variables
- func ComputeCommitment(note *Note) []byte
- func ComputeNullifier(note *Note, spendingKey []byte) []byte
- func EncryptNote(note *Note, recipientPubKey []byte, ephemeralPrivKey []byte, chainID ids.ID, ...) ([]byte, []byte, error)
- func NewPrivacyHandler(vm *VM) http.Handler
- func NewProofHandler(vm *VM) http.Handler
- func NewRPCHandler(vm *VM) http.Handler
- type AddressManager
- func (am *AddressManager) CanDecryptNote(ephemeralPubKey []byte, address []byte) bool
- func (am *AddressManager) Close()
- func (am *AddressManager) DeriveNullifier(address []byte, note *Note) ([]byte, error)
- func (am *AddressManager) GenerateAddress() (*PrivateAddress, error)
- func (am *AddressManager) GetAddress(address []byte) (*PrivateAddress, error)
- func (am *AddressManager) GetAddressCount() uint64
- func (am *AddressManager) GetAddressesByViewingKey(viewingKey []byte) ([]*PrivateAddress, error)
- func (am *AddressManager) SignTransaction(tx *Transaction, signingAddresses [][]byte) error
- type Block
- func (b *Block) Accept(ctx context.Context) error
- func (b *Block) Bytes() []byte
- func (b *Block) Height() uint64
- func (b *Block) ID() ids.ID
- func (b *Block) Parent() ids.ID
- func (b *Block) ParentID() ids.ID
- func (b *Block) Reject(ctx context.Context) error
- func (b *Block) Status() uint8
- func (b *Block) Timestamp() time.Time
- func (b *Block) ToSummary() *BlockSummary
- func (b *Block) Verify(ctx context.Context) error
- type BlockSummary
- type FHEData
- type FHEProcessor
- func (fp *FHEProcessor) AddCiphertexts(ct1, ct2 []byte) ([]byte, error)
- func (fp *FHEProcessor) DecryptValue(ciphertext []byte, privateKey []byte) (uint64, error)
- func (fp *FHEProcessor) EncryptValue(value uint64) ([]byte, error)
- func (fp *FHEProcessor) GetStats() uint64
- func (fp *FHEProcessor) MultiplyCiphertext(ct []byte, scalar uint64) ([]byte, error)
- func (fp *FHEProcessor) ProcessFHEComputation(circuitID string, encryptedInputs [][]byte) ([]byte, []byte, error)
- func (fp *FHEProcessor) VerifyFHEOperations(tx *Transaction) error
- type Factory
- type Genesis
- type Groth16Proof
- type Groth16VerifyingKey
- type Health
- type Mempool
- func (mp *Mempool) AddTransaction(tx *Transaction) error
- func (mp *Mempool) Clear()
- func (mp *Mempool) GetPendingTransactions(limit int) []*Transaction
- func (mp *Mempool) HasNullifier(nullifier []byte) bool
- func (mp *Mempool) HasTransaction(txID ids.ID) bool
- func (mp *Mempool) PruneExpired(currentHeight uint64)
- func (mp *Mempool) RemoveTransaction(txID ids.ID)
- func (mp *Mempool) Size() int
- type MempoolTx
- type Note
- type NullifierDB
- func (ndb *NullifierDB) Close()
- func (ndb *NullifierDB) GetNullifierCount() uint64
- func (ndb *NullifierDB) GetNullifierHeight(nullifier []byte) (uint64, error)
- func (ndb *NullifierDB) GetNullifiersByHeight(height uint64) [][]byte
- func (ndb *NullifierDB) IsNullifierSpent(nullifier []byte) bool
- func (ndb *NullifierDB) MarkNullifierSpent(nullifier []byte, height uint64) error
- func (ndb *NullifierDB) RemoveNullifier(nullifier []byte) error
- type PLONKProof
- type PLONKVerifyingKey
- type PrivateAddress
- type ProofVerifier
- func (pv *ProofVerifier) ClearCache()
- func (pv *ProofVerifier) GetCacheSize() int
- func (pv *ProofVerifier) GetStats() (verifyCount, cacheHits, cacheMisses uint64)
- func (pv *ProofVerifier) VerifyBlockProof(block *Block) error
- func (pv *ProofVerifier) VerifyTransactionProof(tx *Transaction) error
- func (pv *ProofVerifier) VerifyingKeysLoaded() bool
- type SetupParams
- type ShieldedOutput
- type StateTree
- func (st *StateTree) ApplyTransaction(tx *Transaction) error
- func (st *StateTree) Close()
- func (st *StateTree) ComputeRoot() ([]byte, error)
- func (st *StateTree) Finalize(newRoot []byte) error
- func (st *StateTree) GetMerkleProof(commitment []byte) ([][]byte, error)
- func (st *StateTree) GetRoot() []byte
- func (st *StateTree) VerifyMerkleProof(commitment []byte, proof [][]byte, root []byte) bool
- type Transaction
- type TransactionType
- type TransparentInput
- type TransparentOutput
- type TxHeap
- type UTXO
- type UTXODB
- func (udb *UTXODB) AddUTXO(utxo *UTXO) error
- func (udb *UTXODB) Close()
- func (udb *UTXODB) GetAllCommitments() [][]byte
- func (udb *UTXODB) GetUTXO(commitment []byte) (*UTXO, error)
- func (udb *UTXODB) GetUTXOCount() uint64
- func (udb *UTXODB) GetUTXOsByHeight(height uint64) ([]*UTXO, error)
- func (udb *UTXODB) PruneOldUTXOs(minHeight uint64) error
- func (udb *UTXODB) RemoveUTXO(commitment []byte) error
- type VM
- func (vm *VM) BuildBlock(ctx context.Context) (chain.Block, error)
- func (vm *VM) BuildVertex(ctx context.Context) (vertex.Vertex, error)
- func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *chain.VersionInfo) error
- func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error)
- func (vm *VM) CrossChainRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, ...) error
- func (vm *VM) CrossChainRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, appErr *warp.Error) error
- func (vm *VM) CrossChainResponse(ctx context.Context, chainID ids.ID, requestID uint32, response []byte) error
- func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error
- func (vm *VM) FeePolicy() fee.Policy
- func (vm *VM) GetBlock(ctx context.Context, blkID ids.ID) (chain.Block, error)
- func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)
- func (vm *VM) Gossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error
- func (vm *VM) HealthCheck(ctx context.Context) (chain.HealthResult, error)
- func (vm *VM) Initialize(ctx context.Context, init vmcore.Init) error
- func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)
- func (vm *VM) NewHTTPHandler(ctx context.Context) (http.Handler, error)
- func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (chain.Block, error)
- func (vm *VM) ParseVertex(ctx context.Context, b []byte) (vertex.Vertex, error)
- func (vm *VM) Request(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, ...) error
- func (vm *VM) RequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *warp.Error) error
- func (vm *VM) Response(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
- func (vm *VM) SetPreference(ctx context.Context, blkID ids.ID) error
- func (vm *VM) SetState(ctx context.Context, state uint32) error
- func (vm *VM) Shutdown(ctx context.Context) error
- func (vm *VM) StrictPQ() bool
- func (vm *VM) Version(ctx context.Context) (string, error)
- func (vm *VM) WaitForEvent(ctx context.Context) (vmcore.Message, error)
- func (vm *VM) ZKPrecompiles() *precompiles.MapRegistry
- type Vertex
- func (v *Vertex) Accept(ctx context.Context) error
- func (v *Vertex) Bytes() []byte
- func (v *Vertex) Conflicts(other *Vertex) bool
- func (v *Vertex) ConflictsVertex(other vertex.Vertex) bool
- func (v *Vertex) Epoch() uint32
- func (v *Vertex) Height() uint64
- func (v *Vertex) ID() ids.ID
- func (v *Vertex) Parents() []ids.ID
- func (v *Vertex) Reject(ctx context.Context) error
- func (v *Vertex) Status() choices.Status
- func (v *Vertex) Txs() []ids.ID
- func (v *Vertex) Verify(ctx context.Context) error
- type ZConfig
- type ZKProof
- type ZWitnessAdapter
Constants ¶
This section is empty.
Variables ¶
var Codec pcodecs.Manager
var ErrZWitnessNotImplemented = errors.New("Z-Chain MLDSAStark prover not implemented: needs the MLDSA-rollup AIR + a p3q_prove C ABI (LP-020 §6, paper App. B)")
ErrZWitnessNotImplemented is returned by ZWitnessAdapter.Witness until the MLDSAStark rollup AIR and the p3q prover C ABI ship. The verifier side (STARKVerifier → precompile/starkfri) is already wired; this is the prover-binding gap only.
var VMID = ids.ID{'z', 'k', 'v', 'm'}
VMID is the unique identifier for ZKVM (Z-Chain)
var (
Version = &version.Semantic{
Major: 1,
Minor: 0,
Patch: 0,
}
)
Functions ¶
func ComputeCommitment ¶
ComputeCommitment computes a note commitment
func ComputeNullifier ¶
ComputeNullifier computes a nullifier for a note
func EncryptNote ¶
func EncryptNote(note *Note, recipientPubKey []byte, ephemeralPrivKey []byte, chainID ids.ID, txID ids.ID) ([]byte, []byte, error)
EncryptNote encrypts a note for the recipient using ChaCha20-Poly1305. chainID and txID bind the encryption key to prevent cross-chain/cross-tx reuse.
func NewPrivacyHandler ¶
NewPrivacyHandler creates the privacy-specific handler
func NewProofHandler ¶
NewProofHandler creates the proof-specific handler
func NewRPCHandler ¶
NewRPCHandler creates the main RPC handler
Types ¶
type AddressManager ¶
type AddressManager struct {
// contains filtered or unexported fields
}
AddressManager manages private addresses and viewing keys
func NewAddressManager ¶
func NewAddressManager(db database.Database, enablePrivate bool, log log.Logger) (*AddressManager, error)
NewAddressManager creates a new address manager
func (*AddressManager) CanDecryptNote ¶
func (am *AddressManager) CanDecryptNote(ephemeralPubKey []byte, address []byte) bool
CanDecryptNote checks if we have the keys to decrypt a note
func (*AddressManager) DeriveNullifier ¶
func (am *AddressManager) DeriveNullifier(address []byte, note *Note) ([]byte, error)
DeriveNullifier derives a nullifier using the spending key
func (*AddressManager) GenerateAddress ¶
func (am *AddressManager) GenerateAddress() (*PrivateAddress, error)
GenerateAddress generates a new private address
func (*AddressManager) GetAddress ¶
func (am *AddressManager) GetAddress(address []byte) (*PrivateAddress, error)
GetAddress retrieves an address by its public address
func (*AddressManager) GetAddressCount ¶
func (am *AddressManager) GetAddressCount() uint64
GetAddressCount returns the total number of addresses
func (*AddressManager) GetAddressesByViewingKey ¶
func (am *AddressManager) GetAddressesByViewingKey(viewingKey []byte) ([]*PrivateAddress, error)
GetAddressesByViewingKey returns all addresses associated with a viewing key
func (*AddressManager) SignTransaction ¶
func (am *AddressManager) SignTransaction(tx *Transaction, signingAddresses [][]byte) error
SignTransaction signs a transaction with the appropriate keys
type Block ¶
type Block struct {
ParentID_ ids.ID `json:"parentId"`
BlockHeight uint64 `json:"height"`
BlockTimestamp int64 `json:"timestamp"`
Txs []*Transaction `json:"transactions"`
StateRoot []byte `json:"stateRoot"` // Merkle tree root of UTXO set
// Aggregated proof for the block (optional)
BlockProof *ZKProof `json:"blockProof,omitempty"`
// Cached values
ID_ ids.ID
// contains filtered or unexported fields
}
Block represents a block in the ZK UTXO chain
func (*Block) ToSummary ¶
func (b *Block) ToSummary() *BlockSummary
ToSummary converts a block to a summary
type BlockSummary ¶
type BlockSummary struct {
ID ids.ID `json:"id"`
Height uint64 `json:"height"`
Timestamp int64 `json:"timestamp"`
TxCount int `json:"txCount"`
StateRoot []byte `json:"stateRoot"`
}
BlockSummary represents a lightweight block summary
type FHEData ¶
type FHEData struct {
// Encrypted computation inputs
EncryptedInputs [][]byte `json:"encryptedInputs"`
// Computation circuit
CircuitID string `json:"circuitId"`
// Encrypted result
EncryptedResult []byte `json:"encryptedResult"`
// Proof of correct computation
ComputationProof []byte `json:"computationProof"`
}
FHEData represents fully homomorphic encryption data
type FHEProcessor ¶
type FHEProcessor struct {
// contains filtered or unexported fields
}
FHEProcessor handles fully homomorphic encryption operations
func NewFHEProcessor ¶
func NewFHEProcessor(config ZConfig, log log.Logger) (*FHEProcessor, error)
NewFHEProcessor creates a new FHE processor
func (*FHEProcessor) AddCiphertexts ¶
func (fp *FHEProcessor) AddCiphertexts(ct1, ct2 []byte) ([]byte, error)
AddCiphertexts performs homomorphic addition
func (*FHEProcessor) DecryptValue ¶
func (fp *FHEProcessor) DecryptValue(ciphertext []byte, privateKey []byte) (uint64, error)
DecryptValue decrypts an FHE ciphertext
func (*FHEProcessor) EncryptValue ¶
func (fp *FHEProcessor) EncryptValue(value uint64) ([]byte, error)
EncryptValue encrypts a value using FHE
func (*FHEProcessor) GetStats ¶
func (fp *FHEProcessor) GetStats() uint64
GetStats returns FHE processing statistics
func (*FHEProcessor) MultiplyCiphertext ¶
func (fp *FHEProcessor) MultiplyCiphertext(ct []byte, scalar uint64) ([]byte, error)
MultiplyCiphertext performs homomorphic multiplication by a plaintext
func (*FHEProcessor) ProcessFHEComputation ¶
func (fp *FHEProcessor) ProcessFHEComputation( circuitID string, encryptedInputs [][]byte, ) ([]byte, []byte, error)
ProcessFHEComputation performs an FHE computation
func (*FHEProcessor) VerifyFHEOperations ¶
func (fp *FHEProcessor) VerifyFHEOperations(tx *Transaction) error
VerifyFHEOperations verifies FHE operations in a transaction
type Factory ¶
type Factory struct{}
Factory implements vms.Factory interface for creating Z-Chain VM instances
type Genesis ¶
type Genesis struct {
Timestamp int64 `json:"timestamp"`
InitialTxs []*Transaction `json:"initialTransactions,omitempty"`
// Initial setup parameters
SetupParams *SetupParams `json:"setupParams,omitempty"`
}
Genesis represents genesis data
func ParseGenesis ¶
ParseGenesis parses genesis bytes (supports both JSON and Codec formats)
type Groth16Proof ¶
type Groth16Proof struct {
Ar bn254.G1Affine // Proof component A
Bs bn254.G2Affine // Proof component B
Krs bn254.G1Affine // Proof component C
}
Groth16Proof represents a Groth16 proof structure
type Groth16VerifyingKey ¶
type Groth16VerifyingKey struct {
Alpha bn254.G1Affine // Alpha in G1
Beta bn254.G2Affine // Beta in G2
Gamma bn254.G2Affine // Gamma in G2
Delta bn254.G2Affine // Delta in G2
K []bn254.G1Affine // K[i] for public inputs
}
Groth16VerifyingKey represents a Groth16 verifying key
type Health ¶
type Health struct {
DatabaseHealthy bool `json:"databaseHealthy"`
UTXOCount uint64 `json:"utxoCount"`
NullifierCount uint64 `json:"nullifierCount"`
LastBlockHeight uint64 `json:"lastBlockHeight"`
PendingBlockCount int `json:"pendingBlockCount"`
MempoolSize int `json:"mempoolSize"`
ProofCacheSize int `json:"proofCacheSize"`
}
Health represents VM health status
type Mempool ¶
type Mempool struct {
// contains filtered or unexported fields
}
Mempool manages pending transactions
func NewMempool ¶
NewMempool creates a new mempool
func (*Mempool) AddTransaction ¶
func (mp *Mempool) AddTransaction(tx *Transaction) error
AddTransaction adds a transaction to the mempool
func (*Mempool) GetPendingTransactions ¶
func (mp *Mempool) GetPendingTransactions(limit int) []*Transaction
GetPendingTransactions returns pending transactions sorted by priority
func (*Mempool) HasNullifier ¶
HasNullifier checks if a nullifier is already in the mempool
func (*Mempool) HasTransaction ¶
HasTransaction checks if a transaction is in the mempool
func (*Mempool) PruneExpired ¶
PruneExpired removes expired transactions
func (*Mempool) RemoveTransaction ¶
RemoveTransaction removes a transaction from the mempool
type MempoolTx ¶
type MempoolTx struct {
// contains filtered or unexported fields
}
MempoolTx represents a transaction in the mempool
type Note ¶
type Note struct {
Value *big.Int `json:"value"` // Encrypted amount
Address []byte `json:"address"` // Recipient address
AssetID ids.ID `json:"assetId"` // Asset type
Randomness []byte `json:"randomness"` // Note randomness
Nullifier []byte `json:"nullifier"` // Computed nullifier
}
Note represents a shielded note (internal representation)
type NullifierDB ¶
type NullifierDB struct {
// contains filtered or unexported fields
}
NullifierDB manages spent nullifiers
func NewNullifierDB ¶
NewNullifierDB creates a new nullifier database
func (*NullifierDB) GetNullifierCount ¶
func (ndb *NullifierDB) GetNullifierCount() uint64
GetNullifierCount returns the total number of spent nullifiers
func (*NullifierDB) GetNullifierHeight ¶
func (ndb *NullifierDB) GetNullifierHeight(nullifier []byte) (uint64, error)
GetNullifierHeight returns the height when a nullifier was spent
func (*NullifierDB) GetNullifiersByHeight ¶
func (ndb *NullifierDB) GetNullifiersByHeight(height uint64) [][]byte
GetNullifiersByHeight returns all nullifiers spent at a specific height
func (*NullifierDB) IsNullifierSpent ¶
func (ndb *NullifierDB) IsNullifierSpent(nullifier []byte) bool
IsNullifierSpent checks if a nullifier has been spent
func (*NullifierDB) MarkNullifierSpent ¶
func (ndb *NullifierDB) MarkNullifierSpent(nullifier []byte, height uint64) error
MarkNullifierSpent marks a nullifier as spent
func (*NullifierDB) RemoveNullifier ¶
func (ndb *NullifierDB) RemoveNullifier(nullifier []byte) error
RemoveNullifier removes a nullifier (used for reorg)
type PLONKProof ¶
type PLONKProof struct {
// Commitments (7 G1 points)
LCommit bn254.G1Affine // Wire L commitment
RCommit bn254.G1Affine // Wire R commitment
OCommit bn254.G1Affine // Wire O commitment
ZCommit bn254.G1Affine // Permutation polynomial commitment
TLow bn254.G1Affine // Quotient polynomial low
TMid bn254.G1Affine // Quotient polynomial mid
THigh bn254.G1Affine // Quotient polynomial high
// Opening proof components
WzOpening bn254.G1Affine // Opening at z
WzwOpening bn254.G1Affine // Opening at z*omega
// Evaluation proofs (scalars)
AEval fr.Element // a(z) evaluation
BEval fr.Element // b(z) evaluation
CEval fr.Element // c(z) evaluation
SigmaEval fr.Element // sigma permutation evaluation
ZEval fr.Element // z(z*omega) evaluation
}
PLONKProof represents a PLONK proof structure
type PLONKVerifyingKey ¶
type PLONKVerifyingKey struct {
// SRS elements
G1 bn254.G1Affine // Generator in G1
G2 bn254.G2Affine // Generator in G2
G2Alpha bn254.G2Affine // [alpha]_2
// Selector commitments
QLCommit bn254.G1Affine // Left selector
QRCommit bn254.G1Affine // Right selector
QMCommit bn254.G1Affine // Multiplication selector
QOCommit bn254.G1Affine // Output selector
QCCommit bn254.G1Affine // Constant selector
// Permutation commitments
S1Commit bn254.G1Affine // Sigma_1 permutation
S2Commit bn254.G1Affine // Sigma_2 permutation
S3Commit bn254.G1Affine // Sigma_3 permutation
// Domain parameters
N uint64 // Circuit size (power of 2)
K1, K2 fr.Element // Coset generators
Omega fr.Element // Root of unity
}
PLONKVerifyingKey represents a PLONK verifying key
type PrivateAddress ¶
type PrivateAddress struct {
Address []byte `json:"address"` // Public address (32 bytes)
ViewingKey []byte `json:"viewingKey"` // Viewing key for scanning
SpendingKey []byte `json:"spendingKey"` // Spending key (private)
Diversifier []byte `json:"diversifier"` // Address diversifier
IncomingViewKey []byte `json:"incomingViewKey"` // For incoming payments only
CreatedAt int64 `json:"createdAt"`
}
PrivateAddress represents a private address
type ProofVerifier ¶
type ProofVerifier struct {
// contains filtered or unexported fields
}
ProofVerifier verifies zero-knowledge proofs. When verifying keys are all zeros (dummy), proof verification is disabled and VerifyProof returns an error. This is fail-closed by design.
func NewProofVerifier ¶
func NewProofVerifier(config ZConfig, log log.Logger) (*ProofVerifier, error)
NewProofVerifier creates a new proof verifier
func (*ProofVerifier) ClearCache ¶
func (pv *ProofVerifier) ClearCache()
ClearCache clears the proof verification cache
func (*ProofVerifier) GetCacheSize ¶
func (pv *ProofVerifier) GetCacheSize() int
GetCacheSize returns the current size of the proof cache
func (*ProofVerifier) GetStats ¶
func (pv *ProofVerifier) GetStats() (verifyCount, cacheHits, cacheMisses uint64)
GetStats returns verifier statistics
func (*ProofVerifier) VerifyBlockProof ¶
func (pv *ProofVerifier) VerifyBlockProof(block *Block) error
VerifyBlockProof verifies an aggregated block proof. When GPU is available and multiple proofs exist, uses batch MSM acceleration.
func (*ProofVerifier) VerifyTransactionProof ¶
func (pv *ProofVerifier) VerifyTransactionProof(tx *Transaction) error
VerifyTransactionProof verifies a transaction's zero-knowledge proof. Returns an error if verifying keys are dummy (all zeros).
func (*ProofVerifier) VerifyingKeysLoaded ¶
func (pv *ProofVerifier) VerifyingKeysLoaded() bool
VerifyingKeysLoaded returns true if real (non-dummy) verifying keys are loaded.
type SetupParams ¶
type SetupParams struct {
// Groth16 CRS
PowersOfTau []byte `json:"powersOfTau,omitempty"`
VerifyingKey []byte `json:"verifyingKey,omitempty"`
// PLONK setup
PlonkSRS []byte `json:"plonkSRS,omitempty"`
// FHE parameters
FHEPublicParams []byte `json:"fhePublicParams,omitempty"`
}
SetupParams contains trusted setup parameters
type ShieldedOutput ¶
type ShieldedOutput struct {
// Commitment to the note (amount and address)
Commitment []byte `json:"commitment"`
// Encrypted note ciphertext
EncryptedNote []byte `json:"encryptedNote"`
// Ephemeral public key for note encryption
EphemeralPubKey []byte `json:"ephemeralPubKey"`
// Output proof (rangeproof for amount)
OutputProof []byte `json:"outputProof"`
}
ShieldedOutput represents a confidential output
type StateTree ¶
type StateTree struct {
// contains filtered or unexported fields
}
StateTree manages a sparse Merkle tree of the UTXO set
func NewStateTree ¶
NewStateTree creates a new sparse Merkle tree
func (*StateTree) ApplyTransaction ¶
func (st *StateTree) ApplyTransaction(tx *Transaction) error
ApplyTransaction applies a transaction to the state tree
func (*StateTree) ComputeRoot ¶
ComputeRoot computes the new Merkle root after pending changes. Uses GPU-accelerated Poseidon hash when available for ZK-friendly hashing. Falls back to SHA-256 when GPU is unavailable.
func (*StateTree) GetMerkleProof ¶
GetMerkleProof generates a Merkle proof for a commitment in the sparse Merkle tree
type Transaction ¶
type Transaction struct {
ID ids.ID `json:"id"`
Type TransactionType `json:"type"`
Version uint8 `json:"version"`
// Transparent inputs/outputs (for shield/unshield)
TransparentInputs []*TransparentInput `json:"transparentInputs,omitempty"`
TransparentOutputs []*TransparentOutput `json:"transparentOutputs,omitempty"`
// Shielded components
Nullifiers [][]byte `json:"nullifiers"` // Spent note nullifiers
Outputs []*ShieldedOutput `json:"outputs"` // New shielded outputs
// Zero-knowledge proof
Proof *ZKProof `json:"proof"`
// FHE operations (optional)
FHEData *FHEData `json:"fheData,omitempty"`
// Transaction metadata
Fee uint64 `json:"fee"`
Expiry uint64 `json:"expiry"` // Block height
Memo []byte `json:"memo,omitempty"` // Encrypted memo
// Signature for transparent components
Signature []byte `json:"signature,omitempty"`
}
Transaction represents a confidential transaction
func (*Transaction) ComputeID ¶
func (tx *Transaction) ComputeID() ids.ID
ComputeID computes the transaction ID
func (*Transaction) GetNullifiers ¶
func (tx *Transaction) GetNullifiers() [][]byte
GetNullifiers returns all nullifiers in the transaction
func (*Transaction) GetOutputCommitments ¶
func (tx *Transaction) GetOutputCommitments() [][]byte
GetOutputCommitments returns all output commitments
func (*Transaction) HasFHEOperations ¶
func (tx *Transaction) HasFHEOperations() bool
HasFHEOperations returns true if the transaction includes FHE operations
func (*Transaction) ValidateBasic ¶
func (tx *Transaction) ValidateBasic() error
ValidateBasic performs basic validation
type TransactionType ¶
type TransactionType uint8
TransactionType represents the type of transaction
const ( TransactionTypeTransfer TransactionType = iota TransactionTypeMint TransactionTypeBurn TransactionTypeShield // Convert transparent to shielded TransactionTypeUnshield // Convert shielded to transparent )
type TransparentInput ¶
type TransparentInput struct {
TxID ids.ID `json:"txId"`
OutputIdx uint32 `json:"outputIdx"`
Amount uint64 `json:"amount"`
Address []byte `json:"address"`
}
TransparentInput represents an unshielded input
type TransparentOutput ¶
type TransparentOutput struct {
Amount uint64 `json:"amount"`
Address []byte `json:"address"`
AssetID ids.ID `json:"assetId"`
}
TransparentOutput represents an unshielded output
type UTXO ¶
type UTXO struct {
TxID ids.ID `json:"txId"`
OutputIndex uint32 `json:"outputIndex"`
Commitment []byte `json:"commitment"` // Output commitment
Ciphertext []byte `json:"ciphertext"` // Encrypted note
EphemeralPK []byte `json:"ephemeralPK"` // Ephemeral public key
Height uint64 `json:"height"` // Block height when created
}
UTXO represents an unspent transaction output
type UTXODB ¶
type UTXODB struct {
// contains filtered or unexported fields
}
UTXODB manages the UTXO set
func (*UTXODB) GetAllCommitments ¶
GetAllCommitments returns all UTXO commitments (for Merkle tree)
func (*UTXODB) GetUTXOCount ¶
GetUTXOCount returns the total number of UTXOs
func (*UTXODB) GetUTXOsByHeight ¶
GetUTXOsByHeight returns all UTXOs created at a specific height
func (*UTXODB) PruneOldUTXOs ¶
PruneOldUTXOs removes UTXOs older than a certain height
func (*UTXODB) RemoveUTXO ¶
RemoveUTXO removes a UTXO from the set
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM implements the Zero-Knowledge UTXO Chain VM
func (*VM) BuildBlock ¶
BuildBlock builds a new block
func (*VM) BuildVertex ¶
BuildVertex drains the mempool, batches non-conflicting txs, and returns a vertex.
func (*VM) CreateHandlers ¶
CreateHandlers returns the VM handlers
func (*VM) CrossChainRequest ¶
func (vm *VM) CrossChainRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, request []byte) error
CrossChainRequest implements the common.VM interface
func (*VM) CrossChainRequestFailed ¶
func (vm *VM) CrossChainRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, appErr *warp.Error) error
CrossChainRequestFailed implements the common.VM interface
func (*VM) CrossChainResponse ¶
func (vm *VM) CrossChainResponse(ctx context.Context, chainID ids.ID, requestID uint32, response []byte) error
CrossChainResponse implements the common.VM interface
func (*VM) FeePolicy ¶ added in v1.2.6
FeePolicy exposes the chain's declared fee policy for diagnostics and the boot-time Validate gate.
func (*VM) GetBlockIDAtHeight ¶
GetBlockIDAtHeight implements the chain.HeightIndexedChainVM interface
func (*VM) HealthCheck ¶
HealthCheck performs a health check
func (*VM) Initialize ¶
Initialize initializes the VM
func (*VM) NewHTTPHandler ¶
NewHTTPHandler returns HTTP handlers for the VM
func (*VM) ParseBlock ¶
ParseBlock parses a block from bytes
func (*VM) ParseVertex ¶
ParseVertex deserializes a vertex from bytes.
func (*VM) Request ¶
func (vm *VM) Request(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error
Request implements the common.VM interface
func (*VM) RequestFailed ¶
func (vm *VM) RequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *warp.Error) error
RequestFailed implements the common.VM interface
func (*VM) Response ¶
func (vm *VM) Response(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error
Response implements the common.VM interface
func (*VM) SetPreference ¶
Additional interface implementations
func (*VM) StrictPQ ¶ added in v1.3.10
StrictPQ reports whether this Z-Chain instance is on the strict-PQ security profile. It is the single bit that gates both the shielded- proof verifier and the classical-precompile registration.
func (*VM) WaitForEvent ¶
WaitForEvent blocks until an event occurs that should trigger block building
func (*VM) ZKPrecompiles ¶ added in v1.3.10
func (vm *VM) ZKPrecompiles() *precompiles.MapRegistry
ZKPrecompiles returns the registered Z-Chain ZK verifier precompiles. On a strict-PQ chain the classical Groth16 (0x80) / PLONK (0x81) addresses resolve to "no precompile" (fail-closed by absence).
type Vertex ¶
type Vertex struct {
// contains filtered or unexported fields
}
Vertex represents a DAG vertex in the ZK UTXO chain. Conflict key: set of nullifiers spent in the vertex. Two vertices conflict iff their nullifier sets intersect.
func (*Vertex) ConflictsVertex ¶
ConflictsVertex performs the same check against the vertex.Vertex interface.
type ZConfig ¶
type ZConfig struct {
// Privacy configuration
EnableConfidentialTransfers bool `serialize:"true" json:"enableConfidentialTransfers"`
EnablePrivateAddresses bool `serialize:"true" json:"enablePrivateAddresses"`
// ZK proof configuration
ProofSystem string `serialize:"true" json:"proofSystem"` // groth16, plonk, etc.
CircuitType string `serialize:"true" json:"circuitType"` // transfer, mint, burn
VerifyingKeyPath string `serialize:"true" json:"verifyingKeyPath"`
TrustedSetupPath string `serialize:"true" json:"trustedSetupPath"`
// VerifyingKeys supplies real (non-dummy) verifying keys per circuit
// type (keyed by the TransactionType string), in-memory at genesis.
// When empty, loadVerifyingKeys installs all-zero dummy keys (proof
// verification disabled, fail-closed). On a strict-PQ chain, supplying
// a real bn254 verifying key here is REFUSED at construction
// (errStrictPQRealVKForbidden) — shielded value uses STARK/FRI only.
VerifyingKeys map[string][]byte `serialize:"true" json:"verifyingKeys"`
// StrictPQ HARD-DISABLES the classical (bn254 pairing-based) shielded
// proof systems on this chain. When true, the shielded-tx ProofVerifier
// REFUSES groth16/plonk/bulletproofs and accepts ONLY the post-quantum
// STARK/FRI system (delegated to precompile/starkfri, which fails
// closed until the prover binding exists). Loading a real (non-dummy)
// bn254 verifying key on a strict-PQ chain is an ERROR. This is the
// Lux primary-network posture: a CRQC that breaks bn254 cannot forge a
// shield/unshield proof to mint or steal shielded value.
StrictPQ bool `serialize:"true" json:"strictPQ"`
// FHE configuration
EnableFHE bool `serialize:"true" json:"enableFHE"`
FHEScheme string `serialize:"true" json:"fheScheme"` // BFV, CKKS, etc.
SecurityLevel uint32 `serialize:"true" json:"securityLevel"` // 128, 192, 256
// Performance
MaxUTXOsPerBlock uint32 `serialize:"true" json:"maxUtxosPerBlock"`
ProofVerificationTimeout time.Duration `serialize:"true" json:"proofVerificationTimeout"`
ProofCacheSize uint32 `serialize:"true" json:"proofCacheSize"`
}
ZConfig contains VM configuration
type ZKProof ¶
type ZKProof struct {
ProofType string `json:"proofType"` // groth16, plonk, etc.
ProofData []byte `json:"proofData"`
PublicInputs [][]byte `json:"publicInputs"`
}
ZKProof represents a zero-knowledge proof
type ZWitnessAdapter ¶
type ZWitnessAdapter struct {
// contains filtered or unexported fields
}
ZWitnessAdapter adapts the Z-Chain MLDSAStark prover to the consensus ZWitnessProducer interface used by the Quasar round driver.
TODO(pqz-circuit): implement the MLDSAStark rollup AIR (Goldilocks) and add a `p3q_prove` C ABI to ~/work/lux/p3q, then integrate the prover here. Until then Witness returns ErrZWitnessNotImplemented and the round driver finalizes at the next lower witness level (PolicyQuorum or PolicyPQ). The verifier side is already STARK/FRI.
func NewZWitnessAdapter ¶
func NewZWitnessAdapter(vm *VM) *ZWitnessAdapter
NewZWitnessAdapter constructs a Z-witness adapter backed by the given Z-Chain VM.
func (*ZWitnessAdapter) Witness ¶
func (a *ZWitnessAdapter) Witness(ctx context.Context, digest [32]byte, validatorMLDSAPubs [][]byte) ([]byte, error)
Witness produces a post-quantum STARK / FRI proof aggregating per- validator ML-DSA-65 signatures over the round digest. Signature matches consensus/protocol/quasar.ZWitnessProducer.
validatorMLDSAPubs is the canonical ML-DSA-65 public-key list rooted in pchain_validator_root for the round; the STARK circuit takes this list as a public input.
Returns ErrZWitnessNotImplemented today (prover binding outstanding — see the package comment); the round driver treats this as the witness being unavailable and finalizes at the next-lower witness level. We do NOT return fabricated proof bytes: an unsound "proof" on the finality path would be a forgery oracle.