transaction

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: AGPL-3.0 Imports: 28 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("vote already exist in cache")
)

Functions

func VerifyProof

func VerifyProof(process *models.Process, proof *models.Proof,
	censusOrigin models.CensusOrigin,
	censusRoot, processID, pubKey []byte, addr ethcommon.Address) (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,
	censusOrigin models.CensusOrigin,
	censusRoot, processID, pubKey []byte, addr ethcommon.Address) (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,
	censusOrigin models.CensusOrigin,
	censusRoot, processID, pubKey []byte, addr ethcommon.Address) (bool, *big.Int, error)

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

func VerifyProofOffChainCSP

func VerifyProofOffChainCSP(process *models.Process, proof *models.Proof,
	censusOrigin models.CensusOrigin,
	censusRoot, processID, pubKey []byte, addr ethcommon.Address) (bool, *big.Int, error)

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

func VerifyProofOffChainTree

func VerifyProofOffChainTree(process *models.Process, proof *models.Proof,
	censusOrigin models.CensusOrigin,
	censusRoot, processID, pubKey []byte, addr ethcommon.Address) (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 *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, dataDir string) (*TransactionHandler, error)

NewTransactionHandler creates a new TransactionHandler.

func (*TransactionHandler) AdminTxCheck

func (t *TransactionHandler) AdminTxCheck(vtx *vochaintx.VochainTx) (common.Address, error)

AdminTxCheck is an abstraction of ABCI checkTx for an admin transaction

func (*TransactionHandler) CheckTx

func (t *TransactionHandler) CheckTx(vtx *vochaintx.VochainTx, 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.VochainTx) error

CollectFaucetTxCheck checks if a CollectFaucetTx and its data are valid

func (*TransactionHandler) CreateAccountTxCheck

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

CreateAccountTxCheck checks if an account creation tx is valid

func (*TransactionHandler) LoadZkCircuit

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

func (*TransactionHandler) MintTokensTxCheck

func (t *TransactionHandler) MintTokensTxCheck(vtx *vochaintx.VochainTx) error

MintTokensTxCheck checks if a given MintTokensTx and its data are valid

func (*TransactionHandler) NewProcessTxCheck

func (t *TransactionHandler) NewProcessTxCheck(vtx *vochaintx.VochainTx,
	forCommit bool) (*models.Process, common.Address, error)

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

func (*TransactionHandler) RegisterKeyTxCheck

func (t *TransactionHandler) RegisterKeyTxCheck(vtx *vochaintx.VochainTx, forCommit bool) error

RegisterKeyTxCheck validates a registerKeyTx transaction against the state

func (*TransactionHandler) SendTokensTxCheck

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

SendTokensTxCheck checks if a given SendTokensTx and its data are valid

func (*TransactionHandler) SetAccountDelegateTxCheck

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

SetAccountDelegateTxCheck checks if a SetAccountDelegateTx and its data are valid

func (*TransactionHandler) SetAccountInfoTxCheck

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

SetAccountInfoTxCheck checks if a set account info tx is valid

func (*TransactionHandler) SetProcessTxCheck

func (t *TransactionHandler) SetProcessTxCheck(vtx *vochaintx.VochainTx, forCommit bool) (common.Address, error)

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

func (*TransactionHandler) SetTransactionCostsTxCheck

func (t *TransactionHandler) SetTransactionCostsTxCheck(vtx *vochaintx.VochainTx) (uint64, error)

SetTransactionCostsTxCheck is an abstraction of ABCI checkTx for a SetTransactionCosts transaction

func (*TransactionHandler) VoteTxCheck

func (t *TransactionHandler) VoteTxCheck(vtx *vochaintx.VochainTx, 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, pubKey []byte, addr ethcommon.Address) (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