zvm

package
v1.22.78 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = &version.Semantic{
		Major: 1,
		Minor: 0,
		Patch: 0,
	}
)

Functions

func ComputeCommitment added in v1.16.56

func ComputeCommitment(note *Note) []byte

ComputeCommitment computes a note commitment

func ComputeNullifier added in v1.16.56

func ComputeNullifier(note *Note, spendingKey []byte) []byte

ComputeNullifier computes a nullifier for a note

func EncryptNote added in v1.16.56

func EncryptNote(note *Note, recipientPubKey []byte, ephemeralPrivKey []byte) ([]byte, []byte, error)

EncryptNote encrypts a note for the recipient using ChaCha20-Poly1305

func NewPrivacyHandler added in v1.16.56

func NewPrivacyHandler(vm *VM) http.Handler

NewPrivacyHandler creates the privacy-specific handler

func NewProofHandler added in v1.16.56

func NewProofHandler(vm *VM) http.Handler

NewProofHandler creates the proof-specific handler

func NewRPCHandler added in v1.16.56

func NewRPCHandler(vm *VM) http.Handler

NewRPCHandler creates the main RPC handler

Types

type AddressManager added in v1.16.56

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

AddressManager manages private addresses and viewing keys

func NewAddressManager added in v1.16.56

func NewAddressManager(db database.Database, enablePrivate bool, log log.Logger) (*AddressManager, error)

NewAddressManager creates a new address manager

func (*AddressManager) CanDecryptNote added in v1.16.56

func (am *AddressManager) CanDecryptNote(ephemeralPubKey []byte, address []byte) bool

CanDecryptNote checks if we have the keys to decrypt a note

func (*AddressManager) Close added in v1.16.56

func (am *AddressManager) Close()

Close closes the address manager

func (*AddressManager) DeriveNullifier added in v1.16.56

func (am *AddressManager) DeriveNullifier(address []byte, note *Note) ([]byte, error)

DeriveNullifier derives a nullifier using the spending key

func (*AddressManager) GenerateAddress added in v1.16.56

func (am *AddressManager) GenerateAddress() (*PrivateAddress, error)

GenerateAddress generates a new private address

func (*AddressManager) GetAddress added in v1.16.56

func (am *AddressManager) GetAddress(address []byte) (*PrivateAddress, error)

GetAddress retrieves an address by its public address

func (*AddressManager) GetAddressCount added in v1.16.56

func (am *AddressManager) GetAddressCount() uint64

GetAddressCount returns the total number of addresses

func (*AddressManager) GetAddressesByViewingKey added in v1.16.56

func (am *AddressManager) GetAddressesByViewingKey(viewingKey []byte) ([]*PrivateAddress, error)

GetAddressesByViewingKey returns all addresses associated with a viewing key

func (*AddressManager) SignTransaction added in v1.16.56

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) Accept

func (b *Block) Accept(ctx context.Context) error

Accept accepts the block

func (*Block) Bytes

func (b *Block) Bytes() []byte

Bytes returns the block bytes

func (*Block) Height

func (b *Block) Height() uint64

Height returns the block height

func (*Block) ID

func (b *Block) ID() ids.ID

ID returns the block ID

func (*Block) Parent

func (b *Block) Parent() ids.ID

Parent is an alias for ParentID for compatibility

func (*Block) ParentID added in v1.16.56

func (b *Block) ParentID() ids.ID

ParentID returns the parent block ID

func (*Block) Reject

func (b *Block) Reject(ctx context.Context) error

Reject rejects the block

func (*Block) Status

func (b *Block) Status() uint8

Status returns the block status

func (*Block) Timestamp added in v1.16.56

func (b *Block) Timestamp() time.Time

Timestamp returns the block timestamp

func (*Block) ToSummary added in v1.16.56

func (b *Block) ToSummary() *BlockSummary

ToSummary converts a block to a summary

func (*Block) Verify

func (b *Block) Verify(ctx context.Context) error

Verify verifies the block

type BlockSummary added in v1.16.56

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 BulletproofRangeProof added in v1.22.78

type BulletproofRangeProof struct {
	// Pedersen commitment components
	A bn254.G1Affine // Vector commitment
	S bn254.G1Affine // Blinding commitment

	// Polynomial commitments
	T1 bn254.G1Affine // Polynomial commitment T1
	T2 bn254.G1Affine // Polynomial commitment T2

	// Proof scalars
	Taux fr.Element // Blinding factor for T
	Mu   fr.Element // Blinding factor for inner product
	Tx   fr.Element // Evaluation t(x)

	// Inner product proof components
	L  []bn254.G1Affine // Left inner product commitments
	R  []bn254.G1Affine // Right inner product commitments
	A0 fr.Element       // Final scalar a
	B0 fr.Element       // Final scalar b
}

BulletproofRangeProof represents a Bulletproof range proof structure

type FHEData added in v1.16.56

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 added in v1.16.56

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

FHEProcessor handles fully homomorphic encryption operations

func NewFHEProcessor added in v1.16.56

func NewFHEProcessor(config ZConfig, log log.Logger) (*FHEProcessor, error)

NewFHEProcessor creates a new FHE processor

func (*FHEProcessor) AddCiphertexts added in v1.16.56

func (fp *FHEProcessor) AddCiphertexts(ct1, ct2 []byte) ([]byte, error)

AddCiphertexts performs homomorphic addition

func (*FHEProcessor) DecryptValue added in v1.16.56

func (fp *FHEProcessor) DecryptValue(ciphertext []byte, privateKey []byte) (uint64, error)

DecryptValue decrypts an FHE ciphertext

func (*FHEProcessor) EncryptValue added in v1.16.56

func (fp *FHEProcessor) EncryptValue(value uint64) ([]byte, error)

EncryptValue encrypts a value using FHE

func (*FHEProcessor) GetStats added in v1.16.56

func (fp *FHEProcessor) GetStats() uint64

GetStats returns FHE processing statistics

func (*FHEProcessor) MultiplyCiphertext added in v1.16.56

func (fp *FHEProcessor) MultiplyCiphertext(ct []byte, scalar uint64) ([]byte, error)

MultiplyCiphertext performs homomorphic multiplication by a plaintext

func (*FHEProcessor) ProcessFHEComputation added in v1.16.56

func (fp *FHEProcessor) ProcessFHEComputation(
	circuitID string,
	encryptedInputs [][]byte,
) ([]byte, []byte, error)

ProcessFHEComputation performs an FHE computation

func (*FHEProcessor) VerifyFHEOperations added in v1.16.56

func (fp *FHEProcessor) VerifyFHEOperations(tx *Transaction) error

VerifyFHEOperations verifies FHE operations in a transaction

type FRILayer added in v1.22.78

type FRILayer struct {
	Commitment []byte // Merkle root
	Alpha      []byte // Folding challenge
}

FRILayer represents a single FRI fold layer

type Factory

type Factory struct{}

Factory ...

func (*Factory) New

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

New implements vms.Factory

type Genesis added in v1.16.56

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 added in v1.16.56

func ParseGenesis(genesisBytes []byte) (*Genesis, error)

ParseGenesis parses genesis bytes

type Groth16Proof added in v1.22.76

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 added in v1.22.76

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 added in v1.16.56

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 added in v1.16.56

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

Mempool manages pending transactions

func NewMempool added in v1.16.56

func NewMempool(maxSize int, log log.Logger) *Mempool

NewMempool creates a new mempool

func (*Mempool) AddTransaction added in v1.16.56

func (mp *Mempool) AddTransaction(tx *Transaction) error

AddTransaction adds a transaction to the mempool

func (*Mempool) Clear added in v1.16.56

func (mp *Mempool) Clear()

Clear removes all transactions from the mempool

func (*Mempool) GetPendingTransactions added in v1.16.56

func (mp *Mempool) GetPendingTransactions(limit int) []*Transaction

GetPendingTransactions returns pending transactions sorted by priority

func (*Mempool) HasNullifier added in v1.16.56

func (mp *Mempool) HasNullifier(nullifier []byte) bool

HasNullifier checks if a nullifier is already in the mempool

func (*Mempool) HasTransaction added in v1.16.56

func (mp *Mempool) HasTransaction(txID ids.ID) bool

HasTransaction checks if a transaction is in the mempool

func (*Mempool) PruneExpired added in v1.16.56

func (mp *Mempool) PruneExpired(currentHeight uint64)

PruneExpired removes expired transactions

func (*Mempool) RemoveTransaction added in v1.16.56

func (mp *Mempool) RemoveTransaction(txID ids.ID)

RemoveTransaction removes a transaction from the mempool

func (*Mempool) Size added in v1.16.56

func (mp *Mempool) Size() int

Size returns the number of transactions in the mempool

type MempoolTx added in v1.16.56

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

MempoolTx represents a transaction in the mempool

type Note added in v1.16.56

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)

func DecryptNote added in v1.16.56

func DecryptNote(encryptedNote []byte, ephemeralPubKey []byte, recipientPrivKey []byte) (*Note, error)

DecryptNote decrypts a note using the recipient's key and ChaCha20-Poly1305

type NullifierDB added in v1.16.56

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

NullifierDB manages spent nullifiers

func NewNullifierDB added in v1.16.56

func NewNullifierDB(db database.Database, log log.Logger) (*NullifierDB, error)

NewNullifierDB creates a new nullifier database

func (*NullifierDB) Close added in v1.16.56

func (ndb *NullifierDB) Close()

Close closes the nullifier database

func (*NullifierDB) GetNullifierCount added in v1.16.56

func (ndb *NullifierDB) GetNullifierCount() uint64

GetNullifierCount returns the total number of spent nullifiers

func (*NullifierDB) GetNullifierHeight added in v1.16.56

func (ndb *NullifierDB) GetNullifierHeight(nullifier []byte) (uint64, error)

GetNullifierHeight returns the height when a nullifier was spent

func (*NullifierDB) GetNullifiersByHeight added in v1.16.56

func (ndb *NullifierDB) GetNullifiersByHeight(height uint64) [][]byte

GetNullifiersByHeight returns all nullifiers spent at a specific height

func (*NullifierDB) IsNullifierSpent added in v1.16.56

func (ndb *NullifierDB) IsNullifierSpent(nullifier []byte) bool

IsNullifierSpent checks if a nullifier has been spent

func (*NullifierDB) MarkNullifierSpent added in v1.16.56

func (ndb *NullifierDB) MarkNullifierSpent(nullifier []byte, height uint64) error

MarkNullifierSpent marks a nullifier as spent

func (*NullifierDB) PruneOldNullifiers added in v1.16.56

func (ndb *NullifierDB) PruneOldNullifiers(minHeight uint64) error

PruneOldNullifiers removes nullifiers older than a certain height

func (*NullifierDB) RemoveNullifier added in v1.16.56

func (ndb *NullifierDB) RemoveNullifier(nullifier []byte) error

RemoveNullifier removes a nullifier (used for reorg)

type PLONKProof added in v1.22.78

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 added in v1.22.78

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 added in v1.16.56

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 added in v1.16.56

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

ProofVerifier verifies zero-knowledge proofs

func NewProofVerifier added in v1.16.56

func NewProofVerifier(config ZConfig, log log.Logger) (*ProofVerifier, error)

NewProofVerifier creates a new proof verifier

func (*ProofVerifier) ClearCache added in v1.16.56

func (pv *ProofVerifier) ClearCache()

ClearCache clears the proof verification cache

func (*ProofVerifier) GetCacheSize added in v1.16.56

func (pv *ProofVerifier) GetCacheSize() int

GetCacheSize returns the current size of the proof cache

func (*ProofVerifier) GetStats added in v1.16.56

func (pv *ProofVerifier) GetStats() (verifyCount, cacheHits, cacheMisses uint64)

GetStats returns verifier statistics

func (*ProofVerifier) VerifyBlockProof added in v1.16.56

func (pv *ProofVerifier) VerifyBlockProof(block *Block) error

VerifyBlockProof verifies an aggregated block proof

func (*ProofVerifier) VerifyTransactionProof added in v1.16.56

func (pv *ProofVerifier) VerifyTransactionProof(tx *Transaction) error

VerifyTransactionProof verifies a transaction's zero-knowledge proof

type QueryResponse added in v1.22.78

type QueryResponse struct {
	Index      uint64
	Values     [][]byte
	MerklePath [][]byte
}

QueryResponse represents a query response with Merkle authentication

type STARKProof added in v1.22.78

type STARKProof struct {
	// FRI layers (log2(trace_length) layers)
	FRILayers []FRILayer

	// Trace commitments
	TraceCommitment       []byte
	CompositionCommitment []byte

	// Query responses
	QueryResponses []QueryResponse

	// Out-of-domain samples
	OODTraceValues      [][]byte
	OODConstraintValues [][]byte
}

STARKProof represents a STARK proof structure

type SetupParams added in v1.16.56

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 added in v1.16.56

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 added in v1.16.56

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

StateTree manages a sparse Merkle tree of the UTXO set

func NewStateTree added in v1.16.56

func NewStateTree(db database.Database, log log.Logger) (*StateTree, error)

NewStateTree creates a new sparse Merkle tree

func (*StateTree) ApplyTransaction added in v1.16.56

func (st *StateTree) ApplyTransaction(tx *Transaction) error

ApplyTransaction applies a transaction to the state tree

func (*StateTree) Close added in v1.16.56

func (st *StateTree) Close()

Close closes the state tree

func (*StateTree) ComputeRoot added in v1.16.56

func (st *StateTree) ComputeRoot() ([]byte, error)

ComputeRoot computes the new Merkle root after pending changes

func (*StateTree) Finalize added in v1.16.56

func (st *StateTree) Finalize(newRoot []byte) error

Finalize commits the pending changes and updates the root

func (*StateTree) GetMerkleProof added in v1.16.56

func (st *StateTree) GetMerkleProof(commitment []byte) ([][]byte, error)

GetMerkleProof generates a Merkle proof for a commitment in the sparse Merkle tree

func (*StateTree) GetRoot added in v1.16.56

func (st *StateTree) GetRoot() []byte

GetRoot returns the current state root

func (*StateTree) VerifyMerkleProof added in v1.16.56

func (st *StateTree) VerifyMerkleProof(commitment []byte, proof [][]byte, root []byte) bool

VerifyMerkleProof verifies a sparse Merkle proof

type Transaction added in v1.16.56

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 added in v1.16.56

func (tx *Transaction) ComputeID() ids.ID

ComputeID computes the transaction ID

func (*Transaction) GetNullifiers added in v1.16.56

func (tx *Transaction) GetNullifiers() [][]byte

GetNullifiers returns all nullifiers in the transaction

func (*Transaction) GetOutputCommitments added in v1.16.56

func (tx *Transaction) GetOutputCommitments() [][]byte

GetOutputCommitments returns all output commitments

func (*Transaction) HasFHEOperations added in v1.16.56

func (tx *Transaction) HasFHEOperations() bool

HasFHEOperations returns true if the transaction includes FHE operations

func (*Transaction) ValidateBasic added in v1.16.56

func (tx *Transaction) ValidateBasic() error

ValidateBasic performs basic validation

type TransactionType added in v1.16.56

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 added in v1.16.56

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 added in v1.16.56

type TransparentOutput struct {
	Amount  uint64 `json:"amount"`
	Address []byte `json:"address"`
	AssetID ids.ID `json:"assetId"`
}

TransparentOutput represents an unshielded output

type TxHeap added in v1.16.56

type TxHeap []*MempoolTx

TxHeap implements heap.Interface for priority ordering

func (TxHeap) Len added in v1.16.56

func (h TxHeap) Len() int

func (TxHeap) Less added in v1.16.56

func (h TxHeap) Less(i, j int) bool

func (*TxHeap) Pop added in v1.16.56

func (h *TxHeap) Pop() interface{}

func (*TxHeap) Push added in v1.16.56

func (h *TxHeap) Push(x interface{})

func (TxHeap) Swap added in v1.16.56

func (h TxHeap) Swap(i, j int)

type UTXO added in v1.16.56

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 added in v1.16.56

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

UTXODB manages the UTXO set

func NewUTXODB added in v1.16.56

func NewUTXODB(db database.Database, log log.Logger) (*UTXODB, error)

NewUTXODB creates a new UTXO database

func (*UTXODB) AddUTXO added in v1.16.56

func (udb *UTXODB) AddUTXO(utxo *UTXO) error

AddUTXO adds a new UTXO to the set

func (*UTXODB) Close added in v1.16.56

func (udb *UTXODB) Close()

Close closes the UTXO database

func (*UTXODB) GetAllCommitments added in v1.16.56

func (udb *UTXODB) GetAllCommitments() [][]byte

GetAllCommitments returns all UTXO commitments (for Merkle tree)

func (*UTXODB) GetUTXO added in v1.16.56

func (udb *UTXODB) GetUTXO(commitment []byte) (*UTXO, error)

GetUTXO retrieves a UTXO by commitment

func (*UTXODB) GetUTXOCount added in v1.16.56

func (udb *UTXODB) GetUTXOCount() uint64

GetUTXOCount returns the total number of UTXOs

func (*UTXODB) GetUTXOsByHeight added in v1.16.56

func (udb *UTXODB) GetUTXOsByHeight(height uint64) ([]*UTXO, error)

GetUTXOsByHeight returns all UTXOs created at a specific height

func (*UTXODB) PruneOldUTXOs added in v1.16.56

func (udb *UTXODB) PruneOldUTXOs(minHeight uint64) error

PruneOldUTXOs removes UTXOs older than a certain height

func (*UTXODB) RemoveUTXO added in v1.16.56

func (udb *UTXODB) RemoveUTXO(commitment []byte) error

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) AppGossip

func (vm *VM) AppGossip(ctx context.Context, nodeID ids.NodeID, msg []byte) error

AppGossip implements the common.VM interface

func (*VM) AppRequest

func (vm *VM) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte) error

AppRequest implements the common.VM interface

func (*VM) AppRequestFailed

func (vm *VM) AppRequestFailed(ctx context.Context, nodeID ids.NodeID, requestID uint32, appErr *warp.Error) error

AppRequestFailed implements the common.VM interface

func (*VM) AppResponse

func (vm *VM) AppResponse(ctx context.Context, nodeID ids.NodeID, requestID uint32, response []byte) error

AppResponse implements the common.VM interface

func (*VM) BuildBlock

func (vm *VM) BuildBlock(ctx context.Context) (block.Block, error)

BuildBlock builds a new block

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion interface{}) error

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error)

CreateHandlers returns the VM handlers

func (*VM) CrossChainAppRequest

func (vm *VM) CrossChainAppRequest(ctx context.Context, chainID ids.ID, requestID uint32, deadline time.Time, request []byte) error

CrossChainAppRequest implements the common.VM interface

func (*VM) CrossChainAppRequestFailed

func (vm *VM) CrossChainAppRequestFailed(ctx context.Context, chainID ids.ID, requestID uint32, appErr *warp.Error) error

CrossChainAppRequestFailed implements the common.VM interface

func (*VM) CrossChainAppResponse

func (vm *VM) CrossChainAppResponse(ctx context.Context, chainID ids.ID, requestID uint32, response []byte) error

CrossChainAppResponse implements the common.VM interface

func (*VM) Disconnected

func (vm *VM) Disconnected(ctx context.Context, nodeID ids.NodeID) error

func (*VM) GetBlock

func (vm *VM) GetBlock(ctx context.Context, blkID ids.ID) (block.Block, error)

GetBlock retrieves a block by ID

func (*VM) GetBlockIDAtHeight

func (vm *VM) GetBlockIDAtHeight(ctx context.Context, height uint64) (ids.ID, error)

GetBlockIDAtHeight implements the consensusman.HeightIndexedChainVM interface

func (*VM) HealthCheck

func (vm *VM) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck performs a health check

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtx interface{},
	db interface{},
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	msgChan interface{},
	fxs []interface{},
	appSender interface{},
) error

Initialize initializes the VM

func (*VM) LastAccepted

func (vm *VM) LastAccepted(ctx context.Context) (ids.ID, error)

func (*VM) NewHTTPHandler added in v1.16.56

func (vm *VM) NewHTTPHandler(ctx context.Context) (interface{}, error)

NewHTTPHandler returns HTTP handlers for the VM

func (*VM) ParseBlock

func (vm *VM) ParseBlock(ctx context.Context, blockBytes []byte) (block.Block, error)

ParseBlock parses a block from bytes

func (*VM) SetPreference

func (vm *VM) SetPreference(ctx context.Context, blkID ids.ID) error

Additional interface implementations

func (*VM) SetState

func (vm *VM) SetState(ctx context.Context, state uint32) error

SetState sets the VM state

func (*VM) Shutdown

func (vm *VM) Shutdown(ctx context.Context) error

Shutdown shuts down the VM

func (*VM) Version

func (vm *VM) Version(ctx context.Context) (string, error)

Version returns the VM version

func (*VM) WaitForEvent added in v1.16.56

func (vm *VM) WaitForEvent(ctx context.Context) (interface{}, error)

WaitForEvent blocks until an event occurs that should trigger block building

type ZConfig added in v1.16.56

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"`

	// 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"`
	// contains filtered or unexported fields
}

ZKProof represents a zero-knowledge proof

Directories

Path Synopsis
Package accel provides hardware acceleration for ZK operations.
Package accel provides hardware acceleration for ZK operations.
Package fhe provides Fully Homomorphic Encryption primitives for the Lux blockchain.
Package fhe provides Fully Homomorphic Encryption primitives for the Lux blockchain.

Jump to

Keyboard shortcuts

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