transaction

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilTx is returned if the transaction is nil.
	ErrNilTx = fmt.Errorf("nil transaction")
	// ErrInvalidURILength is returned if the entity URI length is invalid.
	ErrInvalidURILength = fmt.Errorf("invalid URI length")
	// ErrorAlreadyExistInCache is returned if the transaction has been already processed
	// and stored in the vote cache.
	ErrorAlreadyExistInCache = fmt.Errorf("transaction already exist in cache")
)

Functions

func VerifyProof

func VerifyProof(process *models.Process, proof *models.Proof, vID state.VoterID) (bool, *big.Int, error)

VerifyProof is a wrapper over all VerifyProofFunc(s) available which uses the process.CensusOrigin to execute the correct verification function.

func VerifyProofERC20

func VerifyProofERC20(process *models.Process, proof *models.Proof,
	_ models.CensusOrigin,
	censusRoot, _ []byte, vID state.VoterID) (bool, *big.Int, error)

VerifyProofERC20 verifies a proof with census origin ERC20 (mapbased). Returns verification result and weight.

func VerifyProofMiniMe

func VerifyProofMiniMe(process *models.Process, proof *models.Proof,
	_ models.CensusOrigin,
	censusRoot, _ []byte, vID state.VoterID) (bool, *big.Int, error)

VerifyProofMiniMe verifies a proof with census origin MiniMe. Returns verification result and weight.

func VerifyProofOffChainCSP

func VerifyProofOffChainCSP(_ *models.Process, proof *models.Proof,
	_ models.CensusOrigin,
	censusRoot, processID []byte, vID state.VoterID) (bool, *big.Int, error)

VerifyProofOffChainCSP verifies a proof with census origin OFF_CHAIN_CA. Returns verification result and weight.

func VerifyProofOffChainTree

func VerifyProofOffChainTree(_ *models.Process, proof *models.Proof,
	_ models.CensusOrigin,
	censusRoot, _ []byte, vID state.VoterID) (bool, *big.Int, error)

VerifyProofOffChainTree verifies a proof with census origin OFF_CHAIN_TREE. Returns verification result and weight.

Types

type TransactionHandler

type TransactionHandler struct {

	// ZkVKs contains the VerificationKey for each circuit parameters index
	ZkVKs []*snarkTypes.Vk
	// ZkCircuit contains the current chain circuit
	ZkCircuit *circuit.ZkCircuit
	// contains filtered or unexported fields
}

TransactionHandler holds the methods for checking the correctness of a transaction.

func NewTransactionHandler

func NewTransactionHandler(state *vstate.State, istc *ist.Controller, dataDir string) *TransactionHandler

NewTransactionHandler creates a new TransactionHandler.

func (*TransactionHandler) AdminTxCheck

func (t *TransactionHandler) AdminTxCheck(vtx *vochaintx.Tx) (ethereum.Address, error)

AdminTxCheck is an abstraction of ABCI checkTx for an admin transaction

func (*TransactionHandler) CheckTx

func (t *TransactionHandler) CheckTx(vtx *vochaintx.Tx, forCommit bool) (*TransactionResponse, error)

CheckTx check the validity of a transaction and adds it to the state if forCommit=true. It returns a bytes value which depends on the transaction type:

Tx_Vote: vote nullifier
default: []byte{}

func (*TransactionHandler) CollectFaucetTxCheck

func (t *TransactionHandler) CollectFaucetTxCheck(vtx *vochaintx.Tx) error

CollectFaucetTxCheck checks if a CollectFaucetTx and its data are valid

func (*TransactionHandler) CreateAccountTxCheck

func (t *TransactionHandler) CreateAccountTxCheck(vtx *vochaintx.Tx) error

CreateAccountTxCheck checks if an account creation tx is valid

func (*TransactionHandler) DelSIKTxCheck added in v1.9.0

func (t *TransactionHandler) DelSIKTxCheck(vtx *vochaintx.Tx) (common.Address, error)

DelSIKTxCheck checks if a delete SIK tx is valid

func (*TransactionHandler) ExtractNonceAndSender added in v1.10.0

func (t *TransactionHandler) ExtractNonceAndSender(vtx *vochaintx.Tx) (*common.Address, uint32, error)

ExtractNonceAndSender extracts the nonce and sender address from a given Vochain transaction. The function uses the signature of the transaction to derive the sender's public key and subsequently the Ethereum address. The nonce is extracted based on the specific payload type of the transaction. If the transaction does not contain signature or nonce, it returns the default values (nil and 0).

func (*TransactionHandler) LoadZkCircuit

func (t *TransactionHandler) LoadZkCircuit(configTag string) error

func (*TransactionHandler) NewProcessTxCheck

func (t *TransactionHandler) NewProcessTxCheck(vtx *vochaintx.Tx) (*models.Process, ethereum.Address, error)

NewProcessTxCheck is an abstraction of ABCI checkTx for creating a new process

func (*TransactionHandler) RegisterSIKTxCheck added in v1.9.0

func (t *TransactionHandler) RegisterSIKTxCheck(vtx *vochaintx.Tx) (common.Address, vstate.SIK, []byte, bool, error)

RegisterSIKTxCheck checks if the provided RegisterSIKTx is valid ensuring that the proof included on it is valid for the address of the transaction signer.

func (*TransactionHandler) SendTokensTxCheck

func (t *TransactionHandler) SendTokensTxCheck(vtx *vochaintx.Tx) error

SendTokensTxCheck checks if a given SendTokensTx and its data are valid

func (*TransactionHandler) SetAccountDelegateTxCheck

func (t *TransactionHandler) SetAccountDelegateTxCheck(vtx *vochaintx.Tx) error

SetAccountDelegateTxCheck checks if a SetAccountDelegateTx and its data are valid

func (*TransactionHandler) SetAccountInfoTxCheck

func (t *TransactionHandler) SetAccountInfoTxCheck(vtx *vochaintx.Tx) error

SetAccountInfoTxCheck checks if a set account info tx is valid

func (*TransactionHandler) SetAccountValidatorTxCheck added in v1.10.0

func (t *TransactionHandler) SetAccountValidatorTxCheck(vtx *vochaintx.Tx) error

SetAccountValidatorTxCheck upgrades an account to a validator.

func (*TransactionHandler) SetProcessTxCheck

func (t *TransactionHandler) SetProcessTxCheck(vtx *vochaintx.Tx) (ethereum.Address, error)

SetProcessTxCheck is an abstraction of ABCI checkTx for canceling an existing process

func (*TransactionHandler) SetSIKTxCheck added in v1.9.0

func (t *TransactionHandler) SetSIKTxCheck(vtx *vochaintx.Tx) (common.Address, vstate.SIK, error)

SetSIKTxCheck checks if a set SIK tx is valid and it is if the current address has not a SIK registered or the SIK registered had been already deleted.

func (*TransactionHandler) VoteTxCheck

func (t *TransactionHandler) VoteTxCheck(vtx *vochaintx.Tx, forCommit bool) (*vstate.Vote, error)

VoteTxCheck performs basic checks on a vote transaction.

type TransactionResponse

type TransactionResponse struct {
	TxHash []byte
	Data   []byte
	Log    string
}

TransactionResponse is the response of a transaction check.

type VerifyProofFunc

type VerifyProofFunc func(process *models.Process, proof *models.Proof,
	censusOrigin models.CensusOrigin,
	censusRoot, processID []byte, vID state.VoterID) (bool, *big.Int, error)

VerifyProofFunc is the generic function type to verify a proof of belonging into a census within a process.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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