coreCrypto

package module
v0.0.0-...-16fd656 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashFnSha256    = iota
	HashFnSha512    = iota
	HashFnKeccak256 = iota
	HashFnKeccak512 = iota
	HashFnRipemd160 = iota
)

HashFn is `int`, not type due to `go bind` support (it does not support enums)

View Source
const (
	SecretStorageHeaderKDF        = "scrypt"
	SecretStorageCipherAes128Crt  = "aes-128-ctr"
	SecretStorageScryptN          = 1 << 18
	SecretStorageScryptP          = 1
	SecretStorageScryptR          = 8
	SecretStorageScryptDKLen      = 32
	SecretStoragePrivateKeyMinLen = 32
)

Secret storage constants

View Source
const (
	CurveSecp256k1 = iota
)

CurveSecp256k1 is `int`, not type due to `go bind` support (it does not support enums)

View Source
const DigestLength = 32

DigestLength sets the signature digest exact length

Variables

View Source
var (
	ErrDecrypt = errors.New("could not decrypt key with given password")
)

Functions

func AESCTRXOR

func AESCTRXOR(key, inText, iv []byte) ([]byte, error)

func AESCTRXOREmptyOnError

func AESCTRXOREmptyOnError(key, inText, iv []byte) []byte

func AddPrivKeys

func AddPrivKeys(curve int, key1 []byte, key2 []byte) []byte

AddPrivKeys Add key to key on a curve

func AddPubKeys

func AddPubKeys(curve int, key1 []byte, key2 []byte) []byte

AddPubKeys Add key to key on a curve

func CompressedPubKey

func CompressedPubKey(curve int, priv []byte) []byte

CompressedPubKey for given curve, user CurveXYZ constants above. (Not type due to `go bind` interop)

func Hash

func Hash(data []byte, hashFn int) []byte

Hash pass one of the hash constants from top of the file. (`HashFnSha256`, `HashFnSha512`, ...) Enum not used due to `go bind` (does not support enums)

func HashData

func HashData(kh KeccakState, data []byte) []byte

HashData hashes the provided data using the KeccakState and returns a 32 byte hash

func HashFunc

func HashFunc(h int) func() hash.Hash

HashFunc hash functions, use constants above

func HmacSha512

func HmacSha512(key []byte, data []byte) []byte

HmacSha512 return hmacSha512 of data, using key

func IsBip44ValidPrv

func IsBip44ValidPrv(curve int, key []byte) bool

IsBip44ValidPrv checks that key bip44 compliant

func IsBip44ValidPub

func IsBip44ValidPub(curve int, key []byte) bool

IsBip44Compliant checks that key bip44 compliant

func Keccak256

func Keccak256(data []byte) []byte

Keccak256 calculates and returns the Keccak256 hash of the input data.

func Keccak512

func Keccak512(data []byte) []byte

Keccak512 calculates and returns the Keccak512 hash of the input data.

func Pbkdf2

func Pbkdf2(password, salt []byte, iter, keyLen, hashFn int) []byte

Pbkdf2 pass one of the hash constants from top of the file. (`HashFnSha256`, `HashFnSha512`, ...) Enum not used due to `go bind` (does not support enums)

func ScryptKey

func ScryptKey(pswd, salt []byte, N, r, p, keyLen int) []byte

ScryptKey derivation

func SecureRand

func SecureRand(size int) ([]byte, error)

SecureRand cryptographically secure random bytes of size or error

func SecureRandFatal

func SecureRandFatal(size int) []byte

SecureRandFatal cryptographically secure random bytes of size crashes if err

func Sign

func Sign(digestHash []byte, prv []byte, curve int) (sig []byte, err error)

func SignEmptyOnError

func SignEmptyOnError(digestHash []byte, prv []byte, curve int) []byte

func UncompressedPubKey

func UncompressedPubKey(curve int, pubKey []byte) []byte

UncompressedPubKey for given curve, decompresses compressed put key Returns empty byte array on error. (Not type due to `go bind` interop)

Types

type Enode

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

Enode represents a host on the network.

type Enodes

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

Enodes represents a slice of accounts.

type KeccakState

type KeccakState interface {
	hash.Hash
	Read([]byte) (int, error)
}

KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.

func NewKeccakState

func NewKeccakState() KeccakState

NewKeccakState creates a new KeccakState

type Node

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

func NewGethNode

func NewGethNode(datadir string, config *NodeConfig) (stack *Node, _ error)

NewGethNode creates and configures a new Geth node.

func NewGethNodeFataln

func NewGethNodeFataln(datadir string, config *NodeConfig) (stack *Node)

NewGethNodeFataln creates and configures a new Geth node.

func (*Node) Close

func (n *Node) Close() error

Close terminates a running node along with all it's services, tearing internal state down. It is not possible to restart a closed node.

func (*Node) GetNodeInfo

func (n *Node) GetNodeInfo() *NodeInfo

GetNodeInfo gathers and returns a collection of metadata known about the host.

func (*Node) GetPeersInfo

func (n *Node) GetPeersInfo() *PeerInfos

GetPeersInfo returns an array of metadata objects describing connected peers.

func (*Node) Start

func (n *Node) Start() error

Start creates a live P2P node and starts running it.

type NodeConfig

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

NodeConfig represents the collection of configuration values to fine tune the Geth node embedded into a mobile process. The available values are a subset of the entire API provided by go-ethereum to reduce the maintenance surface and dev complexity.

func NewNodeConfig

func NewNodeConfig() *NodeConfig

NewNodeConfig creates a new node option set, initialized to the default values.

func (*NodeConfig) AddBootstrapNode

func (nc *NodeConfig) AddBootstrapNode(node *Enode)

AddBootstrapNode adds a bootstrap node to the node config.

func (*NodeConfig) BootstrapNodes

func (nc *NodeConfig) BootstrapNodes() *Enodes

BootstrapNodes used to establish connectivity with the rest of the network.

func (*NodeConfig) EthereumDatabaseCache

func (nc *NodeConfig) EthereumDatabaseCache() int

EthereumDatabaseCache is the system memory in MB to allocate for database caching. A minimum of 16MB is always reserved.

func (*NodeConfig) EthereumEnabled

func (nc *NodeConfig) EthereumEnabled() bool

EthereumEnabled specifies whether the node should run the Ethereum protocol.

func (*NodeConfig) EthereumGenesis

func (nc *NodeConfig) EthereumGenesis() string

EthereumGenesis is the genesis JSON to use to seed the blockchain with. An empty genesis state is equivalent to using the mainnet's state.

func (*NodeConfig) EthereumNetStats

func (nc *NodeConfig) EthereumNetStats() string

EthereumNetStats is a netstats connection string to use to report various chain, transaction and node stats to a monitoring server. It has the form "nodename:secret@host:port"

func (*NodeConfig) EthereumNetworkID

func (nc *NodeConfig) EthereumNetworkID() int64

EthereumNetworkID is the network identifier used by the Ethereum protocol to decide if remote peers should be accepted or not.

func (*NodeConfig) MaxPeers

func (nc *NodeConfig) MaxPeers() int

MaxPeers is the maximum number of peers that can be connected. If this is set to zero, then only the configured static and trusted peers can connect.

func (*NodeConfig) PprofAddress

func (nc *NodeConfig) PprofAddress() string

PprofAddress listening address of pprof server.

func (*NodeConfig) SetEthereumDatabaseCache

func (nc *NodeConfig) SetEthereumDatabaseCache(databaseCache int)

SetEthereumDatabaseCache is the system memory in MB to allocate for database caching. A minimum of 16MB is always reserved.

func (*NodeConfig) SetEthereumEnabled

func (nc *NodeConfig) SetEthereumEnabled(ethereumEnabled bool)

SetEthereumEnabled specifies whether the node should run the Ethereum protocol.

func (*NodeConfig) SetEthereumGenesis

func (nc *NodeConfig) SetEthereumGenesis(genesis string)

SetEthereumGenesis is the genesis JSON to use to seed the blockchain with. An empty genesis state is equivalent to using the mainnet's state.

func (*NodeConfig) SetEthereumNetStats

func (nc *NodeConfig) SetEthereumNetStats(netStats string)

SetEthereumNetStats is a netstats connection string to use to report various chain, transaction and node stats to a monitoring server. It has the form "nodename:secret@host:port"

func (*NodeConfig) SetEthereumNetworkID

func (nc *NodeConfig) SetEthereumNetworkID(networkID int64)

SetEthereumNetworkID is the network identifier used by the Ethereum protocol to decide if remote peers should be accepted or not.

func (*NodeConfig) SetMaxPeers

func (nc *NodeConfig) SetMaxPeers(maxPeers int)

SetMaxPeers is the maximum number of peers that can be connected. If this is set to zero, then only the configured static and trusted peers can connect.

func (*NodeConfig) SetPprofAddress

func (nc *NodeConfig) SetPprofAddress(pprofAddress string)

SetPprofAddress listening address of pprof server.

type NodeInfo

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

NodeInfo represents pi short summary of the information known about the host.

func (*NodeInfo) String

func (ni *NodeInfo) String() string

String implements fmt.Stringer

type PeerInfos

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

PeerInfos represents a slice of infos about remote peers.

func (*PeerInfos) String

func (pi *PeerInfos) String() string

String implements fmt.Stringer

Directories

Path Synopsis
supportFiles
c
Package main is an autogenerated binder stub for package universe.
Package main is an autogenerated binder stub for package universe.

Jump to

Keyboard shortcuts

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