Documentation
¶
Overview ¶
Package zchain provides the Z-Chain (Privacy) adapter for DAG indexing. Z-Chain uses DAG consensus for fast finality combined with ZK proofs for privacy.
Index ¶
- Constants
- func DefaultConfig() dag.Config
- func ValidateCommitmentHash(hash string) error
- func ValidateNullifierHash(hash string) error
- type Adapter
- func (a *Adapter) GetCommitment(ctx context.Context, hash string) (*Commitment, error)
- func (a *Adapter) GetMerkleRoot(ctx context.Context) (string, error)
- func (a *Adapter) GetNullifier(ctx context.Context, hash string) (*Nullifier, error)
- func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)
- func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
- func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)
- func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error
- func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)
- func (a *Adapter) StoreTransfer(ctx context.Context, store storage.Store, t ShieldedTransfer, vertexID string) error
- func (a *Adapter) UpdateExtendedStats(ctx context.Context, store storage.Store) error
- func (a *Adapter) VerifyProof(ctx context.Context, proof ZKProof) (bool, error)
- type Commitment
- type Nullifier
- type ProofType
- type RPCError
- type RPCRequest
- type RPCResponse
- type ShieldedTransfer
- type VertexData
- type ZKProof
- type ZKTransactionType
Constants ¶
const ( // DefaultRPCEndpoint for Z-Chain DefaultRPCEndpoint = "http://localhost:9650/ext/bc/Z/rpc" // DefaultHTTPPort for Z-Chain indexer API DefaultHTTPPort = 4400 // DefaultDatabase for Z-Chain explorer DefaultDatabase = "explorer_zchain" // RPCMethod prefix for Z-Chain RPCMethod = "zvm" )
Variables ¶
This section is empty.
Functions ¶
func DefaultConfig ¶
DefaultConfig returns the default configuration for Z-Chain indexer
func ValidateCommitmentHash ¶
ValidateCommitmentHash validates a commitment hash format
func ValidateNullifierHash ¶
ValidateNullifierHash validates a nullifier hash format
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements dag.Adapter for Z-Chain
func (*Adapter) GetCommitment ¶
GetCommitment fetches commitment status
func (*Adapter) GetMerkleRoot ¶
GetMerkleRoot fetches the current commitment tree root
func (*Adapter) GetNullifier ¶
GetNullifier fetches nullifier status
func (*Adapter) GetRecentVertices ¶
GetRecentVertices fetches recent vertices from RPC
func (*Adapter) GetStats ¶
func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
GetStats returns Z-Chain specific statistics
func (*Adapter) GetVertexByID ¶
GetVertexByID fetches a specific vertex
func (*Adapter) InitSchema ¶
InitSchema creates Z-Chain specific database tables
func (*Adapter) ParseVertex ¶
ParseVertex parses RPC response into a DAG vertex
func (*Adapter) StoreTransfer ¶
func (a *Adapter) StoreTransfer(ctx context.Context, store storage.Store, t ShieldedTransfer, vertexID string) error
StoreTransfer stores a shielded transfer and its components
func (*Adapter) UpdateExtendedStats ¶
UpdateExtendedStats updates Z-Chain specific statistics
type Commitment ¶
type Commitment struct {
Hash string `json:"hash"`
TxID string `json:"txId"`
Index int `json:"index"`
CreatedAt int64 `json:"createdAt,omitempty"` // Vertex height
Spent bool `json:"spent"`
}
Commitment represents a shielded note commitment
type Nullifier ¶
type Nullifier struct {
Hash string `json:"hash"`
TxID string `json:"txId"`
Index int `json:"index"`
SpentAt int64 `json:"spentAt,omitempty"` // Vertex height
}
Nullifier represents a spent note marker (prevents double-spending)
type RPCRequest ¶
type RPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Method string `json:"method"`
Params []interface{} `json:"params,omitempty"`
}
RPCRequest for JSON-RPC calls
type RPCResponse ¶
type RPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
RPCResponse from JSON-RPC calls
type ShieldedTransfer ¶
type ShieldedTransfer struct {
TxID string `json:"txId"`
Type ZKTransactionType `json:"type"`
Proof ZKProof `json:"proof"`
Nullifiers []Nullifier `json:"nullifiers"`
Commitments []Commitment `json:"commitments"`
ValueBalance int64 `json:"valueBalance,omitempty"` // Net flow for shield/unshield
Fee uint64 `json:"fee"`
Memo string `json:"memo,omitempty"` // Encrypted memo
Timestamp time.Time `json:"timestamp"`
}
ShieldedTransfer represents a private transfer
type VertexData ¶
type VertexData struct {
Transfers []ShieldedTransfer `json:"transfers,omitempty"`
MerkleRoot string `json:"merkleRoot"` // Commitment tree root
NullifierRoot string `json:"nullifierRoot"` // Nullifier set root
Epoch uint32 `json:"epoch"`
Proposer string `json:"proposer,omitempty"`
}
VertexData holds Z-Chain specific vertex payload
type ZKProof ¶
type ZKProof struct {
Type ProofType `json:"type"`
Data string `json:"data"` // Hex-encoded proof bytes
PublicInputs []string `json:"publicInputs,omitempty"`
VerifyingKey string `json:"verifyingKey,omitempty"`
}
ZKProof represents a zero-knowledge proof
type ZKTransactionType ¶
type ZKTransactionType string
ZKTransactionType identifies privacy transaction types
const ( TxShieldedTransfer ZKTransactionType = "shielded_transfer" TxShield ZKTransactionType = "shield" // Deposit: transparent -> shielded TxUnshield ZKTransactionType = "unshield" // Withdraw: shielded -> transparent TxJoinSplit ZKTransactionType = "joinsplit" TxMint ZKTransactionType = "mint" TxBurn ZKTransactionType = "burn" )