common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Localhost = "127.0.0.1"

	JSONKeyAddress         = "address"
	JSONKeyID              = "id"
	JSONKeyMethod          = "method"
	JSONKeyParams          = "params"
	JSONKeyRPCVersion      = "jsonrpc"
	JSONKeySignature       = "signature"
	JSONKeyType            = "type"
	JSONKeyEncryptionToken = "encryptionToken"
	JSONKeyFormats         = "formats"
)
View Source
const (
	PathReady                     = "/ready/"
	PathJoin                      = "/join/"
	PathGetMessage                = "/getmessage/"
	PathAuthenticate              = "/authenticate/"
	PathQuery                     = "/query/"
	PathRevoke                    = "/revoke/"
	PathHealth                    = "/health/"
	PathSessionKeys               = "/session-key/"
	PathNetworkHealth             = "/network-health/"
	PathNetworkConfig             = "/network-config/"
	PathKeyExchange               = "/key-exchange/"
	WSProtocol                    = "ws://"
	HTTPProtocol                  = "http://"
	EncryptedTokenQueryParameter  = "token"
	AddressQueryParameter         = "a"
	MessageUserIDLen              = 40
	MessageUserIDLenWithPrefix    = 42
	EthereumAddressLen            = 42
	SuccessMsg                    = "success"
	APIVersion1                   = "/v1"
	PathVersion                   = "/version/"
	DeduplicationBufferSize       = 20
	DefaultGatewayAuthMessageType = "EIP712"
)
View Source
const EncryptionKeySize = 32

Variables

This section is empty.

Functions

func BytesToPrivateKey

func BytesToPrivateKey(keyBytes []byte) (*ecies.PrivateKey, error)

BytesToPrivateKey converts []bytes to *ecies.PrivateKey

func CreateEncClient

func CreateEncClient(conn *gethrpc.Client, encKey []byte, addressBytes []byte, privateKeyBytes []byte, signature []byte, signatureType viewingkey.SignatureType, logger gethlog.Logger) (*rpc.EncRPCClient, error)

func GenerateRandomKey added in v0.28.0

func GenerateRandomKey() ([]byte, error)

func HashForLogging added in v1.0.0

func HashForLogging(input []byte) string

HashForLogging creates a double-hashed hex string of the input bytes for secure logging

func PrivateKeyToCompressedPubKey

func PrivateKeyToCompressedPubKey(prvKey *ecies.PrivateKey) []byte

PrivateKeyToCompressedPubKey converts *ecies.PrivateKey to compressed PubKey ([]byte with length 33)

Types

type Config added in v0.24.0

type Config struct {
	WalletExtensionHost     string
	WalletExtensionPortHTTP int
	WalletExtensionPortWS   int

	NodeRPCHTTPAddress      string
	NodeRPCWebsocketAddress string

	LogPath        string
	DBPathOverride string // Overrides the database file location. Used in tests.
	VerboseFlag    bool

	DBType          string
	DBConnectionURL string

	TenChainID       int
	StoreIncomingTxs bool

	RateLimitUserComputeTime       time.Duration
	RateLimitWindow                time.Duration
	RateLimitMaxConcurrentRequests int

	InsideEnclave                bool // Indicates if the program is running inside an enclave
	KeyExchangeURL               string
	EnableTLS                    bool
	TLSDomain                    string
	EncryptingCertificateEnabled bool
	DisableCaching               bool
}

Config contains the configuration required by the WalletExtension.

type GWAccount added in v0.28.0

type GWAccount struct {
	User          *GWUser
	Address       *common.Address
	Signature     []byte // the signature by the account over the userId - which is derived from the VK
	SignatureType viewingkey.SignatureType
}

type GWSessionKey added in v1.0.0

type GWSessionKey struct {
	Account    *GWAccount
	PrivateKey *ecies.PrivateKey // the private key corresponding to the account
}

GWSessionKey - an account key-pair registered for a user

type GWUser added in v0.28.0

type GWUser struct {
	ID         []byte
	Accounts   map[common.Address]*GWAccount
	UserKey    []byte
	SessionKey *GWSessionKey
	ActiveSK   bool // the session key is active, and it must be used to sign all incoming transactions, and used as the preferred account
}

func (GWUser) AllAccounts added in v1.0.0

func (u GWUser) AllAccounts() map[common.Address]*GWAccount

func (GWUser) GetAllAddresses added in v0.28.0

func (u GWUser) GetAllAddresses() []common.Address

type RPCRequest

type RPCRequest struct {
	ID     json.RawMessage
	Method string
	Params []interface{}
}

func (*RPCRequest) Clone

func (r *RPCRequest) Clone() *RPCRequest

Clone returns a new instance of the *RPCRequest

Jump to

Keyboard shortcuts

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