common

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package base91 implements base91 encoding, fork from https://github.com/mtraver/base91

Index

Constants

View Source
const (
	OperationTypeWrapper     = 0
	OperationTypeKeygenInput = 1
	OperationTypeSignInput   = 2

	OperationTypeKeygenOutput = 11
	OperationTypeSignOutput   = 12

	CurveSecp256k1ECDSABitcoin   = 1
	CurveSecp256k1ECDSAEthereum  = 2
	CurveSecp256k1SchnorrBitcoin = 3
	CurveEdwards25519Default     = 4
	CurveEdwards25519Mixin       = 5

	CurveSecp256k1ECDSALitecoin    = 100 + CurveSecp256k1ECDSABitcoin
	CurveSecp256k1ECDSABitcoinCash = 110 + CurveSecp256k1ECDSABitcoin
	CurveSecp256k1ECDSAMVM         = 100 + CurveSecp256k1ECDSAEthereum
	CurveSecp256k1ECDSAPolygon     = 110 + CurveSecp256k1ECDSAEthereum
)
View Source
const (
	RequestRoleHolder   = 1
	RequestRoleSigner   = 2
	RequestRoleObserver = 3

	RequestFlagNone              = 0
	RequestFlagCustomObserverKey = 1

	RequestStateInitial = 1
	RequestStatePending = 2
	RequestStateDone    = 3
	RequestStateFailed  = 4

	// Observer can terminate all signer and keeper nodes
	ActionTerminate = 100

	ActionObserverAddKey              = 101
	ActionObserverRequestSignerKeys   = 102
	ActionObserverUpdateNetworkStatus = 103
	ActionObserverHolderDeposit       = 104
	ActionObserverSetOperationParams  = 106

	// For all Bitcoin like chains
	ActionBitcoinSafeProposeAccount     = 110
	ActionBitcoinSafeApproveAccount     = 111
	ActionBitcoinSafeProposeTransaction = 112
	ActionBitcoinSafeApproveTransaction = 113
	ActionBitcoinSafeRevokeTransaction  = 114
	ActionBitcoinSafeCloseAccount       = 115

	// For Mixin Kernel mainnet
	ActionMixinSafeProposeAccount     = 120
	ActionMixinSafeApproveAccount     = 121
	ActionMixinSafeProposeTransaction = 122
	ActionMixinSafeApproveTransaction = 123
	ActionMixinSafeRevokeTransaction  = 124

	// For all Ethereum like chains
	ActionEthereumSafeProposeAccount     = 130
	ActionEthereumSafeApproveAccount     = 131
	ActionEthereumSafeProposeTransaction = 132
	ActionEthereumSafeApproveTransaction = 133
	ActionEthereumSafeRevokeTransaction  = 134
	ActionEthereumSafeCloseAccount       = 135
	ActionEthereumSafeRefundTransaction  = 136

	FlagProposeNormalTransaction   = 0
	FlagProposeRecoveryTransaction = 1
)

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(secret, b []byte) []byte

func AESEncrypt

func AESEncrypt(secret, b []byte, sid string) []byte

func Base91Decode

func Base91Decode(src string) ([]byte, error)

func Base91Encode

func Base91Encode(src []byte) string

func CheckRetryableError added in v0.9.12

func CheckRetryableError(err error) bool

func CheckTestEnvironment

func CheckTestEnvironment(ctx context.Context) bool

func CheckUnique

func CheckUnique(args ...any) bool

func CreateObjectUntilSufficient added in v0.9.17

func CreateObjectUntilSufficient(ctx context.Context, memo, traceId string, uid, sid, priv, pin, pinToken string) (*bot.Snapshot, error)

func DecodeHexOrPanic

func DecodeHexOrPanic(s string) []byte

func DecodeMixinObjectExtra added in v0.8.0

func DecodeMixinObjectExtra(extra []byte) []byte

func ECDHEd25519

func ECDHEd25519(priv, pub string) [32]byte

func EnableTestEnvironment

func EnableTestEnvironment(ctx context.Context) context.Context

func ExpandTilde added in v0.9.6

func ExpandTilde(path string) string

func Fingerprint added in v0.3.0

func Fingerprint(public string) []byte

func HandleCORS added in v0.9.3

func HandleCORS(handler http.Handler) http.Handler

TODO may consider a whitelist in the case of Ethereum scams

func HandleNotFound added in v0.9.3

func HandleNotFound(w http.ResponseWriter, r *http.Request)

func HandlePanic added in v0.9.3

func HandlePanic(w http.ResponseWriter, r *http.Request, rcv any)

func MarshalJSONOrPanic added in v0.9.3

func MarshalJSONOrPanic(v any) []byte

func MarshalPanic

func MarshalPanic(m encoding.BinaryMarshaler) []byte

func NormalizeCurve added in v0.2.0

func NormalizeCurve(crv uint8) uint8

func OpenSQLite3ReadOnlyStore

func OpenSQLite3ReadOnlyStore(path string) (*sql.DB, error)

func OpenSQLite3Store

func OpenSQLite3Store(path, schema string) (*sql.DB, error)

func ReadKernelTransaction

func ReadKernelTransaction(rpc string, tx crypto.Hash) (*common.VersionedTransaction, error)

func RenderError added in v0.9.3

func RenderError(w http.ResponseWriter, r *http.Request, err error)

func RenderJSON added in v0.9.3

func RenderJSON(w http.ResponseWriter, r *http.Request, status int, data any)

func SendTransaction

func SendTransaction(ctx context.Context, client *mixin.Client, assetId string, receivers []string, threshold int, amount decimal.Decimal, memo, traceId string, pin string) error

func SendTransactionUntilSufficient

func SendTransactionUntilSufficient(ctx context.Context, client *mixin.Client, assetId string, receivers []string, threshold int, amount decimal.Decimal, memo, traceId string, pin string) error

func StateName added in v0.3.0

func StateName(state int) string

func UniqueId added in v0.11.0

func UniqueId(a, b string) string

func VerifyKernelTransaction

func VerifyKernelTransaction(rpc string, out *mtg.Output, timeout time.Duration) error

TODO the output should include the snapshot signature, then it can just be verified against the active kernel nodes public key

Types

type AccountProposal added in v0.8.0

type AccountProposal struct {
	Receivers []string
	Threshold byte
	Timelock  time.Duration
	Observer  string
}

type Encoding

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

An Encoding is a base 91 encoding/decoding scheme defined by a 91-character alphabet.

func (*Encoding) Decode

func (enc *Encoding) Decode(dst, src []byte) (int, error)

Decode decodes src using the encoding enc. It writes at most DecodedLen(len(src)) bytes to dst and returns the number of bytes written. If src contains invalid base91 data, it will return the number of bytes successfully written and CorruptInputError.

func (*Encoding) DecodedLen

func (enc *Encoding) DecodedLen(n int) int

DecodedLen returns the maximum length in bytes of the decoded data corresponding to n bytes of base91-encoded data.

func (*Encoding) Encode

func (enc *Encoding) Encode(dst, src []byte) int

Encode encodes src using the encoding enc, writing bytes to dst. It returns the number of bytes written, because the exact output size cannot be known before encoding takes place. EncodedLen(len(src)) may be used to determine an upper bound on the output size when allocating a dst slice.

func (*Encoding) EncodedLen

func (enc *Encoding) EncodedLen(n int) int

EncodedLen returns an upper bound on the length in bytes of the base91 encoding of an input buffer of length n. The true encoded length may be shorter.

type Operation

type Operation struct {
	Id     string
	Type   uint8
	Curve  uint8
	Public string
	Extra  []byte
}

func DecodeOperation

func DecodeOperation(b []byte) (*Operation, error)

func (*Operation) Encode

func (o *Operation) Encode() []byte

TODO compact format for different type

func (*Operation) IdBytes

func (o *Operation) IdBytes() []byte

type Request

type Request struct {
	Id         string
	MixinHash  crypto.Hash
	MixinIndex int
	AssetId    string
	Amount     decimal.Decimal
	Role       uint8
	Action     uint8
	Curve      uint8
	Holder     string
	Extra      string
	State      uint8
	CreatedAt  time.Time
}

func DecodeRequest

func DecodeRequest(out *mtg.Output, b []byte, role uint8) (*Request, error)

func (*Request) Operation

func (req *Request) Operation() *Operation

func (*Request) ParseMixinRecipient

func (req *Request) ParseMixinRecipient(extra []byte) (*AccountProposal, error)

func (*Request) VerifyFormat

func (r *Request) VerifyFormat() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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