zkvm

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "zkvm"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

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

Block represents a block in the ZK Chain

func (*Block) Accept

func (b *Block) Accept() error

Accept implements the snowman.Block interface

func (*Block) Bytes

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

Bytes implements the snowman.Block interface

func (*Block) Height

func (b *Block) Height() uint64

Height implements the snowman.Block interface

func (*Block) ID

func (b *Block) ID() string

ID implements the snowman.Block interface

func (*Block) Parent

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

Parent implements the snowman.Block interface

func (*Block) Reject

func (b *Block) Reject() error

Reject implements the snowman.Block interface

func (*Block) Status

func (b *Block) Status() choices.Status

Status implements the snowman.Block interface

func (*Block) Time

func (b *Block) Time() uint64

Time implements the snowman.Block interface

func (*Block) Verify

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

Verify implements the snowman.Block interface

type Challenge

type Challenge struct {
	ID            ids.ID          `json:"id"`
	Type          ChallengeType   `json:"type"`
	TargetChain   ids.ID          `json:"targetChain"`
	TargetBlock   ids.ID          `json:"targetBlock"`
	TargetTx      ids.ID          `json:"targetTx,omitempty"`
	Challenger    ids.ShortID     `json:"challenger"`
	Defender      ids.ShortID     `json:"defender"`
	Status        ChallengeStatus `json:"status"`
	CreatedAt     int64           `json:"createdAt"`
	ResolvedAt    int64           `json:"resolvedAt,omitempty"`
	Evidence      []byte          `json:"evidence"`
	DefenderProof []byte          `json:"defenderProof,omitempty"`
	Resolution    []byte          `json:"resolution,omitempty"`
}

Challenge represents a fraud proof challenge

type ChallengeStatus

type ChallengeStatus uint8

ChallengeStatus represents the status of a challenge

const (
	ChallengePending ChallengeStatus = iota
	ChallengeActive
	ChallengeResolved
	ChallengeExpired
)

type ChallengeType

type ChallengeType uint8

ChallengeType represents the type of challenge

const (
	ChallengeStateRoot ChallengeType = iota
	ChallengeTransaction
	ChallengeComputation
)

type ChallengeUpdate

type ChallengeUpdate struct {
	ChallengeID   ids.ID          `json:"challengeId"`
	NewStatus     ChallengeStatus `json:"newStatus"`
	DefenderProof []byte          `json:"defenderProof,omitempty"`
	Resolution    []byte          `json:"resolution,omitempty"`
}

ChallengeUpdate represents an update to a challenge

type Factory

type Factory struct{}

Factory creates new instances of the ZK VM

func (*Factory) New

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

New returns a new instance of the ZK VM

type FraudProof

type FraudProof struct {
	ID             ids.ID `json:"id"`
	StateRoot      ids.ID `json:"stateRoot"`
	DisputedTx     ids.ID `json:"disputedTx"`
	PreState       []byte `json:"preState"`
	PostState      []byte `json:"postState"`
	ExecutionTrace []byte `json:"executionTrace"`
	WitnessData    []byte `json:"witnessData"`
}

FraudProof represents a fraud proof for optimistic rollup

type PrivacyAction

type PrivacyAction struct {
	Type       PrivacyActionType `json:"type"`
	Commitment ethcommon.Hash    `json:"commitment,omitempty"`
	Nullifier  ethcommon.Hash    `json:"nullifier,omitempty"`
	Amount     uint64            `json:"amount,omitempty"`
	Proof      []byte            `json:"proof"`
}

PrivacyAction represents a privacy-related action

type PrivacyActionType

type PrivacyActionType uint8

PrivacyActionType represents the type of privacy action

const (
	Shield PrivacyActionType = iota
	Unshield
	Transfer
)

type ShieldedPool

type ShieldedPool struct {
	TotalSupply uint64                  `json:"totalSupply"`
	Notes       map[ethcommon.Hash]bool `json:"notes"`
	Commitments []ethcommon.Hash        `json:"commitments"`
}

ShieldedPool represents the privacy pool

type VM

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

VM implements the chain.ChainVM interface for the Zero-Knowledge Chain (Z-Chain) This chain provides ZK proof verification and fraud proof processing

func (*VM) AppGossip

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

AppGossip implements the core.AppHandler 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 core.AppHandler interface

func (*VM) AppRequestFailed

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

AppRequestFailed implements the core.AppHandler interface

func (*VM) AppResponse

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

AppResponse implements the core.AppHandler interface

func (*VM) BuildBlock

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

BuildBlock implements the chain.ChainVM interface

func (*VM) Connected

func (vm *VM) Connected(ctx context.Context, nodeID ids.NodeID, nodeVersion *version.Application) error

Connected implements the validators.Connector interface

func (*VM) CreateHandlers

func (vm *VM) CreateHandlers(context.Context) (map[string]interface{}, error)

CreateHandlers implements the core.VM interface

func (*VM) CreateStaticHandlers

func (vm *VM) CreateStaticHandlers(context.Context) (map[string]interface{}, error)

CreateStaticHandlers implements the core.VM interface

func (*VM) CrossChainAppRequest

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

CrossChainAppRequest implements the core.VM interface

func (*VM) CrossChainAppRequestFailed

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

CrossChainAppRequestFailed implements the core.VM interface

func (*VM) CrossChainAppResponse

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

CrossChainAppResponse implements the core.VM interface

func (*VM) Disconnected

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

Disconnected implements the validators.Connector interface

func (*VM) GetBlock

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

GetBlock implements the chain.ChainVM interface

func (*VM) GetBlockIDAtHeight

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

GetBlockIDAtHeight implements the chain.ChainVM interface

func (*VM) HealthCheck

func (vm *VM) HealthCheck(context.Context) (any, error)

HealthCheck implements the health.Checker interface

func (*VM) Initialize

func (vm *VM) Initialize(
	ctx context.Context,
	chainCtx *core.Context,
	db interface{},
	genesisBytes []byte,
	upgradeBytes []byte,
	configBytes []byte,
	toEngine chan<- core.Message,
	fxs []*core.Fx,
	appSender core.AppSender,
) error

Initialize implements the core.VM interface

func (*VM) LastAccepted

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

LastAccepted implements the chain.ChainVM interface

func (*VM) ParseBlock

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

ParseBlock implements the chain.ChainVM interface

func (*VM) SetPreference

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

SetPreference implements the chain.ChainVM interface

func (*VM) SetState

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

SetState implements the core.VM interface

func (*VM) Shutdown

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

Shutdown implements the core.VM interface

func (*VM) StartChallenge

func (vm *VM) StartChallenge(challenge *Challenge) error

StartChallenge starts a new fraud proof challenge

func (*VM) VerifyZKProof

func (vm *VM) VerifyZKProof(proof *ZKProof) error

VerifyZKProof verifies a zero-knowledge proof

func (*VM) Version

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

Version implements the core.VM interface

type VerifierKey

type VerifierKey struct {
	ID          string `json:"id"`
	CircuitType string `json:"circuitType"`
	Key         []byte `json:"key"`
	Parameters  []byte `json:"parameters"`
}

VerifierKey represents a ZK verifier key

type ZKProof

type ZKProof struct {
	ID           ids.ID `json:"id"`
	ProofType    string `json:"proofType"`
	PublicInputs []byte `json:"publicInputs"`
	Proof        []byte `json:"proof"`
	VerifierKey  string `json:"verifierKey"`
	Verified     bool   `json:"verified"`
	SubmittedAt  int64  `json:"submittedAt"`
}

ZKProof represents a zero-knowledge proof

Jump to

Keyboard shortcuts

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