crypto

package
v0.0.0-...-1e47281 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 47 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BabyJubJub

func BabyJubJub() *edwards.Param

BabyJubJub describes the twisted Edwards curve, babyJubJub, required for zero-knowledge proofs

func BcoinDialJsonRpc

func BcoinDialJsonRpc(networkID, rpcURL, rpcAPIUser, rpcAPIKey string) (*rpcclient.Client, error)

BcoinDialJsonRpc - dials and caches a new JSON-RPC client instance at the JSON-RPC url and caches it using the given network id

func BcoinGenerateKeyPair

func BcoinGenerateKeyPair(version byte) (address *string, privateKey *ecdsa.PrivateKey, err error)

BcoinGenerateKeyPair generates a bitcoin address using the given hex representation of a secp256k1 private key; see http://bcoin.io/guides/generate-address.html; returns the address and private key, or an error

func BcoinGetBlock

func BcoinGetBlock(networkID, rpcURL, rpcAPIUser, rpcAPIKey, hash string) (map[string]interface{}, error)

BcoinGetBlock retrieves the latsest block

func BcoinGetChainInfo

func BcoinGetChainInfo(networkID, rpcURL, rpcAPIUser, rpcAPIKey string) (map[string]interface{}, error)

BcoinGetChainInfo retrieves chain info

func BcoinGetDifficulty

func BcoinGetDifficulty(networkID, rpcURL, rpcAPIUser, rpcAPIKey string) (*float64, error)

BcoinGetDifficulty retrieves the current difficulty target

func BcoinGetHeader

func BcoinGetHeader(networkID, rpcURL, rpcAPIUser, rpcAPIKey, hash string) (map[string]interface{}, error)

BcoinGetHeader retrieves the latsest block

func BcoinGetHeight

func BcoinGetHeight(networkID, rpcURL, rpcAPIUser, rpcAPIKey string) (*int64, error)

BcoinGetHeight retrieves the height of the longest chain

func BcoinGetNetworkStatus

func BcoinGetNetworkStatus(networkID, rpcURL, rpcAPIUser, rpcAPIKey string) (*api.NetworkStatus, error)

BcoinGetNetworkStatus retrieves current metadata from the JSON-RPC client; returned struct includes block height, number of connected peers, protocol version, and syncing state.

func BcoinInvokeJsonRpcClient

func BcoinInvokeJsonRpcClient(networkID, rpcURL, rpcAPIUser, rpcAPIKey, method string, params []interface{}, response interface{}) error

BcoinInvokeJsonRpcClient - invokes the JSON-RPC client for the given network and url

func BcoinResolveJsonRpcClient

func BcoinResolveJsonRpcClient(networkID, rpcURL, rpcAPIUser, rpcAPIKey string) (*rpcclient.Client, error)

BcoinResolveJsonRpcClient resolves a cached *ethclient.Client client or dials and caches a new instance

func C25519ComputeSecret

func C25519ComputeSecret(privateKey, peerPublicKey []byte) []byte

C25519ComputeSecret - computes the shared secret given a private key and peer's public key

func C25519GenerateKeyPair

func C25519GenerateKeyPair() (publicKey, privateKey []byte, err error)

C25519GenerateKeyPair - generates a c25519 keypair suitable for Diffie-Hellman key exchange

func EVMBroadcastSignedTx

func EVMBroadcastSignedTx(rpcClientKey, rpcURL string, signedTx *types.Transaction) error

EVMBroadcastSignedTx emits a given signed tx for inclusion in a block

func EVMBroadcastTx

func EVMBroadcastTx(ctx context.Context, rpcClientKey, rpcURL string, tx *types.Transaction, client *ethclient.Client, result interface{}) error

EVMBroadcastTx injects a signed transaction into the pending pool for execution.

func EVMChainConfigFactory

func EVMChainConfigFactory(chainID *big.Int) *params.ChainConfig

EVMChainConfigFactory returns the chain config for the given chain id

func EVMDialJsonRpc

func EVMDialJsonRpc(rpcClientKey, rpcURL string) (*ethclient.Client, error)

EVMDialJsonRpc - dials and caches a new JSON-RPC client instance at the JSON-RPC url and caches it using the given network id

func EVMEncodeABI

func EVMEncodeABI(method *abi.Method, params ...interface{}) ([]byte, error)

EVMEncodeABI returns the ABI-encoded calldata for the given method and params

func EVMEthCall

func EVMEthCall(rpcClientKey, rpcURL string, params []interface{}) (*api.EthereumJsonRpcResponse, error)

EVMEthCall invokes eth_call manually via JSON-RPC

func EVMGenerateKeyPair

func EVMGenerateKeyPair() (address *string, privateKey *ecdsa.PrivateKey, err error)

EVMGenerateKeyPair - creates and returns an ECDSA keypair; the returned *ecdsa.PrivateKey can be encoded with: hex.EncodeToString(ethcrypto.FromECDSA(privateKey))

func EVMGetBlockByNumber

func EVMGetBlockByNumber(rpcClientKey, rpcURL string, blockNumber uint64) (*api.EthereumJsonRpcResponse, error)

EVMGetBlockByNumber retrieves a given block by number

func EVMGetBlockGasLimit

func EVMGetBlockGasLimit(rpcClientKey, rpcURL string) (uint64, error)

EVMGetBlockGasLimit retrieves the latest block gas limit

func EVMGetBlockNumber

func EVMGetBlockNumber(rpcClientKey, rpcURL string) *uint64

EVMGetBlockNumber retrieves the latest block known to the JSON-RPC client

func EVMGetBlockTimestamp

func EVMGetBlockTimestamp(rpcClientKey, rpcURL string, blockNumber uint64) (uint64, error)

EVMGetBlockTimestamp retrieves a block timestamp (seconds since epoch time) for the given block by number

func EVMGetChainConfig

func EVMGetChainConfig(rpcClientKey, rpcURL string) (*params.ChainConfig, error)

EVMGetChainConfig parses the cached network config mapped to the given `rpcClientKey`, if one exists; otherwise, the mainnet chain config is returned.

func EVMGetChainID

func EVMGetChainID(rpcClientKey, rpcURL string) (*big.Int, error)

EVMGetChainID retrieves the current chainID via JSON-RPC

func EVMGetCode

func EVMGetCode(rpcClientKey, rpcURL, addr, scope string) (*string, error)

EVMGetCode retrieves the code stored at the named address in the given scope; scope can be a block number, latest, earliest or pending

func EVMGetGasPrice

func EVMGetGasPrice(rpcClientKey, rpcURL string) *string

EVMGetGasPrice returns the gas price

func EVMGetHeaderByNumber

func EVMGetHeaderByNumber(rpcClientKey, rpcURL string, blockNumber uint64) (*api.EthereumJsonRpcResponse, error)

EVMGetHeaderByNumber retrieves a given block header by number

func EVMGetLatestBlock

func EVMGetLatestBlock(rpcClientKey, rpcURL string) (*api.EthereumJsonRpcResponse, error)

EVMGetLatestBlock retrieves the latest block

func EVMGetLatestBlockNumber

func EVMGetLatestBlockNumber(rpcClientKey, rpcURL string) (uint64, error)

EVMGetLatestBlockNumber retrieves the latest block number

func EVMGetLogs

func EVMGetLogs(rpcClientKey, rpcURL, address string, blockHash *string) (*api.EthereumJsonRpcResponse, error)

EVMGetLogs retrieves logs emitted from the given contract address

func EVMGetNativeBalance

func EVMGetNativeBalance(rpcClientKey, rpcURL, addr string) (*big.Int, error)

EVMGetNativeBalance retrieves a wallet's native currency balance

func EVMGetNetworkStatus

func EVMGetNetworkStatus(rpcClientKey, rpcURL string) (*api.NetworkStatus, error)

EVMGetNetworkStatus retrieves current metadata from the JSON-RPC client; returned struct includes block height, chainID, number of connected peers, protocol version, and syncing state.

func EVMGetPeerCount

func EVMGetPeerCount(rpcClientKey, rpcURL string) uint64

EVMGetPeerCount returns the number of peers currently connected to the JSON-RPC client

func EVMGetProtocolVersion

func EVMGetProtocolVersion(rpcClientKey, rpcURL string) *string

EVMGetProtocolVersion returns the JSON-RPC client protocol version

func EVMGetSyncProgress

func EVMGetSyncProgress(client *ethclient.Client) (*ethereum.SyncProgress, error)

EVMGetSyncProgress retrieves the status of the current network sync

func EVMGetTokenBalance

func EVMGetTokenBalance(rpcClientKey, rpcURL, tokenAddr, addr string, contractABI interface{}) (*big.Int, error)

EVMGetTokenBalance retrieves a token balance for a specific token contract and network address

func EVMGetTokenDecimals

func EVMGetTokenDecimals(rpcClientKey, rpcURL, from, tokenAddr string) (*uint8, error)

EVMGetTokenDecimals attempts to retrieve the number of decimals supported by an arbitrary token contract

func EVMGetTokenSymbol

func EVMGetTokenSymbol(rpcClientKey, rpcURL, from, tokenAddr string, contractABI interface{}) (*string, error)

EVMGetTokenSymbol attempts to retrieve the symbol of a token presumed to be deployed at the given token contract address

func EVMGetTxReceipt

func EVMGetTxReceipt(rpcClientKey, rpcURL, txHash, from string) (*types.Receipt, error)

EVMGetTxReceipt retrieves the full transaction receipt via JSON-RPC given the transaction hash

func EVMHashFunctionSelector

func EVMHashFunctionSelector(sel string) string

EVMHashFunctionSelector returns the first 4 bytes of the Keccak256 hash of the given function selector

func EVMInvokeJsonRpcClient

func EVMInvokeJsonRpcClient(rpcClientKey, rpcURL, method string, params []interface{}, response interface{}) error

EVMInvokeJsonRpcClient - invokes the JSON-RPC client for the given network and url

func EVMMarshalEncryptedKey

func EVMMarshalEncryptedKey(addr common.Address, privateKey *ecdsa.PrivateKey, secret string) ([]byte, error)

EVMMarshalEncryptedKey encrypts key as version 3.

func EVMMarshalKeyPairJSON

func EVMMarshalKeyPairJSON(addr common.Address, privateKey *ecdsa.PrivateKey) ([]byte, error)

EVMMarshalKeyPairJSON - returns keystore JSON representation of given private key

func EVMResolveEthClient

func EVMResolveEthClient(rpcClientKey, rpcURL string) (*ethclient.Client, error)

EVMResolveEthClient resolves a cached *ethclient.Client client or dials and caches a new instance

func EVMResolveJsonRpcClient

func EVMResolveJsonRpcClient(rpcClientKey, rpcURL string) (*ethrpc.Client, error)

EVMResolveJsonRpcClient resolves a cached *ethclient.Client client or dials and caches a new instance

func EVMSignTx

func EVMSignTx(
	rpcClientKey,
	rpcURL,
	from,
	privateKey string,
	to,
	data *string,
	val *big.Int,
	nonce *uint64,
	gasLimit uint64,
	gasPrice *uint64,
) (*types.Transaction, *string, error)

EVMSignTx signs a transaction using the given private key and calldata; providing 0 gas results in the tx attempting to use up to the block gas limit for execution

func EVMTraceTx

func EVMTraceTx(rpcClientKey, rpcURL string, hash *string) (interface{}, error)

EVMTraceTx returns the VM traces; requires parity JSON-RPC client and the node must be configured with `--fat-db on --tracing on --pruning archive`

func EVMTxFactory

func EVMTxFactory(
	rpcClientKey,
	rpcURL,
	from string,
	to,
	data *string,
	val *big.Int,
	nonce *uint64,
	gasLimit uint64,
	gasPrice *uint64,
) (types.Signer, *types.Transaction, []byte, error)

EVMTxFactory builds and returns an unsigned transaction hash

func FromECDSA

func FromECDSA(priv *ecdsa.PrivateKey) []byte

FromECDSA exports a private key into a binary dump.

func HexToAddress

func HexToAddress(s string) common.Address

HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.

func Keccak256

func Keccak256(str string) []byte

Keccak256 hash the given string

func TECGenerateKeyPair

func TECGenerateKeyPair() (publicKey, privateKey []byte, err error)

TECGenerateKeyPair - creates and returns an Twisted Edwards Curve (TEC) keypair;

func TECSign

func TECSign(privateKey, message []byte) ([]byte, error)

TECSign signs the given message using the given private key TODO: see crypto/anon/sig.go to add anonymous sigs

func TECVerify

func TECVerify(publicKey, message []byte, signature []byte) error

TECVerify verifies a signature for the given message and public key

Types

This section is empty.

Jump to

Keyboard shortcuts

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