com

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

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

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 Address, suffix string) ([]byte, error)

func VerifyStamp

func VerifyStamp(stamp Stamp) error

Types

type Address

type Address string

func PubToAddr

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

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        Address `json:"wallet_addr"`
	SAddr        string  `json:"stamp_addr"`
	FromMailAddr string  `json:"from_mail_addr"`
	MsgID        string  `json:"msg_id"`
	No           int     `json:"no"`
	Time         int64   `json:"time"`
}

type Stamp

type Stamp struct {
	Data *RawStamp
	Sig  *StampSig
}

type StampSig

type StampSig struct {
	SigData   string
	PubSuffix string
}

func (*StampSig) Data

func (ss *StampSig) Data() string

func (*StampSig) Suffix

func (ss *StampSig) Suffix() string

type Wallet

type Wallet struct {
	NickName string      `json:"nick_name"`
	Version  string      `json:"version"`
	Addr     Address     `json:"address"`
	Cipher   *CipherData `json:"cipher"`
	// contains filtered or unexported fields
}

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)

func (*Wallet) Address

func (sw *Wallet) Address() Address

func (*Wallet) Close

func (sw *Wallet) Close()

func (*Wallet) IsOpen

func (sw *Wallet) IsOpen() bool

func (*Wallet) Name

func (sw *Wallet) Name() string

func (*Wallet) Open

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

func (*Wallet) SetName

func (sw *Wallet) SetName(newName string)

func (*Wallet) Sign

func (sw *Wallet) Sign(s *RawStamp) *StampSig

func (*Wallet) String

func (sw *Wallet) String() string

func (*Wallet) Verbose

func (sw *Wallet) Verbose() string

Jump to

Keyboard shortcuts

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