Documentation ¶
Index ¶
- Constants
- Variables
- func AddPrefix(origin string, prefixs []string) string
- func BinaryToUint32(in []byte) (uint32, error)
- func CalcBlockHash(hashType string, b *commonPb.Block) ([]byte, error)
- func CalcDagHash(hashType string, dag *commonPb.DAG) ([]byte, error)
- func CalcPartialBlockHash(hashType string, b *commonPb.Block) ([]byte, error)
- func CalcRWSetHash(hashType string, set *commonPb.TxRWSet) ([]byte, error)
- func CalcRWSetRoot(hashType string, txs []*commonPb.Transaction) ([]byte, error)
- func CalcResultBytes(result *commonPb.Result) ([]byte, error)
- func CalcTxHash(hashType string, t *commonPb.Transaction) ([]byte, error)
- func CalcTxHashWithVersion(hashType string, t *commonPb.Transaction, version int) ([]byte, error)
- func CalcTxRequestHash(hashType string, t *commonPb.Transaction) ([]byte, error)
- func CalcTxResultHash(hashType string, result *commonPb.Result) ([]byte, error)
- func CalcTxVerifyWorkers(txCount int) int
- func CalcUnsignedTxBytes(t *commonPb.Transaction) ([]byte, error)
- func CalcUnsignedTxRequestBytes(txReq *commonPb.TxRequest) ([]byte, error)
- func CanProposeEmptyBlock(consensusType consensusPb.ConsensusType) bool
- func CertToAddrInt(cert *x509.Certificate, addrType config.AddrType) (*evmutils.Int, error)
- func CertToAddrStr(cert *x509.Certificate, addrType config.AddrType) (string, error)
- func CheckChainIdFormat(chainId string) bool
- func CheckContractNameFormat(name string) bool
- func CheckEvmAddressFormat(addr string) bool
- func CheckRootCertificate(certPEM string) (bool, error)
- func CheckTxIDFormat(txID string) bool
- func CheckZxlAddrFormat(addr string) bool
- func ConvertCmTx2EthTx(tx *commonPb.Transaction) (*ethbase.Transaction, error)
- func ConvertEthTx2CmTx(tx *ethbase.Transaction) (*commonPb.Transaction, error)
- func CreateGenesis(cc *configPb.ChainConfig) (*commonPb.Block, []*commonPb.TxRWSet, error)
- func CurrentTimeMillisSeconds() int64
- func CurrentTimeSeconds() int64
- func DispatchTxVerifyTask(txs []*commonPb.Transaction) map[int][]*commonPb.Transaction
- func FilterBlacklistTxs(txs []*commonPb.Transaction) []*commonPb.Transaction
- func FilterBlockBlacklistEvents(events []*commonPb.ContractEvent, chainId string) []*commonPb.ContractEvent
- func FilterBlockBlacklistTxRWSet(txRWSet []*commonPb.TxRWSet, chainId string) (txRWSetNew []*commonPb.TxRWSet)
- func FilterBlockBlacklistTxs(block *commonPb.Block) *commonPb.Block
- func FilterBlockTxs(reqSenderOrgId string, block *commonPb.Block) *commonPb.Block
- func FormatBlock(b *commonPb.Block) string
- func FormatRWSet(set *commonPb.TxRWSet) string
- func GZipCompressBytes(data []byte) ([]byte, error)
- func GZipDeCompressBytes(data []byte) ([]byte, error)
- func GenerateCreateTopicTableDdl(t *commonPb.ContractEvent, chainId string) string
- func GenerateInstallContractPayload(contractName, version string, runtimeType commonPb.RuntimeType, ...) (*commonPb.Payload, error)
- func GenerateSaveBlockHeightWithTopicDdl(t *commonPb.ContractEvent, chainId string, blockHeight uint64) string
- func GenerateSaveContractEventDdl(t *commonPb.ContractEvent, chainId string, blockHeight uint64, eventIdx int) string
- func GenerateUpdateBlockHeightIndexDdl(blockHeight uint64) string
- func GetBlockVersion(cfgVersion string) uint32
- func GetCertHash(_ string, userCrtPEM []byte, hashType string) ([]byte, error)
- func GetCertificateId(certPEM []byte, hashType string) ([]byte, error)
- func GetCertificateIdFromDER(certDER []byte, hashType string) ([]byte, error)
- func GetCertificateIdHex(certPEM []byte, hashType string) (string, error)
- func GetConsensusArgsFromBlock(block *commonPb.Block) (*consensusPb.BlockHeaderConsensusArgs, error)
- func GetContractByName(readObject func(contractName string, key []byte) ([]byte, error), name string) (*commonPb.Contract, error)
- func GetContractByteCodeDbKey(contractName string) []byte
- func GetContractBytecode(readObject func(contractName string, key []byte) ([]byte, error), name string) ([]byte, error)
- func GetContractDbKey(contractName string) []byte
- func GetIntAddrFromMember(member protocol.Member, addrType config.AddrType) (*evmutils.Int, error)
- func GetIntAddrFromPbMember(pbMember *acPb.Member, addrType config.AddrType, hashType crypto.HashType) (*evmutils.Int, error)
- func GetMemberPubKeySA(member *acPb.Member, getter MemberGetter) ([]byte, uint32)
- func GetNodeUidFromAddr(addr string) (string, error)
- func GetRandTxId() string
- func GetRoleFromTx(tx *commonPb.Transaction, ac protocol.AccessControlProvider) (protocol.Role, error)
- func GetSqlStatementCount(sql string) int
- func GetSqlTableName(sql string) []string
- func GetStrAddrFromMember(member protocol.Member, addrType config.AddrType) (string, error)
- func GetStrAddrFromPbMember(pbMember *acPb.Member, addrType config.AddrType, hashType crypto.HashType) (string, error)
- func GetTimestampTxId() string
- func GetTimestampTxIdByNano(nano int64) string
- func GetTxIdWithSeed(seed int64) string
- func GetTxIds(txs []*commonPb.Transaction) []string
- func HasDPosTxWritesInHeader(block *commonPb.Block, chainConf protocol.ChainConf) bool
- func IsAllBlank(args ...interface{}) bool
- func IsAnyBlank(args ...interface{}) bool
- func IsCertManagementTx(tx *commonPb.Transaction) bool
- func IsConfBlock(block *commonPb.Block) bool
- func IsConfigTx(tx *commonPb.Transaction) bool
- func IsContractManagementTx(tx *commonPb.Transaction) bool
- func IsContractMgmtBlock(b *commonPb.Block) bool
- func IsContractMgmtTx(tx *commonPb.Transaction) bool
- func IsDagEqual(dag1 *commonPb.DAG, dag2 *commonPb.DAG) (bool, error)
- func IsEmptyBlock(block *commonPb.Block) error
- func IsManageContractAsConfigTx(tx *commonPb.Transaction, enableSqlDB bool) bool
- func IsManagementTx(tx *commonPb.Transaction) bool
- func IsMultiSignManagementTx(tx *commonPb.Transaction) bool
- func IsNativeContract(contractName string) bool
- func IsNativeTx(tx *commonPb.Transaction) (isNative bool, contractName string)
- func IsPubKeyManagementTx(tx *commonPb.Transaction) bool
- func IsValidConfigTx(tx *commonPb.Transaction) bool
- func MarshalTxBytes(t *commonPb.Transaction) ([]byte, error)
- func NameToAddrInt(name string, addrType config.AddrType, blockVersion uint32) (*evmutils.Int, error)
- func NameToAddrStr(name string, addrType config.AddrType, blockVersion uint32) (string, error)
- func ParseCert(crtPEM []byte) (*bcx509.Certificate, error)
- func ParsePkFromPbMember(member *acPb.Member) (crypto.PublicKey, error)
- func PkToAddrInt(pk crypto.PublicKey, addrType config.AddrType, hashType crypto.HashType) (*evmutils.Int, error)
- func PkToAddrStr(pk crypto.PublicKey, addrType config.AddrType, hashType crypto.HashType) (string, error)
- func RearrangeRWSet(block *commonPb.Block, rwSetMap map[string]*commonPb.TxRWSet) []*commonPb.TxRWSet
- func SignBlock(hashType string, singer protocol.SigningMember, b *commonPb.Block) ([]byte, []byte, error)
- func ToCamelCase(field string) string
- func Uint32ToBinary(in uint32) []byte
- func UnmarshalEthRlpBytes(data []byte) (*commonPb.Transaction, error)
- func UnmarshalJsonStrKV2KVPairs(jsonStr string) ([]*commonpb.KeyValuePair, error)
- func UnmarshalTxBytes(data []byte) (*commonPb.Transaction, error)
- func UpdateField(params map[string][]byte, key string, config interface{}) (bool, error)
- func VerifyBlockSig(hashType string, b *commonPb.Block, ac protocol.AccessControlProvider) (bool, error)
- func VerifyCertIssue(caCerts [][]byte, intermediateCerts [][]byte, cert []byte) error
- func VerifyDPoSConfig(cc *configPb.ChainConfig) error
- func VerifyTxSignature(t *commonPb.Transaction) (bool, error)
- func VerifyTxWithoutPayload(tx *commonPb.Transaction, chainId string, ac protocol.AccessControlProvider, ...) error
- type BigInteger
- type BlockFingerPrint
- type DistributionAndSlashingConfig
- type ERC20Config
- type MemberGetter
- type StakeConfig
- type TEEProof
- func AttestationVerify(proof []byte, certOpts bcx509.VerifyOptions, reportFromChain []byte) (bool, *TEEProof, error)
- func AttestationVerifyComponents(challenge, signature, report []byte, certificate *bcx509.Certificate, ...) (bool, *TEEProof, error)
- func GrapheneAttestationVerify(proof *tee.RemoteAttestationResponse, certOpts bcx509.VerifyOptions, ...) (bool, *TEEProof, error)
Constants ¶
const ( // NativePrefix black list profix NativePrefix = "vm-native" // Violation black list message Violation = "该交易违规,内容已屏蔽。" )
const ( // PrefixContractInfo prefix of contract info PrefixContractInfo = "Contract:" // PrefixContractByteCode prefix of contract bytecode PrefixContractByteCode = "ContractByteCode:" )
const (
// DPosOrgId DPoS org id
DPosOrgId = "dpos_org_id"
)
const DecBase = 10
DecBase 10
const (
// KLV_LENGTH_SIZE 4
KLV_LENGTH_SIZE = 4
)
const TopicTableColumnDdl = `` /* 494-byte string literal not displayed */
TopicTableColumnDdl describe topic table column
const TopicTableIndex = `` /* 281-byte string literal not displayed */
TopicTableIndex describe topic table index
const TopicTableUniqueKey = `UNIQUE KEY unique_index(chain_id,block_height,tx_id,event_index)`
TopicTableUniqueKey describe topic table unique key
Variables ¶
var ( // OidKeyBag oid key bag OidKeyBag = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 12, 10, 1, 1} )
Functions ¶
func AddPrefix ¶
AddPrefix add prefix to origin string, use delimiter :
func BinaryToUint32 ¶
BinaryToUint32 binary to uint32
func CalcBlockHash ¶
CalcBlockHash calculate block hash @param hashType 哈希类型 @param b 区块对象 @return []byte @return error
func CalcDagHash ¶
CalcDagHash calculate DAG hash
func CalcPartialBlockHash ¶
CalcPartialBlockHash calculate partial block bytes hash contains Header without BlockHash, ConsensusArgs, Signature @param hashType @param b @return []byte @return error
func CalcRWSetHash ¶
CalcRWSetHash calculate read-write set hash return (nil, nil) if read-write set is nil
func CalcRWSetRoot ¶
func CalcRWSetRoot(hashType string, txs []*commonPb.Transaction) ([]byte, error)
CalcRWSetRoot calculate txs' read-write set root hash, following the tx order in txs
func CalcResultBytes ¶
CalcResultBytes get bytearray of result
func CalcTxHash ¶
func CalcTxHash(hashType string, t *commonPb.Transaction) ([]byte, error)
CalcTxHash calculate transaction hash, include tx.Payload, tx.signature, tx.Payload, tx.Result
func CalcTxHashWithVersion ¶
CalcTxHashWithVersion use version to judge if set tx gasUsed to zero when calc tx hash
func CalcTxRequestHash ¶
func CalcTxRequestHash(hashType string, t *commonPb.Transaction) ([]byte, error)
CalcTxRequestHash calculate hash of transaction request
func CalcTxResultHash ¶
CalcTxResultHash calculate hash of transaction result
func CalcTxVerifyWorkers ¶
CalcTxVerifyWorkers calculate work size of transaction verify
func CalcUnsignedTxBytes ¶
func CalcUnsignedTxBytes(t *commonPb.Transaction) ([]byte, error)
CalcUnsignedTxBytes calculate unsigned transaction bytes [request payload bytes]
func CalcUnsignedTxRequestBytes ¶
CalcUnsignedTxRequestBytes calculate unsigned transaction request bytes
func CanProposeEmptyBlock ¶
func CanProposeEmptyBlock(consensusType consensusPb.ConsensusType) bool
CanProposeEmptyBlock can empty blocks be packed
func CertToAddrInt ¶
CertToAddrInt create big.Int address by certificate @param cert 用户的证书对象 @param addrType 地址类型 @return *evmutils.Int @return error
func CertToAddrStr ¶
CertToAddrStr create string address by certificate @param cert 证书 @param addrType 地址类型 @return string 字符串形式的地址 @return error
func CheckChainIdFormat ¶
CheckChainIdFormat check chain id format
func CheckContractNameFormat ¶
CheckContractNameFormat check contract name format
func CheckEvmAddressFormat ¶
CheckEvmAddressFormat check evm address format
func CheckRootCertificate ¶
CheckRootCertificate check the root certificate
func CheckZxlAddrFormat ¶
CheckZxlAddrFormat check evm address format
func ConvertCmTx2EthTx ¶
func ConvertCmTx2EthTx(tx *commonPb.Transaction) (*ethbase.Transaction, error)
ConvertCmTx2EthTx 转换长安链交易为以太坊交易,这个长安链交易本身就是从以太坊交易转换过来的 @param tx @return *ethbase.Transaction @return error
func ConvertEthTx2CmTx ¶
func ConvertEthTx2CmTx(tx *ethbase.Transaction) (*commonPb.Transaction, error)
ConvertEthTx2CmTx 转换以太坊交易为长安链交易 以太坊交易与CM交易格式有极大不同,在转换时使用以下规则: EthTx.To -> CmTx.ContractName (为空则使用ZeroAddress) EthTx.Value .Bytes() -> CmTx.Parameter["VALUE"] EthTx.Data -> CmTx.Parameter["DATA"] ECRecover( EthTx.R,S,V) ->PubKey -Marshal-> CmTx.Sender.MemberInfo R||S||V -> CmTx.Signature if len(EthTx.Data)>4 EthTx.Data[0:4]-> CmTx.Method else -> CmTx.Method="Transfer"
func CreateGenesis ¶
CreateGenesis create genesis block (with read-write set) based on chain config
func CurrentTimeMillisSeconds ¶
func CurrentTimeMillisSeconds() int64
CurrentTimeMillisSeconds return current unix timestamp in milliseconds
func CurrentTimeSeconds ¶
func CurrentTimeSeconds() int64
CurrentTimeSeconds return current unix timestamp in seconds
func DispatchTxVerifyTask ¶
func DispatchTxVerifyTask(txs []*commonPb.Transaction) map[int][]*commonPb.Transaction
DispatchTxVerifyTask dispatch transaction verify task
func FilterBlacklistTxs ¶ added in v3.0.1
func FilterBlacklistTxs(txs []*commonPb.Transaction) []*commonPb.Transaction
FilterBlacklistTxs filter transactions with blacklist
func FilterBlockBlacklistEvents ¶ added in v3.0.1
func FilterBlockBlacklistEvents(events []*commonPb.ContractEvent, chainId string) []*commonPb.ContractEvent
FilterBlockBlacklistEvents filter events in blacklist tx id
func FilterBlockBlacklistTxRWSet ¶ added in v3.0.1
func FilterBlockBlacklistTxRWSet(txRWSet []*commonPb.TxRWSet, chainId string) (txRWSetNew []*commonPb.TxRWSet)
FilterBlockBlacklistTxRWSet filter txRWSet in blacklist tx id
func FilterBlockBlacklistTxs ¶ added in v3.0.1
FilterBlockBlacklistTxs filter transactions with blacklist
func FilterBlockTxs ¶
FilterBlockTxs filter transactions with given sender org id @param reqSenderOrgId @param block @return *commonPb.Block
func GZipCompressBytes ¶
GZipCompressBytes compress bytes with GZip(BestSpeed mode).
func GZipDeCompressBytes ¶
GZipDeCompressBytes decompress bytes with GZip.
func GenerateCreateTopicTableDdl ¶
func GenerateCreateTopicTableDdl(t *commonPb.ContractEvent, chainId string) string
GenerateCreateTopicTableDdl generate create topic table
func GenerateInstallContractPayload ¶
func GenerateInstallContractPayload(contractName, version string, runtimeType commonPb.RuntimeType, bytecode []byte, initParameters []*commonPb.KeyValuePair) (*commonPb.Payload, error)
GenerateInstallContractPayload generate install contract payload
func GenerateSaveBlockHeightWithTopicDdl ¶
func GenerateSaveBlockHeightWithTopicDdl(t *commonPb.ContractEvent, chainId string, blockHeight uint64) string
GenerateSaveBlockHeightWithTopicDdl generate save block height with topic
func GenerateSaveContractEventDdl ¶
func GenerateSaveContractEventDdl(t *commonPb.ContractEvent, chainId string, blockHeight uint64, eventIdx int) string
GenerateSaveContractEventDdl generate save contract event
func GenerateUpdateBlockHeightIndexDdl ¶
GenerateUpdateBlockHeightIndexDdl generate update block height index
func GetBlockVersion ¶
GetBlockVersion 根据vX.Y.Z形势的字符串转换为int类型的BlockVersion @param cfgVersion @return uint32
func GetCertHash ¶
GetCertHash get certificate hash
func GetCertificateId ¶
GetCertificateId get certificate id
func GetCertificateIdFromDER ¶
GetCertificateIdFromDER get certificate id from DER
func GetCertificateIdHex ¶
GetCertificateIdHex on input a certificate in PEM format, a hash algorithm(should be the one in chain configuration), output the identity of the certificate in the form of a string (under hexadecimal encoding)
func GetConsensusArgsFromBlock ¶
func GetConsensusArgsFromBlock(block *commonPb.Block) (*consensusPb.BlockHeaderConsensusArgs, error)
GetConsensusArgsFromBlock get args from block
func GetContractByName ¶
func GetContractByName(readObject func(contractName string, key []byte) ([]byte, error), name string) ( *commonPb.Contract, error)
GetContractByName get contract by name 如果找不到合约,返回contractName为空的合约,nil
func GetContractByteCodeDbKey ¶
GetContractByteCodeDbKey get contract byte code db key
func GetContractBytecode ¶
func GetContractBytecode(readObject func(contractName string, key []byte) ([]byte, error), name string) ( []byte, error)
GetContractBytecode get contract bytecode
func GetContractDbKey ¶
GetContractDbKey get contract db key
func GetIntAddrFromMember ¶
GetIntAddrFromMember calculate Int address from protocol member @param member @param addrType @return *evmutils.Int @return error
func GetIntAddrFromPbMember ¶
func GetIntAddrFromPbMember(pbMember *acPb.Member, addrType config.AddrType, hashType crypto.HashType) (*evmutils.Int, error)
GetIntAddrFromPbMember calculate Int address from pb member @param pbMember member对象 @param addrType 地址类型 @param hashType 哈希类型 @return *evmutils.Int @return error
func GetMemberPubKeySA ¶
func GetMemberPubKeySA(member *acPb.Member, getter MemberGetter) ([]byte, uint32)
GetMemberPubKeySA get member public key
func GetNodeUidFromAddr ¶
GetNodeUidFromAddr get protocol.NodeUId from node's address
func GetRandTxId ¶
func GetRandTxId() string
GetRandTxId return hex string format random transaction id with length = 64
func GetRoleFromTx ¶
func GetRoleFromTx(tx *commonPb.Transaction, ac protocol.AccessControlProvider) (protocol.Role, error)
GetRoleFromTx get role from tx
func GetSqlStatementCount ¶
GetSqlStatementCount 判断一个sql字符串是由多少条独立的SQL语句组成
func GetSqlTableName ¶
GetSqlTableName 获得SQL中使用到的表名,如果带有dbName.tableName,那么返回完整的dbName.tableName
func GetStrAddrFromMember ¶
GetStrAddrFromMember calculate string address from protocol member @param member @param addrType @return string @return error
func GetStrAddrFromPbMember ¶
func GetStrAddrFromPbMember(pbMember *acPb.Member, addrType config.AddrType, hashType crypto.HashType) (string, error)
GetStrAddrFromPbMember calculate string address from pb Member @param pbMember @param addrType @param hashType @return string @return error
func GetTimestampTxId ¶
func GetTimestampTxId() string
GetTimestampTxId return hex string format random transaction id with length = 64 GetTimestampTxId by current time, see: GetTimestampTxIdByNano eg: 687dca1d9c4fdf1652fdfc072182654f53622c496aa94c05b47d34263cd99ec9
func GetTimestampTxIdByNano ¶
GetTimestampTxIdByNano nanosecond TODO TxId is generated linearly according to Nano
func GetTxIdWithSeed ¶
GetTxIdWithSeed return tx-id with seed
func HasDPosTxWritesInHeader ¶
HasDPosTxWritesInHeader check if header has DPoS tx writes
func IsCertManagementTx ¶
func IsCertManagementTx(tx *commonPb.Transaction) bool
IsCertManagementTx the transaction is a cert management transaction or not
func IsConfBlock ¶
IsConfBlock is it a configuration block
func IsConfigTx ¶
func IsConfigTx(tx *commonPb.Transaction) bool
IsConfigTx the transaction is a config transaction or not separate blocks are required
func IsContractManagementTx ¶
func IsContractManagementTx(tx *commonPb.Transaction) bool
IsContractManagementTx the transaction is a contract management transaction or not
func IsContractMgmtBlock ¶
IsContractMgmtBlock check is contract management block
func IsContractMgmtTx ¶
func IsContractMgmtTx(tx *commonPb.Transaction) bool
IsContractMgmtTx 是否是合约安装、升级的交易
func IsDagEqual ¶
IsDagEqual compare two DAG by bytes
func IsEmptyBlock ¶
IsEmptyBlock is it an empty block
func IsManageContractAsConfigTx ¶
func IsManageContractAsConfigTx(tx *commonPb.Transaction, enableSqlDB bool) bool
IsManageContractAsConfigTx Whether the Manager Contract is considered a configuration transaction
func IsManagementTx ¶
func IsManagementTx(tx *commonPb.Transaction) bool
IsManagementTx the transaction is a management transaction or not separate blocks are required
func IsMultiSignManagementTx ¶
func IsMultiSignManagementTx(tx *commonPb.Transaction) bool
IsMultiSignManagementTx the transaction is a multi sign management transaction or not
func IsNativeContract ¶
IsNativeContract return is native contract name
func IsNativeTx ¶
func IsNativeTx(tx *commonPb.Transaction) (isNative bool, contractName string)
IsNativeTx check tx is a native contract invoke tx
func IsPubKeyManagementTx ¶
func IsPubKeyManagementTx(tx *commonPb.Transaction) bool
IsPubKeyManagementTx the transaction is a pub key management transaction or not
func IsValidConfigTx ¶
func IsValidConfigTx(tx *commonPb.Transaction) bool
IsValidConfigTx the transaction is a valid config transaction or not
func MarshalTxBytes ¶
func MarshalTxBytes(t *commonPb.Transaction) ([]byte, error)
MarshalTxBytes 将交易序列号成二进制,如果是以太坊交易就采用RLP编码,如果是长安链交易就采用pb编码 @return []byte @return error
func NameToAddrInt ¶
func NameToAddrInt(name string, addrType config.AddrType, blockVersion uint32) (*evmutils.Int, error)
NameToAddrInt create big.Int address by name 根据合约名创建Int类型的地址,因为要兼容老版本,所以需要传入BlockVersion,并不是计算地址本身要用BlockVersion @param name 合约名 @param addrType 地址类型 @param blockVersion 区块版本 @return *evmutils.Int @return error
func NameToAddrStr ¶
NameToAddrStr create string address by name 合约地址创建,因为要兼容老版本,所以需要传入BlockVersion,并不是计算地址本身要用BlockVersion @param name 合约名 @param addrType 地址类型 @param blockVersion 区块版本 @return string @return error
func ParseCert ¶
func ParseCert(crtPEM []byte) (*bcx509.Certificate, error)
ParseCert convert bytearray to certificate
func ParsePkFromPbMember ¶
ParsePkFromPbMember parse public key from member @param member 从Member对象提取公钥 @return crypto.PublicKey @return error
func PkToAddrInt ¶
func PkToAddrInt(pk crypto.PublicKey, addrType config.AddrType, hashType crypto.HashType) (*evmutils.Int, error)
PkToAddrInt create big.Int address by pk @param pk 用户的公钥 @param addrType 地址类型 @param hashType Hash类型 @return *evmutils.Int @return error
func PkToAddrStr ¶
func PkToAddrStr(pk crypto.PublicKey, addrType config.AddrType, hashType crypto.HashType) (string, error)
PkToAddrStr crete string address by pk @param pk 用户的公钥 @param addrType 地址类型 @param hashType 哈希类型 @return string 字符串型的地址 @return error
func RearrangeRWSet ¶
func RearrangeRWSet(block *commonPb.Block, rwSetMap map[string]*commonPb.TxRWSet) []*commonPb.TxRWSet
RearrangeRWSet rearrange rwSetMap into slice by block.Txs order
func SignBlock ¶
func SignBlock(hashType string, singer protocol.SigningMember, b *commonPb.Block) ([]byte, []byte, error)
SignBlock sign the block (in fact, here we sign block hash...) with signing member @param hashType 哈希类型 @param singer 签名用的Member @param b 区块 @return []byte hash bytes @return []byte signature bytes @return error
func UnmarshalEthRlpBytes ¶
func UnmarshalEthRlpBytes(data []byte) (*commonPb.Transaction, error)
UnmarshalEthRlpBytes 已知是EthTx的Rlp二进制,反序列化为CmTx @param data @return error
func UnmarshalJsonStrKV2KVPairs ¶
func UnmarshalJsonStrKV2KVPairs(jsonStr string) ([]*commonpb.KeyValuePair, error)
UnmarshalJsonStrKV2KVPairs 传入一个json字符串,该字符串key value都是string,转换为系统需要的KeyValuePair列表
func UnmarshalTxBytes ¶
func UnmarshalTxBytes(data []byte) (*commonPb.Transaction, error)
UnmarshalTxBytes 接收二进制,不知道是pb二进制还是rlp二进制,进行反序列化为交易 @param data @return error
func UpdateField ¶
UpdateField set the key in data by params[key] to struct public field return if the field has been changed such as key->field: block_height -> BlockHeight
func VerifyBlockSig ¶
func VerifyBlockSig(hashType string, b *commonPb.Block, ac protocol.AccessControlProvider) (bool, error)
VerifyBlockSig verify block proposer and signature @param hashType @param b @param ac @return bool @return error
func VerifyCertIssue ¶
VerifyCertIssue verify that the certificate is issued by the root/intermediate certificate caCerts caCert list, caCert means cert []byte(string)
func VerifyDPoSConfig ¶
func VerifyDPoSConfig(cc *configPb.ChainConfig) error
VerifyDPoSConfig 检查DPoS配置合法性
func VerifyTxSignature ¶
func VerifyTxSignature(t *commonPb.Transaction) (bool, error)
VerifyTxSignature 一个已经签名的交易,验证签名的有效性 @return bool @return error
Types ¶
type BigInteger ¶
BigInteger wrapper for big.Int
func NewZeroBigInteger ¶
func NewZeroBigInteger() *BigInteger
NewZeroBigInteger create a BigInteger of zero
func (*BigInteger) Cmp ¶
func (x *BigInteger) Cmp(y *BigInteger) int
Cmp compares x and y and returns:
-1 if x < y 0 if x == y +1 if x > y
type BlockFingerPrint ¶
type BlockFingerPrint string
BlockFingerPrint alias for string
func CalcBlockFingerPrint ¶
func CalcBlockFingerPrint(block *commonPb.Block) BlockFingerPrint
CalcBlockFingerPrint since the block has not yet formed, snapshot uses fingerprint as the possible unique value of the block @param block @return BlockFingerPrint
func CalcBlockFingerPrintWithoutTx ¶
func CalcBlockFingerPrintWithoutTx(block *commonPb.Block) BlockFingerPrint
CalcBlockFingerPrintWithoutTx 排除掉Tx的因素,计算Block的指纹,这样计算出来不管Block如何包含Tx,其指纹不变 @param block @return BlockFingerPrint
func CalcFingerPrint ¶
func CalcFingerPrint(chainId string, height uint64, timestamp int64, proposer, preHash, txRoot, dagHash, rwSetRoot []byte) BlockFingerPrint
CalcFingerPrint calculate fingerprint @param chainId @param height @param timestamp @param proposer @param preHash @param txRoot @param dagHash @param rwSetRoot @return BlockFingerPrint
type DistributionAndSlashingConfig ¶
type DistributionAndSlashingConfig struct {
// contains filtered or unexported fields
}
DistributionAndSlashingConfig struct for config
type ERC20Config ¶
type ERC20Config struct {
// contains filtered or unexported fields
}
ERC20Config for DPoS
type MemberGetter ¶
type MemberGetter interface { // GetFullMemberInfo 根据CERT_HASH获得完整的Cert,根据DID获得DID Document GetFullMemberInfo(memberId []byte, mtype acPb.MemberType) ([]byte, error) }
MemberGetter member getter interface
type StakeConfig ¶
type StakeConfig struct {
// contains filtered or unexported fields
}
StakeConfig defines stake config
type TEEProof ¶
type TEEProof struct { VerificationKey bccrypto.PublicKey VerificationKeyPEM []byte EncryptionKey bccrypto.EncryptKey EncryptionKeyPEM []byte Certificate *bcx509.Certificate CertificateDER []byte Report []byte Challenge []byte Signature []byte }
TEEProof TEE proof
func AttestationVerify ¶
func AttestationVerify(proof []byte, certOpts bcx509.VerifyOptions, reportFromChain []byte) (bool, *TEEProof, error)
AttestationVerify attestation verify
func AttestationVerifyComponents ¶
func AttestationVerifyComponents(challenge, signature, report []byte, certificate *bcx509.Certificate, verificationKey bccrypto.PublicKey, encryptionKey bccrypto.EncryptKey, certOpts bcx509.VerifyOptions) (bool, *TEEProof, error)
AttestationVerifyComponents attestation verify components
func GrapheneAttestationVerify ¶
func GrapheneAttestationVerify(proof *tee.RemoteAttestationResponse, certOpts bcx509.VerifyOptions, reportFromChain []byte) (bool, *TEEProof, error)
GrapheneAttestationVerify graphene attestation verify