wallet

package
Version: v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EAddrTypeDefault the type of default public address
	EAddrTypeDefault = byte(iota + 1)
	// EAddrTypeIBS identity-based signature 基于身份的签名,不同时间,使用不同私钥签名(签名时间是消息的前8个字节)
	EAddrTypeIBS
)
View Source
const (
	// AddressLength address length
	AddressLength = 24
	// SignLen default length of sign
	SignLen = 65

	// TimeDuration EAddrTypeIBS的子私钥有效时间,一个月
	TimeDuration = 31558150000 / 12
)

Variables

This section is empty.

Functions

func GetDeadlineOfIBS

func GetDeadlineOfIBS(addr []byte) uint64

GetDeadlineOfIBS get deadline of child key by public address

func GetHash

func GetHash(in []byte) []byte

GetHash get data hash

func GetPublicKey

func GetPublicKey(in []byte) []byte

GetPublicKey 通过私钥获得公钥

func NewChildPrivateKeyOfIBS

func NewChildPrivateKeyOfIBS(privK []byte, t uint64) (cPriKey []byte, signPre []byte)

NewChildPrivateKeyOfIBS create child key of the address,time(ms)

func NewPrivateKey

func NewPrivateKey() []byte

NewPrivateKey 获取一个随机的私钥

func PublicKeyToAddress

func PublicKeyToAddress(in []byte, addrType uint8) []byte

PublicKeyToAddress 将公钥转成钱包地址

func Recover

func Recover(address, sign, msg []byte) bool

Recover 通过签名信息,提取钱包地址

func SaveWallet

func SaveWallet(file, passwd string, addr, privKey, prefix []byte) error

SaveWallet 将私钥信息和地址保存到文件中

func Sign

func Sign(privK, msg []byte) []byte

Sign 用私钥对msg进行签名

Types

type EcdsaKey

type EcdsaKey struct {
	Type string
}

EcdsaKey ecdsa key

func (*EcdsaKey) GetPublic

func (k *EcdsaKey) GetPublic(privKey []byte) []byte

GetPublic get public key

func (*EcdsaKey) GetType

func (k *EcdsaKey) GetType() string

GetType get type

func (*EcdsaKey) Sign

func (k *EcdsaKey) Sign(data, privKey []byte) []byte

Sign sign data

func (*EcdsaKey) Verify

func (k *EcdsaKey) Verify(data, sig, pubKey []byte) bool

Verify verify

type TWallet

type TWallet struct {
	Tag        string `json:"tag,omitempty"`
	AddressStr string `json:"address_str,omitempty"`
	Address    []byte `json:"address,omitempty"`
	Key        []byte `json:"key,omitempty"`
	SignPrefix []byte `json:"sign_prefix,omitempty"`
}

TWallet 钱包存储的结构体

func LoadWallet

func LoadWallet(file, password string) (TWallet, error)

LoadWallet 从文件中加载钱包信息

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL