comm

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: GPL-2.0 Imports: 19 Imported by: 4

Documentation

Index

Constants

View Source
const (
	AccPrefix = "BS"
	AccLen    = 20
)
View Source
const (
	WalletVersion = "1"
)

Variables

View Source
var (
	WOpenErr    = errors.New("open wallet failed")
	WVerifyErr  = errors.New("verify signature failed")
	WInvalidSig = errors.New("invalid signature data")
)
View Source
var (
	InvalidAddr = errors.New("invalid address")
)
View Source
var KP = KeyParam{
	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 Encrypt

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

func PrivateKeyToCurve25519

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

func RecoverPub

func RecoverPub(addr WalletAddr, suffix string) ([]byte, error)

func VerifyStamp

func VerifyStamp(stamp Stamp) error

Types

type CipherData

type CipherData struct {
	KeyParam  `json:"param"`
	Code      string `json:"code"`
	KeyCrypto string `json:"key_crypto"`
	Salt      string `json:"salt"`
	PriCipher string `json:"pri_cipher"`
}

type KeyParam

type KeyParam struct {
	S int `json:"s"`
	N int `json:"n"`
	R int `json:"r"`
	P int `json:"p"`
	L int `json:"l"`
}

type RawStamp

type RawStamp struct {
	WAddr        WalletAddr     `json:"wallet_addr"`
	SAddr        StampAddr      `json:"stamp_addr"`
	EAddr        common.Address `json:"eth_addr"`
	FromMailAddr string         `json:"from_mail_addr"`
	MsgID        string         `json:"msg_id"`
	No           int            `json:"no"`
	Time         int64          `json:"time"`
}

func (*RawStamp) GetMailID

func (r *RawStamp) GetMailID() string

func (*RawStamp) GetMailSender

func (r *RawStamp) GetMailSender() string

func (*RawStamp) GetStampAddr

func (r *RawStamp) GetStampAddr() StampAddr

func (*RawStamp) GetWalletAddr

func (r *RawStamp) GetWalletAddr() WalletAddr

func (*RawStamp) IsValidInitData

func (r *RawStamp) IsValidInitData() bool

func (*RawStamp) SetAddr

func (r *RawStamp) SetAddr(addr WalletAddr)

func (*RawStamp) SetEthAddr

func (r *RawStamp) SetEthAddr(addr common.Address)

func (*RawStamp) SetMsgID

func (r *RawStamp) SetMsgID(id string)

func (*RawStamp) SetNo

func (r *RawStamp) SetNo(no int)

type SDataBase

type SDataBase struct {
	*leveldb.DB
}

func (*SDataBase) AppendString

func (db *SDataBase) AppendString(key string, newV string) error

func (*SDataBase) Del

func (db *SDataBase) Del(key []byte) error

func (*SDataBase) GetInt

func (db *SDataBase) GetInt(key string) uint64

func (*SDataBase) GetJsonObj

func (db *SDataBase) GetJsonObj(key []byte, v interface{}) error

func (*SDataBase) GetString

func (db *SDataBase) GetString(key string) string

func (*SDataBase) SaveInt

func (db *SDataBase) SaveInt(key string, val uint64) error

func (*SDataBase) SaveJsonObj

func (db *SDataBase) SaveJsonObj(key []byte, v interface{}) error

func (*SDataBase) SaveString

func (db *SDataBase) SaveString(key string, val string) error

func (*SDataBase) TrimString added in v1.0.2

func (db *SDataBase) TrimString(key string, trimV string) error

type SimpleStamp

type SimpleStamp struct {
	Data *RawStamp
	Sig  *SimpleStampSig
}

func (*SimpleStamp) RawData

func (ss *SimpleStamp) RawData() StampData

func (*SimpleStamp) Serial

func (ss *SimpleStamp) Serial() string

func (*SimpleStamp) SigData

func (ss *SimpleStamp) SigData() StampSig

type SimpleStampSig

type SimpleStampSig struct {
	SigData   string
	PubSuffix string
}

func (*SimpleStampSig) Data

func (sss *SimpleStampSig) Data() string

func (*SimpleStampSig) Suffix

func (sss *SimpleStampSig) Suffix() string

type SimpleWallet

type SimpleWallet struct {
	NickName string         `json:"nick_name"`
	Version  string         `json:"version"`
	Addr     WalletAddr     `json:"address"`
	EAddr    common.Address `json:"eth_addr"`
	Cipher   *CipherData    `json:"cipher"`
	// contains filtered or unexported fields
}

func (*SimpleWallet) Address

func (sw *SimpleWallet) Address() WalletAddr

func (*SimpleWallet) Close

func (sw *SimpleWallet) Close()

func (*SimpleWallet) EthAddr

func (sw *SimpleWallet) EthAddr() common.Address

func (*SimpleWallet) IsOpen

func (sw *SimpleWallet) IsOpen() bool

func (*SimpleWallet) Name added in v1.0.2

func (sw *SimpleWallet) Name() string

func (*SimpleWallet) Open

func (sw *SimpleWallet) Open(auth string) error

func (*SimpleWallet) SetName added in v1.0.2

func (sw *SimpleWallet) SetName(newName string)

func (*SimpleWallet) Sign

func (sw *SimpleWallet) Sign(s StampData) StampSig

func (*SimpleWallet) String

func (sw *SimpleWallet) String() string

func (*SimpleWallet) Verbose

func (sw *SimpleWallet) Verbose() string

type Stamp

type Stamp interface {
	Serial() string
	RawData() StampData
	SigData() StampSig
}

type StampAddr

type StampAddr string

type StampData

type StampData interface {
	SetMsgID(id string)
	GetMailSender() string
	SetNo(no int)
	GetWalletAddr() WalletAddr
	GetStampAddr() StampAddr
	GetMailID() string
	SetEthAddr(addr common.Address)
	SetAddr(addr WalletAddr)
	IsValidInitData() bool
}

type StampSig

type StampSig interface {
	Data() string
	Suffix() string
}

type Wallet

type Wallet interface {
	Name() string
	SetName(nn string)
	Address() WalletAddr
	Open(auth string) error
	Verbose() string
	Close()
	Sign(s StampData) StampSig
	IsOpen() bool
	EthAddr() common.Address
	fmt.Stringer
}

func CreateWallet

func CreateWallet(auth, name string) (Wallet, error)

func LoadByFile

func LoadByFile(path string) (Wallet, error)

func LoadByJsonData

func LoadByJsonData(jsonStr string) (Wallet, error)

type WalletAddr

type WalletAddr string

func PubToAddr

func PubToAddr(key []byte) (WalletAddr, string)

Jump to

Keyboard shortcuts

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