account

package module
v0.0.0-...-81fe9aa Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: GPL-2.0 Imports: 20 Imported by: 18

Documentation

Index

Constants

View Source
const (
	AccPrefix       = "BM"
	AccIDLen        = 40
	SocketPortInit  = 52000
	SocketPortRange = 12000
)
View Source
const (
	WalletVersion = 1
)

Variables

View Source
var (
	EConvertCurvePubKey = fmt.Errorf("convert ed25519 public key to curve25519 public key failed")
)
View Source
var (
	EInvalidID = fmt.Errorf("invalid ID")
)
View Source
var KP = struct {
	S int
	N int
	R int
	P int
	L int
}{
	S: 8,
	N: 1 << 15,
	R: 8,
	P: 1,
	L: 32,
}

Functions

func AESKey

func AESKey(salt []byte, password string) ([]byte, error)

func Decrypt

func Decrypt(key []byte, cipherTxt []byte) ([]byte, error)

func DecryptAndIV

func DecryptAndIV(key []byte, cipherTxt []byte) (iv, plainTxt []byte, err error)

func DecryptSubPriKey

func DecryptSubPriKey(pk ed25519.PublicKey, cpTxt, auth string) (ed25519.PrivateKey, error)

func Encrypt

func Encrypt(key []byte, plainTxt []byte) ([]byte, error)

func EncryptSubPriKey

func EncryptSubPriKey(priKey ed25519.PrivateKey, pubKey ed25519.PublicKey, auth string) (string, error)

func EncryptWithIV

func EncryptWithIV(key, iv, plainTxt []byte) ([]byte, error)

func GenerateAesKey

func GenerateAesKey(peerPub []byte, key ed25519.PrivateKey) ([]byte, error)

func LoadWallet

func LoadWallet(wPath string, wallet Wallet) error

func LoadWalletFromJson

func LoadWalletFromJson(jsonStr string, wallet Wallet) error

func PrivateKeyToCurve25519

func PrivateKeyToCurve25519(curve25519Private *[32]byte, privateKey *[64]byte)

func PublicKeyToCurve25519

func PublicKeyToCurve25519(curve25519Public *[32]byte, publicKey *[32]byte) bool

func RecoverJson

func RecoverJson(sig []byte, v interface{}) common.Address

func VerifyAbiSig

func VerifyAbiSig(mainAddr common.Address, sig []byte, msg []byte) bool

func VerifyJsonSig

func VerifyJsonSig(mainAddr common.Address, sig []byte, v interface{}) bool

func VerifySubSig

func VerifySubSig(subAddr ID, sig []byte, v interface{}) bool

Types

type ID

type ID string

func ToIDByBytes

func ToIDByBytes(key []byte) ID

func ToIDByStr

func ToIDByStr(addr string) (ID, error)

func (ID) IsValid

func (id ID) IsValid() bool

func (ID) String

func (id ID) String() string

func (ID) ToArray

func (id ID) ToArray() [32]byte

func (ID) ToPubKey

func (id ID) ToPubKey() ed25519.PublicKey

func (ID) ToServerPort

func (id ID) ToServerPort() uint16

type PayableWallet

type PayableWallet struct {
	Version   int                 `json:"version"`
	MainAddr  common.Address      `json:"mainAddress"`
	Crypto    keystore.CryptoJSON `json:"crypto"`
	SubAddr   ID                  `json:"subAddress"`
	SubCipher string              `json:"subCipher"`
	// contains filtered or unexported fields
}

func (*PayableWallet) Close

func (pw *PayableWallet) Close()

func (*PayableWallet) CryptKey

func (pw *PayableWallet) CryptKey() ed25519.PrivateKey

func (*PayableWallet) ExportEth

func (pw *PayableWallet) ExportEth(auth, eAuth, path string) error

func (*PayableWallet) IsOpen

func (pw *PayableWallet) IsOpen() bool

func (*PayableWallet) MainAddress

func (pw *PayableWallet) MainAddress() common.Address

func (*PayableWallet) Open

func (pw *PayableWallet) Open(auth string) error

func (*PayableWallet) SaveToPath

func (pw *PayableWallet) SaveToPath(wPath string) error

func (*PayableWallet) Sign

func (pw *PayableWallet) Sign(v []byte) ([]byte, error)

func (*PayableWallet) SignJSONSub

func (pw *PayableWallet) SignJSONSub(v interface{}) []byte

func (*PayableWallet) SignJson

func (pw *PayableWallet) SignJson(v interface{}) ([]byte, error)

func (*PayableWallet) SignKey

func (pw *PayableWallet) SignKey() *ecdsa.PrivateKey

func (*PayableWallet) SignSub

func (pw *PayableWallet) SignSub(v []byte) []byte

func (*PayableWallet) String

func (pw *PayableWallet) String() string

func (*PayableWallet) SubAddress

func (pw *PayableWallet) SubAddress() ID

type PipeCryptKey

type PipeCryptKey [32]byte

type Wallet

type Wallet interface {
	SignKey() *ecdsa.PrivateKey
	CryptKey() ed25519.PrivateKey

	MainAddress() common.Address
	SubAddress() ID

	SignJson(v interface{}) ([]byte, error)
	Sign(v []byte) ([]byte, error)
	SignJSONSub(v interface{}) []byte
	SignSub(v []byte) []byte

	Open(auth string) error
	IsOpen() bool
	SaveToPath(wPath string) error
	String() string
	Close()
	ExportEth(auth, eAuth, path string) error
}

func NewPayableWallet

func NewPayableWallet(auth string) (Wallet, error)

type WalletKey

type WalletKey struct {
	SubPriKey  ed25519.PrivateKey
	MainPriKey *ecdsa.PrivateKey
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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