core

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const WebServerOffString = "off"

WebServerOffString represents the constant used to switch off the web server

Variables

View Source
var (
	ErrInvalidLengthUserInfo        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowUserInfo          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupUserInfo = fmt.Errorf("proto: unexpected end of group")
)
View Source
var ErrEmptyData = errors.New("empty data")

ErrEmptyData signals that empty data was received

View Source
var ErrInvalidBucketHandlers = errors.New("invalid bucket handlers")

ErrInvalidBucketHandlers signals than an invalid bucket handlers was provided

View Source
var ErrInvalidBucketID = errors.New("invalid bucket id")

ErrInvalidBucketID signals that an invalid bucket id was provided

View Source
var ErrInvalidNumberOfBuckets = errors.New("invalid number of buckets")

ErrInvalidNumberOfBuckets signals that an invalid number of buckets was provided

View Source
var ErrInvalidPubkeyConverterType = errors.New("invalid pubkey converter type")

ErrInvalidPubkeyConverterType signals that the provided pubkey converter type is invalid

View Source
var ErrInvalidRedisConnType = errors.New("invalid redis connection type")

ErrInvalidRedisConnType signals that an invalid redis connection type has been provided

View Source
var ErrInvalidValue = errors.New("invalid value")

ErrInvalidValue signals that an invalid value was provided

View Source
var ErrNilBucket = errors.New("nil bucket")

ErrNilBucket signals that a nil bucket has been provided

View Source
var ErrNilBucketHandler = errors.New("nil bucket handler")

ErrNilBucketHandler signals that a nil bucket handler was provided

View Source
var ErrNilBucketIDProvider = errors.New("nil bucket id provider")

ErrNilBucketIDProvider signals that a nil bucket id provider was provided

View Source
var ErrNilFacadeHandler = errors.New("nil facade handler")

ErrNilFacadeHandler signals that a nil facade handler has been provided

View Source
var ErrNilHttpClient = errors.New("nil http client")

ErrNilHttpClient signals that a nil http client has been provided

View Source
var ErrNilKeyGenerator = errors.New("nil key generator")

ErrNilKeyGenerator signals that a nil key generator was provided

View Source
var ErrNilMetricsHandler = errors.New("nil metrics handler")

ErrNilMetricsHandler signals that a nil metrics handler has been provided

View Source
var ErrNilMongoDBClient = errors.New("nil mongodb client")

ErrNilMongoDBClient signals that a nil mongodb client has been provided

View Source
var ErrNilStorer = errors.New("nil storer")

ErrNilStorer signals that a nil storer has been provided

View Source
var ErrTooManyFailedAttempts = errors.New("too many failed attempts")

ErrTooManyFailedAttempts signals that too many failed attempts were made

View Source
var GuardianState_name = map[int32]string{
	0: "NotUsable",
	1: "Usable",
}
View Source
var GuardianState_value = map[string]int32{
	"NotUsable": 0,
	"Usable":    1,
}

Functions

func NewGuardianKeyGenerator

func NewGuardianKeyGenerator(args ArgGuardianKeyGenerator) (*guardianKeyGenerator, error)

NewGuardianKeyGenerator returns a new instance of guardian key generator

func NewHttpClientWrapper

func NewHttpClientWrapper(httpClient HttpClient) (*httpClientWrapper, error)

NewHttpClientWrapper returns a new instance of httpClientWrapper

Types

type ArgGuardianKeyGenerator

type ArgGuardianKeyGenerator struct {
	Mnemonic data.Mnemonic
	KeyGen   crypto.KeyGenerator
}

ArgGuardianKeyGenerator is the DTO used to create a new instance of guardian key generator

type BucketIDProvider

type BucketIDProvider interface {
	GetBucketForAddress(address []byte) uint32
	IsInterfaceNil() bool
}

BucketIDProvider defines the methods for a component able to extract a bucket id from an address

type CryptoComponentsHolderFactory

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

CryptoComponentsHolderFactory is the implementation of the CryptoComponentsHolderFactory interface

func NewCryptoComponentsHolderFactory

func NewCryptoComponentsHolderFactory(keyGen crypto.KeyGenerator) (*CryptoComponentsHolderFactory, error)

NewCryptoComponentsHolderFactory creates a new instance of CryptoComponentsHolderFactory

func (*CryptoComponentsHolderFactory) Create

Create creates a new instance of CryptoComponentsHolder

func (*CryptoComponentsHolderFactory) IsInterfaceNil

func (f *CryptoComponentsHolderFactory) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

type DBType

type DBType string

DBType represents the type of DB

const LevelDB DBType = "levelDB"

LevelDB is the local levelDB

const MongoDB DBType = "mongoDB"

MongoDB is the mongo db identifier

type GuardedTxBuilder

type GuardedTxBuilder interface {
	ApplyGuardianSignature(cryptoHolderGuardian core.CryptoComponentsHolder, tx *transaction.FrontendTransaction) error
	IsInterfaceNil() bool
}

GuardedTxBuilder defines the component able to build and sign a guarded transaction

type GuardianInfo

type GuardianInfo struct {
	PublicKey  []byte        `protobuf:"bytes,1,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"`
	PrivateKey []byte        `protobuf:"bytes,2,opt,name=PrivateKey,proto3" json:"PrivateKey,omitempty"`
	State      GuardianState `protobuf:"varint,3,opt,name=State,proto3,enum=proto.GuardianState" json:"State,omitempty"`
	OTPData    OTPInfo       `protobuf:"bytes,4,opt,name=OTPData,proto3" json:"OTPData"`
}

GuardianInfo holds details about a guardian

func (*GuardianInfo) Descriptor

func (*GuardianInfo) Descriptor() ([]byte, []int)

func (*GuardianInfo) Equal

func (this *GuardianInfo) Equal(that interface{}) bool

func (*GuardianInfo) GetOTPData

func (m *GuardianInfo) GetOTPData() OTPInfo

func (*GuardianInfo) GetPrivateKey

func (m *GuardianInfo) GetPrivateKey() []byte

func (*GuardianInfo) GetPublicKey

func (m *GuardianInfo) GetPublicKey() []byte

func (*GuardianInfo) GetState

func (m *GuardianInfo) GetState() GuardianState

func (*GuardianInfo) GoString

func (this *GuardianInfo) GoString() string

func (*GuardianInfo) Marshal

func (m *GuardianInfo) Marshal() (dAtA []byte, err error)

func (*GuardianInfo) MarshalTo

func (m *GuardianInfo) MarshalTo(dAtA []byte) (int, error)

func (*GuardianInfo) MarshalToSizedBuffer

func (m *GuardianInfo) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GuardianInfo) ProtoMessage

func (*GuardianInfo) ProtoMessage()

func (*GuardianInfo) Reset

func (m *GuardianInfo) Reset()

func (*GuardianInfo) Size

func (m *GuardianInfo) Size() (n int)

func (*GuardianInfo) String

func (this *GuardianInfo) String() string

func (*GuardianInfo) Unmarshal

func (m *GuardianInfo) Unmarshal(dAtA []byte) error

func (*GuardianInfo) XXX_DiscardUnknown

func (m *GuardianInfo) XXX_DiscardUnknown()

func (*GuardianInfo) XXX_Marshal

func (m *GuardianInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GuardianInfo) XXX_Merge

func (m *GuardianInfo) XXX_Merge(src proto.Message)

func (*GuardianInfo) XXX_Size

func (m *GuardianInfo) XXX_Size() int

func (*GuardianInfo) XXX_Unmarshal

func (m *GuardianInfo) XXX_Unmarshal(b []byte) error

type GuardianState

type GuardianState int32

GuardianState represents the state of the guardian

const (
	// NotUsable represents a guardian recently generated but not verified
	NotUsable GuardianState = 0
	// Usable represents a verified guardian
	Usable GuardianState = 1
)

func (GuardianState) EnumDescriptor

func (GuardianState) EnumDescriptor() ([]byte, []int)

func (GuardianState) String

func (x GuardianState) String() string

type HttpClient

type HttpClient interface {
	GetHTTP(ctx context.Context, endpoint string) ([]byte, int, error)
	IsInterfaceNil() bool
}

HttpClient defines the behavior of http client able to make http requests

type HttpClientWrapper

type HttpClientWrapper interface {
	GetAccount(ctx context.Context, address string) (*data.Account, error)
	GetGuardianData(ctx context.Context, address string) (*api.GuardianData, error)
	IsInterfaceNil() bool
}

HttpClientWrapper defines the behavior of wrapper over HttpClient

type IndexHandler

type IndexHandler interface {
	Put(key, data []byte) error
	Get(key []byte) ([]byte, error)
	Has(key []byte) error
	Close() error
	AllocateBucketIndex() (uint32, error)
	GetLastIndex() (uint32, error)
	IsInterfaceNil() bool
}

IndexHandler defines the methods for a component which handles indexes

type KeyGenerator

type KeyGenerator interface {
	PrivateKeyFromByteArray(b []byte) (crypto.PrivateKey, error)
	IsInterfaceNil() bool
}

KeyGenerator defines the methods for a component able to create a crypto.PrivateKey from a byte array

type KeysGenerator

type KeysGenerator interface {
	GenerateManagedKey() (crypto.PrivateKey, error)
	GenerateKeys(index uint32) ([]crypto.PrivateKey, error)
	IsInterfaceNil() bool
}

KeysGenerator defines the methods for a component able to generate unique HD keys

type Marshaller

type Marshaller interface {
	Marshal(obj interface{}) ([]byte, error)
	Unmarshal(obj interface{}, buff []byte) error
	IsInterfaceNil() bool
}

Marshaller defines the 2 basic operations: serialize (marshal) and deserialize (unmarshal)

type NativeAuthWhitelistHandler

type NativeAuthWhitelistHandler interface {
	IsWhitelisted(route string) bool
	IsInterfaceNil() bool
}

NativeAuthWhitelistHandler defines the behavior of a component that handles whitelisted routes

type OTPInfo

type OTPInfo struct {
	OTP                     []byte `protobuf:"bytes,1,opt,name=OTP,proto3" json:"OTP,omitempty"`
	LastTOTPChangeTimestamp int64  `protobuf:"varint,2,opt,name=LastTOTPChangeTimestamp,proto3" json:"LastTOTPChangeTimestamp,omitempty"`
}

OTPInfo holds the encrypted otp along with its last update timestamp

func (*OTPInfo) Descriptor

func (*OTPInfo) Descriptor() ([]byte, []int)

func (*OTPInfo) Equal

func (this *OTPInfo) Equal(that interface{}) bool

func (*OTPInfo) GetLastTOTPChangeTimestamp

func (m *OTPInfo) GetLastTOTPChangeTimestamp() int64

func (*OTPInfo) GetOTP

func (m *OTPInfo) GetOTP() []byte

func (*OTPInfo) GoString

func (this *OTPInfo) GoString() string

func (*OTPInfo) Marshal

func (m *OTPInfo) Marshal() (dAtA []byte, err error)

func (*OTPInfo) MarshalTo

func (m *OTPInfo) MarshalTo(dAtA []byte) (int, error)

func (*OTPInfo) MarshalToSizedBuffer

func (m *OTPInfo) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*OTPInfo) ProtoMessage

func (*OTPInfo) ProtoMessage()

func (*OTPInfo) Reset

func (m *OTPInfo) Reset()

func (*OTPInfo) Size

func (m *OTPInfo) Size() (n int)

func (*OTPInfo) String

func (this *OTPInfo) String() string

func (*OTPInfo) Unmarshal

func (m *OTPInfo) Unmarshal(dAtA []byte) error

func (*OTPInfo) XXX_DiscardUnknown

func (m *OTPInfo) XXX_DiscardUnknown()

func (*OTPInfo) XXX_Marshal

func (m *OTPInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OTPInfo) XXX_Merge

func (m *OTPInfo) XXX_Merge(src proto.Message)

func (*OTPInfo) XXX_Size

func (m *OTPInfo) XXX_Size() int

func (*OTPInfo) XXX_Unmarshal

func (m *OTPInfo) XXX_Unmarshal(b []byte) error

type OnChainGuardianState

type OnChainGuardianState uint32

OnChainGuardianState represents the on chain state of the guardian

const (
	// ActiveGuardian represents an active guardian on chain
	ActiveGuardian OnChainGuardianState = iota
	// PendingGuardian represents a pending guardian on chain
	PendingGuardian
	// MissingGuardian represents a guardian missing from chain
	MissingGuardian
)

type PubkeyConverter

type PubkeyConverter interface {
	Len() int
	Decode(humanReadable string) ([]byte, error)
	Encode(pkBytes []byte) string
	IsInterfaceNil() bool
}

PubkeyConverter can convert public key bytes from a human-readable form

type RedisConnType

type RedisConnType string

RedisConnType defines the redis connection type

const (
	// RedisInstanceConnType specifies a redis connection to a single instance
	RedisInstanceConnType RedisConnType = "instance"

	// RedisSentinelConnType specifies a redis connection to a setup with sentinel
	RedisSentinelConnType RedisConnType = "sentinel"
)

type ServiceResolver

type ServiceResolver interface {
	RegisterUser(userAddress core.AddressHandler, request requests.RegistrationPayload) (*requests.OTP, string, error)
	VerifyCode(userAddress core.AddressHandler, userIp string, request requests.VerificationPayload) (*requests.OTPCodeVerifyData, error)
	SignTransaction(userIp string, request requests.SignTransaction) ([]byte, *requests.OTPCodeVerifyData, error)
	SignMultipleTransactions(userIp string, request requests.SignMultipleTransactions) ([][]byte, *requests.OTPCodeVerifyData, error)
	RegisteredUsers() (uint32, error)
	TcsConfig() *TcsConfig
	IsInterfaceNil() bool
}

ServiceResolver defines the methods available for a service

type StatusMetricsHandler

type StatusMetricsHandler interface {
	AddRequestData(path string, duration time.Duration, status int)
	GetAll() map[string]*requests.EndpointMetricsResponse
	GetMetricsForPrometheus() string
	IsInterfaceNil() bool
}

StatusMetricsHandler defines the behavior of a component that handles status metrics

type StorageWithIndex

type StorageWithIndex interface {
	AllocateIndex(address []byte) (uint32, error)
	Put(key, data []byte) error
	Get(key []byte) ([]byte, error)
	Has(key []byte) error
	Close() error
	Count() (uint32, error)
	IsInterfaceNil() bool
}

StorageWithIndex defines the methods for a component that holds multiple BucketIndexHandler

type Storer

type Storer interface {
	Put(key, data []byte) error
	Get(key []byte) ([]byte, error)
	Has(key []byte) error
	SearchFirst(key []byte) ([]byte, error)
	Remove(key []byte) error
	ClearCache()
	Close() error
	IsInterfaceNil() bool
}

Storer provides storage services in a two layered storage construct, where the first layer is represented by a cache and second layer by a persistent storage (DB-like)

type TcsConfig

type TcsConfig struct {
	OTPDelay         uint64
	BackoffWrongCode uint64
}

TcsConfig represents the TCS configuration to be exposed to the user

type UserInfo

type UserInfo struct {
	Index          uint32       `protobuf:"varint,1,opt,name=Index,proto3" json:"Index,omitempty"`
	FirstGuardian  GuardianInfo `protobuf:"bytes,2,opt,name=FirstGuardian,proto3" json:"FirstGuardian"`
	SecondGuardian GuardianInfo `protobuf:"bytes,3,opt,name=SecondGuardian,proto3" json:"SecondGuardian"`
}

UserInfo holds info about both user's guardians and its unique index

func (*UserInfo) Descriptor

func (*UserInfo) Descriptor() ([]byte, []int)

func (*UserInfo) Equal

func (this *UserInfo) Equal(that interface{}) bool

func (*UserInfo) GetFirstGuardian

func (m *UserInfo) GetFirstGuardian() GuardianInfo

func (*UserInfo) GetIndex

func (m *UserInfo) GetIndex() uint32

func (*UserInfo) GetSecondGuardian

func (m *UserInfo) GetSecondGuardian() GuardianInfo

func (*UserInfo) GoString

func (this *UserInfo) GoString() string

func (*UserInfo) Marshal

func (m *UserInfo) Marshal() (dAtA []byte, err error)

func (*UserInfo) MarshalTo

func (m *UserInfo) MarshalTo(dAtA []byte) (int, error)

func (*UserInfo) MarshalToSizedBuffer

func (m *UserInfo) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*UserInfo) ProtoMessage

func (*UserInfo) ProtoMessage()

func (*UserInfo) Reset

func (m *UserInfo) Reset()

func (*UserInfo) Size

func (m *UserInfo) Size() (n int)

func (*UserInfo) String

func (this *UserInfo) String() string

func (*UserInfo) Unmarshal

func (m *UserInfo) Unmarshal(dAtA []byte) error

func (*UserInfo) XXX_DiscardUnknown

func (m *UserInfo) XXX_DiscardUnknown()

func (*UserInfo) XXX_Marshal

func (m *UserInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserInfo) XXX_Merge

func (m *UserInfo) XXX_Merge(src proto.Message)

func (*UserInfo) XXX_Size

func (m *UserInfo) XXX_Size() int

func (*UserInfo) XXX_Unmarshal

func (m *UserInfo) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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