common

package
v0.20.5 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Localhost = "127.0.0.1"

	JSONKeyAddress      = "address"
	JSONKeyData         = "data"
	JSONKeyErr          = "error"
	JSONKeyFrom         = "from"
	JSONKeyID           = "id"
	JSONKeyMethod       = "method"
	JSONKeyParams       = "params"
	JSONKeyResult       = "result"
	JSONKeyRoot         = "root"
	JSONKeyRPCVersion   = "jsonrpc"
	JSONKeySignature    = "signature"
	JSONKeySubscription = "subscription"
	JSONKeyCode         = "code"
	JSONKeyMessage      = "message"
)
View Source
const (
	PathRoot                            = "/"
	PathReady                           = "/ready/"
	PathViewingKeys                     = "/viewingkeys/"
	PathGenerateViewingKey              = "/generateviewingkey/"
	PathSubmitViewingKey                = "/submitviewingkey/"
	PathJoin                            = "/join/"
	PathAuthenticate                    = "/authenticate/"
	PathQuery                           = "/query/"
	PathRevoke                          = "/revoke/"
	PathObscuroGateway                  = "/"
	PathHealth                          = "/health/"
	WSProtocol                          = "ws://"
	DefaultUser                         = "defaultUser"
	UserQueryParameter                  = "u"
	EncryptedTokenQueryParameter        = "token"
	AddressQueryParameter               = "a"
	MessageUserIDLen                    = 40
	EthereumAddressLen                  = 42
	GetStorageAtUserIDRequestMethodName = "getUserID"
	SuccessMsg                          = "success"
	APIVersion1                         = "/v1"
	MethodEthSubscription               = "eth_subscription"
	PathVersion                         = "/version/"
	DeduplicationBufferSize             = 20
)

Variables

View Source
var ReaderHeadTimeout = 10 * time.Second

Functions

func BytesToPrivateKey

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

BytesToPrivateKey converts []bytes to *ecies.PrivateKey

func CraftErrorResponse

func CraftErrorResponse(err error) map[string]interface{}

func CreateEncClient

func CreateEncClient(
	hostRPCBindAddr string,
	addressBytes []byte,
	privateKeyBytes []byte,
	signature []byte,
	logger gethlog.Logger,
) (*rpc.EncRPCClient, error)

func GetUserIDbyte

func GetUserIDbyte(userID string) ([]byte, error)

GetUserIDbyte converts userID from string to correct byte format

func PrivateKeyToCompressedPubKey

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

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

Types

type AccountDB

type AccountDB struct {
	AccountAddress []byte
	Signature      []byte
}

type JSONError

type JSONError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

type JSONRPCMessage

type JSONRPCMessage struct {
	Version string          `json:"jsonrpc,omitempty"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method,omitempty"`
	Params  json.RawMessage `json:"params,omitempty"`
	Error   *JSONError      `json:"error,omitempty"`
	Result  json.RawMessage `json:"result,omitempty"`
}

JSONRPCMessage value of this type can a JSON-RPC request, notification, successful response or error response. Which one it is depends on the fields.

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

type UserDB

type UserDB struct {
	UserID     []byte
	PrivateKey []byte
}

Jump to

Keyboard shortcuts

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