privatecompute

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package privatecompute is package for privatecompute

Index

Constants

View Source
const (
	// ComputeResult is used to combine store key for private compute system contract
	ComputeResult = "private_compute_result"
	// ContractByteHeader is used to combine store key for storing evm contract header
	ContractByteHeader = ":H:"
	// ContractByteCode is used to combine store key for storing evm contract code
	ContractByteCode = ":B:"
	// ContractVersion is used to combine store key for storing evm contract version
	ContractVersion = ":V:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ACProviderMock added in v2.3.0

type ACProviderMock struct {
}

ACProviderMock is ac provider mock

func (*ACProviderMock) CreatePrincipal added in v2.3.0

func (ac *ACProviderMock) CreatePrincipal(resourceName string, endorsements []*common.EndorsementEntry,
	message []byte) (protocol.Principal, error)

CreatePrincipal creates a principal for one time authentication

func (*ACProviderMock) CreatePrincipalForTargetOrg added in v2.3.0

func (ac *ACProviderMock) CreatePrincipalForTargetOrg(resourceName string, endorsements []*common.EndorsementEntry,
	message []byte, targetOrgId string) (protocol.Principal, error)

CreatePrincipalForTargetOrg creates a principal for "SELF" type policy, which needs to convert SELF to a sepecific organization id in one authentication

func (*ACProviderMock) GetAddressFromCache added in v2.3.4

func (ac *ACProviderMock) GetAddressFromCache(pkBytes []byte) (string, crypto.PublicKey, error)

GetAddressFromCache get address from cache

func (*ACProviderMock) GetAllPolicy added in v2.3.0

func (ac *ACProviderMock) GetAllPolicy() (map[string]*pbac.Policy, error)

GetAllPolicy returns all policies

func (*ACProviderMock) GetCertFromCache added in v2.3.4

func (ac *ACProviderMock) GetCertFromCache(keyBytes []byte) ([]byte, error)

GetCertFromCache get cert from cache

func (*ACProviderMock) GetHashAlg added in v2.3.0

func (ac *ACProviderMock) GetHashAlg() string

GetHashAlg return hash algorithm the access control provider uses

func (*ACProviderMock) GetMemberStatus added in v2.3.0

func (ac *ACProviderMock) GetMemberStatus(member *pbac.Member) (pbac.MemberStatus, error)

GetMemberStatus get the status information of the member

func (*ACProviderMock) GetPayerFromCache added in v2.3.4

func (ac *ACProviderMock) GetPayerFromCache(key []byte) ([]byte, error)

GetPayerFromCache get payer from cache

func (*ACProviderMock) GetValidEndorsements added in v2.3.0

func (ac *ACProviderMock) GetValidEndorsements(
	principal protocol.Principal, blockVersion uint32) ([]*common.EndorsementEntry, error)

GetValidEndorsements filters all endorsement entries and returns all valid ones

func (*ACProviderMock) GetValidEndorsementsLT2330 added in v2.3.4

func (ac *ACProviderMock) GetValidEndorsementsLT2330(
	principal protocol.Principal, blockVersion uint32) ([]*common.EndorsementEntry, error)

GetValidEndorsementsLT2330 mock a func of AccessControlProvider

func (*ACProviderMock) IsRuleSupportedByMultiSign added in v2.3.4

func (ac *ACProviderMock) IsRuleSupportedByMultiSign(resourceName string, blockVersion uint32) error

IsRuleSupportedByMultiSign verify policy of resourceName is supported by multi-sign

func (*ACProviderMock) NewMember added in v2.3.0

func (ac *ACProviderMock) NewMember(member *pbac.Member) (protocol.Member, error)

NewMember creates a member from pb Member

func (*ACProviderMock) RefineEndorsements added in v2.3.3

func (ac *ACProviderMock) RefineEndorsements(endorsements []*common.EndorsementEntry,
	msg []byte) []*common.EndorsementEntry

RefineEndorsements verify signature

func (*ACProviderMock) SetPayerToCache added in v2.3.4

func (ac *ACProviderMock) SetPayerToCache(key []byte, value []byte) error

SetPayerToCache set payer to cache

func (*ACProviderMock) ValidateResourcePolicy added in v2.3.0

func (ac *ACProviderMock) ValidateResourcePolicy(resourcePolicy *config.ResourcePolicy) bool

ValidateResourcePolicy checks whether the given resource policy is valid

func (*ACProviderMock) VerifyMsgPrincipal added in v2.3.4

func (ac *ACProviderMock) VerifyMsgPrincipal(principal protocol.Principal, blockVersion uint32) (bool, error)

VerifyMsgPrincipal verifies if the policy for the resource is met

func (*ACProviderMock) VerifyMultiSignTxPrincipal added in v2.3.4

func (ac *ACProviderMock) VerifyMultiSignTxPrincipal(
	mInfo *syscontract.MultiSignInfo, blockVersion uint32) (syscontract.MultiSignStatus, error)

VerifyMultiSignTxPrincipal verify multi-sign tx should be failed.

func (*ACProviderMock) VerifyPrincipalLT2330 added in v2.3.4

func (ac *ACProviderMock) VerifyPrincipalLT2330(
	principal protocol.Principal, blockVersion uint32) (bool, error)

VerifyPrincipalLT2330 mock a func of AccessControlProvider

func (*ACProviderMock) VerifyRelatedMaterial added in v2.3.0

func (ac *ACProviderMock) VerifyRelatedMaterial(verifyType pbac.VerifyType, data []byte) (bool, error)

VerifyRelatedMaterial verify the member's relevant identity material

func (*ACProviderMock) VerifyTxPrincipal added in v2.3.4

func (ac *ACProviderMock) VerifyTxPrincipal(
	tx *common.Transaction, resourceName string, blockVersion uint32) (bool, error)

VerifyTxPrincipal verifies if the policy for the resource is met

type PrincipalMock added in v2.3.0

type PrincipalMock struct {
}

PrincipalMock mock principal

func (*PrincipalMock) GetEndorsement added in v2.3.0

func (pm *PrincipalMock) GetEndorsement() []*common.EndorsementEntry

GetEndorsement returns all endorsements (signatures) of the verification

func (*PrincipalMock) GetMessage added in v2.3.0

func (pm *PrincipalMock) GetMessage() []byte

GetMessage returns signing data of the verification

func (*PrincipalMock) GetResourceName added in v2.3.0

func (pm *PrincipalMock) GetResourceName() string

GetResourceName returns resource name of the verification

func (*PrincipalMock) GetTargetOrgId added in v2.3.0

func (pm *PrincipalMock) GetTargetOrgId() string

GetTargetOrgId returns target organization id of the verification if the verification is for a specific organization

type PrivateComputeContract

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

PrivateComputeContract is private compute contract

func NewPrivateComputeContact

func NewPrivateComputeContact(log protocol.Logger) *PrivateComputeContract

NewPrivateComputeContact returns private compute contract @param log @return *PrivateComputeContract

func (*PrivateComputeContract) GetMethod

func (p *PrivateComputeContract) GetMethod(methodName string) common.ContractFunc

GetMethod get register method by name

type PrivateComputeRuntime

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

PrivateComputeRuntime is the private compute runtime

func (*PrivateComputeRuntime) CheckCallerCertAuth

func (r *PrivateComputeRuntime) CheckCallerCertAuth(ctx protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

CheckCallerCertAuth check caller cert auth

func (*PrivateComputeRuntime) GetContract

func (r *PrivateComputeRuntime) GetContract(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

GetContract returns contract

func (*PrivateComputeRuntime) GetData

func (r *PrivateComputeRuntime) GetData(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

GetData returns private data

func (*PrivateComputeRuntime) GetDir

func (r *PrivateComputeRuntime) GetDir(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

GetDir returns private dir

func (*PrivateComputeRuntime) GetEnclaveCACert

func (r *PrivateComputeRuntime) GetEnclaveCACert(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

GetEnclaveCACert returns enclave CA cert

func (*PrivateComputeRuntime) GetEnclaveChallenge

func (r *PrivateComputeRuntime) GetEnclaveChallenge(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

GetEnclaveChallenge returns enclave challenge

func (*PrivateComputeRuntime) GetEnclaveEncryptPubKey

func (r *PrivateComputeRuntime) GetEnclaveEncryptPubKey(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

GetEnclaveEncryptPubKey returns enclave encrypt pub key

func (*PrivateComputeRuntime) GetEnclaveProof

func (r *PrivateComputeRuntime) GetEnclaveProof(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

GetEnclaveProof returns enclave proof

func (*PrivateComputeRuntime) GetEnclaveReport

func (r *PrivateComputeRuntime) GetEnclaveReport(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

GetEnclaveReport returns enclave report

func (*PrivateComputeRuntime) GetEnclaveSignature

func (r *PrivateComputeRuntime) GetEnclaveSignature(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

GetEnclaveSignature returns enclave signature

func (*PrivateComputeRuntime) GetEnclaveVerificationPubKey

func (r *PrivateComputeRuntime) GetEnclaveVerificationPubKey(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

GetEnclaveVerificationPubKey returns enclave verification key

func (*PrivateComputeRuntime) SaveData

func (r *PrivateComputeRuntime) SaveData(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

SaveData returns private data

func (*PrivateComputeRuntime) SaveDir

func (r *PrivateComputeRuntime) SaveDir(context protocol.TxSimContext, params map[string][]byte) ([]byte, error)

SaveDir save private dir

func (*PrivateComputeRuntime) SaveEnclaveCACert

func (r *PrivateComputeRuntime) SaveEnclaveCACert(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

SaveEnclaveCACert save enclave CA cert

func (*PrivateComputeRuntime) SaveEnclaveReport

func (r *PrivateComputeRuntime) SaveEnclaveReport(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

SaveEnclaveReport saves enclave report

func (*PrivateComputeRuntime) SaveRemoteAttestation

func (r *PrivateComputeRuntime) SaveRemoteAttestation(context protocol.TxSimContext,
	params map[string][]byte) ([]byte, error)

SaveRemoteAttestation saves enclave CA cert

func (*PrivateComputeRuntime) VerifyByEnclaveCert

func (r *PrivateComputeRuntime) VerifyByEnclaveCert(context protocol.TxSimContext, enclaveId []byte,
	data []byte, sign []byte) (bool, error)

VerifyByEnclaveCert verify sign by enclave cert

type TxContextMock

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

TxContextMock mock tx context

func (*TxContextMock) CallContract

func (*TxContextMock) CallContract(caller, contract *commonPb.Contract,
	method string,
	byteCode []byte,
	parameter map[string][]byte,
	gasUsed uint64,
	refTxType commonPb.TxType,
) (*commonPb.ContractResult, protocol.ExecOrderTxType, commonPb.TxStatusCode)

CallContract Cross contract call, return (contract result, gas used)

func (*TxContextMock) Del

func (mock *TxContextMock) Del(name string, key []byte) error

Del Delete key from cache

func (*TxContextMock) Get

func (mock *TxContextMock) Get(name string, key []byte) ([]byte, error)

Get key from cache, record this operation to read set

func (*TxContextMock) GetAccessControl

func (mock *TxContextMock) GetAccessControl() (protocol.AccessControlProvider, error)

GetAccessControl returns access control

func (*TxContextMock) GetBlockFingerprint added in v2.3.0

func (s *TxContextMock) GetBlockFingerprint() string

GetBlockFingerprint mock

func (*TxContextMock) GetBlockHeight

func (mock *TxContextMock) GetBlockHeight() uint64

GetBlockHeight returns current block height

func (*TxContextMock) GetBlockProposer

func (mock *TxContextMock) GetBlockProposer() *acPb.Member

GetBlockProposer returns current block proposer

func (*TxContextMock) GetBlockTimestamp added in v2.2.0

func (s *TxContextMock) GetBlockTimestamp() int64

GetBlockTimestamp returns block timestamp

func (*TxContextMock) GetBlockVersion

func (mock *TxContextMock) GetBlockVersion() uint32

GetBlockVersion returns block version

func (*TxContextMock) GetBlockchainStore

func (mock *TxContextMock) GetBlockchainStore() protocol.BlockchainStore

GetBlockchainStore returns blockchain store

func (*TxContextMock) GetChainNodesInfoProvider

func (mock *TxContextMock) GetChainNodesInfoProvider() (protocol.ChainNodesInfoProvider, error)

GetChainNodesInfoProvider returns organization service

func (*TxContextMock) GetContractByName

func (mock *TxContextMock) GetContractByName(name string) (*commonPb.Contract, error)

GetContractByName returns contract by name

func (*TxContextMock) GetContractBytecode

func (mock *TxContextMock) GetContractBytecode(name string) ([]byte, error)

GetContractBytecode returns contract by code

func (*TxContextMock) GetCreator

func (mock *TxContextMock) GetCreator(namespace string) *acPb.Member

GetCreator returns creator

func (*TxContextMock) GetCrossInfo added in v2.3.0

func (mock *TxContextMock) GetCrossInfo() uint64

GetCrossInfo get contract call link information

func (*TxContextMock) GetCurrentResult

func (*TxContextMock) GetCurrentResult() []byte

GetCurrentResult Get cross contract call result, cache for len

func (*TxContextMock) GetDepth

func (mock *TxContextMock) GetDepth() int

GetDepth get cross contract call depth

func (*TxContextMock) GetGasRemaining added in v2.3.3

func (mock *TxContextMock) GetGasRemaining() uint64

GetGasRemaining mocks base method.

func (*TxContextMock) GetHistoryIterForKey added in v2.1.1

func (s *TxContextMock) GetHistoryIterForKey(contractName string, key []byte) (protocol.KeyHistoryIterator, error)

GetHistoryIterForKey returns history iter for key

func (*TxContextMock) GetIterHandle added in v2.1.1

func (s *TxContextMock) GetIterHandle(index int32) (interface{}, bool)

GetIterHandle returns iter

func (*TxContextMock) GetKeys added in v2.3.0

func (s *TxContextMock) GetKeys(keys []*vm.BatchKey) ([]*vm.BatchKey, error)

GetKeys returns batch key values

func (*TxContextMock) GetLastChainConfig added in v2.3.2

func (mock *TxContextMock) GetLastChainConfig() *config.ChainConfig

GetLastChainConfig returns last chain config

func (*TxContextMock) GetNoRecord added in v2.2.0

func (s *TxContextMock) GetNoRecord(contractName string, key []byte) ([]byte, error)

GetNoRecord returns no record

func (*TxContextMock) GetSender

func (mock *TxContextMock) GetSender() *acPb.Member

GetSender returns sender

func (*TxContextMock) GetSnapshot added in v2.3.2

func (s *TxContextMock) GetSnapshot() protocol.Snapshot

GetSnapshot mock

func (*TxContextMock) GetStrAddrFromPbMember added in v2.3.0

func (s *TxContextMock) GetStrAddrFromPbMember(pbMember *acPb.Member) (string, error)

GetStrAddrFromPbMember mock

func (*TxContextMock) GetTx

GetTx get related transaction

func (*TxContextMock) GetTxExecSeq

func (mock *TxContextMock) GetTxExecSeq() int

GetTxExecSeq returns tx exec seq

func (*TxContextMock) GetTxRWMapByContractName added in v2.3.0

func (mock *TxContextMock) GetTxRWMapByContractName(contractName string) (
	map[string]*commonPb.TxRead, map[string]*commonPb.TxWrite)

GetTxRWMapByContractName get the read-write map of the specified contract of the current transaction

func (*TxContextMock) GetTxRWSet

func (mock *TxContextMock) GetTxRWSet(runVmSuccess bool) *commonPb.TxRWSet

GetTxRWSet returns tx rwset

func (*TxContextMock) GetTxResult

func (mock *TxContextMock) GetTxResult() *commonPb.Result

GetTxResult returns the tx result

func (*TxContextMock) HasUsed added in v2.3.0

func (mock *TxContextMock) HasUsed(runtimeType commonPb.RuntimeType) bool

HasUsed judge whether the specified common.RuntimeType has appeared in the previous depth in the current cross-link

func (*TxContextMock) Put

func (mock *TxContextMock) Put(name string, key []byte, value []byte) error

Put key into cache

func (*TxContextMock) PutIntoReadSet added in v2.1.1

func (mock *TxContextMock) PutIntoReadSet(contractName string, key []byte, value []byte)

PutIntoReadSet put into read set

func (*TxContextMock) PutRecord

func (mock *TxContextMock) PutRecord(contractName string, value []byte, sqlType protocol.SqlType)

PutRecord put sql state into cache

func (*TxContextMock) RecordRuntimeTypeIntoCrossInfo added in v2.3.0

func (mock *TxContextMock) RecordRuntimeTypeIntoCrossInfo(runtimeType commonPb.RuntimeType)

RecordRuntimeTypeIntoCrossInfo record the new contract call information to the top of crossInfo

func (*TxContextMock) RemoveRuntimeTypeFromCrossInfo added in v2.3.0

func (mock *TxContextMock) RemoveRuntimeTypeFromCrossInfo()

RemoveRuntimeTypeFromCrossInfo remove the top-level information from the crossInfo

func (*TxContextMock) Select

func (mock *TxContextMock) Select(name string, startKey []byte, limit []byte) (protocol.StateIterator, error)

Select range query for key [start, limit)

func (*TxContextMock) SetIterHandle added in v2.1.1

func (s *TxContextMock) SetIterHandle(index int32, iter interface{})

SetIterHandle set iter

func (*TxContextMock) SetTxExecSeq

func (mock *TxContextMock) SetTxExecSeq(i int)

SetTxExecSeq set tx exec seq

func (*TxContextMock) SetTxResult

func (mock *TxContextMock) SetTxResult(txResult *commonPb.Result)

SetTxResult set tx result

func (*TxContextMock) SubtractGas added in v2.3.3

func (mock *TxContextMock) SubtractGas(gasUsed uint64) error

SubtractGas mocks base method.

Jump to

Keyboard shortcuts

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