Documentation ¶
Index ¶
- Constants
- Variables
- func Base58checkDecode(address string, fix []byte) ([]byte, error)
- func Base58checkEncode(data []byte, fix []byte) string
- func Decode(input string, alphabet *Alphabet) ([]byte, error)
- func DerivedPrivateKeyBytes(seed []byte, coinType CoinType, serializes uint32) ([]byte, error)
- func Encode(input []byte, alphabet *Alphabet) string
- func GetMultiSigShareData(owpub string) (string, error)
- type Alphabet
- type CoinType
- type ExtendedKey
- func DerivedPrivateKeyWithPath(seed []byte, derivedPath string, curveType uint32) (*ExtendedKey, error)
- func GetCoinRootPublicKey(seed []byte, coinType CoinType) (*ExtendedKey, error)
- func InitRootKeyFromSeed(seed []byte, curveType uint32) (*ExtendedKey, error)
- func NewExtendedKey(key, chainCode, parentFP []byte, depth uint8, serializes uint32, ...) *ExtendedKey
- func OWDecode(data string) (*ExtendedKey, error)
- func (k *ExtendedKey) DerivedPublicKeyFromPath(derivedPath string) (*ExtendedKey, error)
- func (k *ExtendedKey) DerivedPublicKeyFromSerializes(serializes uint32) (*ExtendedKey, error)
- func (k *ExtendedKey) GenPrivateChild(serializes uint32) (*ExtendedKey, error)
- func (k *ExtendedKey) GenPublicChild(serializes uint32) (*ExtendedKey, error)
- func (k *ExtendedKey) GetPrivateKeyBytes() ([]byte, error)
- func (k *ExtendedKey) GetPublicKey() *ExtendedKey
- func (k *ExtendedKey) GetPublicKeyBytes() []byte
- func (k *ExtendedKey) GetUncompressedPublicKeyBytes() []byte
- func (k *ExtendedKey) OWEncode() string
- type MultiSigShare
Constants ¶
View Source
const ( // 用于产生根密钥的种子长度 MinRecommendedSeedLen = 16 MAxRecommendedSeedLen = 64 // 强化子密钥索引号起始值 HardenedKeyStart uint32 = 0x80000000 )
Variables ¶
View Source
var ( BitcoinAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") IPFSAlphabet = NewAlphabet("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") FlickrAlphabet = NewAlphabet("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ") RippleAlphabet = NewAlphabet("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz") )
Alphabet: copy from https://en.wikipedia.org/wiki/Base58
View Source
var ( // 公钥不能进行强化扩展 ErrDeriveHardFromPublic = errors.New("cannot derive a hardened key from a public key") // 超过最大扩展深度 ErrDeriveBeyondMaxDepth = errors.New("cannot derive a key with more than 255 indices in its path") // 公钥无法扩展子私钥 ErrNotPrivExtKey = errors.New("unable to create private keys from a public extended key") // 该索引号无法扩展,应尝试下一个 ErrInvalidChild = errors.New("the extended key at this index is invalid") // 种子长度错误 ErrInvalidSeedLen = fmt.Errorf("seed length should be between 16 bytes and 64 bytes!") // reserve ErrBadChecksum = errors.New("bad extended key checksum") // reserve ErrInvalidKeyLen = errors.New("the provided serialized extended key length is invalid") )
View Source
var ( ErrInvalidDerivedPath = errors.New("Invalid DerivedPath") ErrKeyIsNotPrivate = errors.New("The key is not private") )
View Source
var ( Bitcoin = CoinType{uint32(0), owcrypt.ECC_CURVE_SECP256K1} Ethereum = CoinType{uint32(1), owcrypt.ECC_CURVE_SECP256K1} )
XXX[0]:hd扩展索引 XXX[1]:曲线类型
View Source
var ( BitcoinPubkeyPrefix = []byte{0} BitcoinScriptPrefix = []byte{5} )
View Source
var ChainPrefix = []byte{0x08, 0x61, 0x24, 0x96, 0x12, 0xae, 0x5c}
View Source
var (
ErrInvalidAddress = errors.New("address is invalid")
)
View Source
var (
ErrorInvalidBase58String = errors.New("invalid base58 string")
)
Errors
Functions ¶
func Base58checkEncode ¶
func DerivedPrivateKeyBytes ¶
func GetMultiSigShareData ¶ added in v1.1.13
Types ¶
type Alphabet ¶
type Alphabet struct {
// contains filtered or unexported fields
}
Alphabet The base58 alphabet object.
func NewAlphabet ¶
NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.
type ExtendedKey ¶
type ExtendedKey struct {
// contains filtered or unexported fields
}
ExtendedKey 扩展密钥结构体
func DerivedPrivateKeyWithPath ¶
func DerivedPrivateKeyWithPath(seed []byte, derivedPath string, curveType uint32) (*ExtendedKey, error)
接口仅接受绝对路径
func GetCoinRootPublicKey ¶
func GetCoinRootPublicKey(seed []byte, coinType CoinType) (*ExtendedKey, error)
func InitRootKeyFromSeed ¶
func InitRootKeyFromSeed(seed []byte, curveType uint32) (*ExtendedKey, error)
InitRootKeyFromSeed 通过种子获得根私钥
func NewExtendedKey ¶
func NewExtendedKey(key, chainCode, parentFP []byte, depth uint8, serializes uint32, isPrivate bool, curveType uint32) *ExtendedKey
NewExtendedKey 初始化密钥结构体
func OWDecode ¶
func OWDecode(data string) (*ExtendedKey, error)
func (*ExtendedKey) DerivedPublicKeyFromPath ¶
func (k *ExtendedKey) DerivedPublicKeyFromPath(derivedPath string) (*ExtendedKey, error)
DerivedPublicKeyFromPath 从当前密钥k按照相对路径进行扩展
func (*ExtendedKey) DerivedPublicKeyFromSerializes ¶
func (k *ExtendedKey) DerivedPublicKeyFromSerializes(serializes uint32) (*ExtendedKey, error)
DerivedPublicKeyFromSerializes 普通密钥扩展的单层深度派生
func (*ExtendedKey) GenPrivateChild ¶
func (k *ExtendedKey) GenPrivateChild(serializes uint32) (*ExtendedKey, error)
GenPrivateChild 通过k扩展子私钥
func (*ExtendedKey) GenPublicChild ¶
func (k *ExtendedKey) GenPublicChild(serializes uint32) (*ExtendedKey, error)
GenPublicChild 通过k扩展子公钥
func (*ExtendedKey) GetPrivateKeyBytes ¶
func (k *ExtendedKey) GetPrivateKeyBytes() ([]byte, error)
GetPrivateKey 获取当前密钥对应的私钥数组
func (*ExtendedKey) GetPublicKey ¶
func (k *ExtendedKey) GetPublicKey() *ExtendedKey
GePublicKey 获取公钥结构体
func (*ExtendedKey) GetPublicKeyBytes ¶
func (k *ExtendedKey) GetPublicKeyBytes() []byte
GetPublicKeyBytes 获取当前密钥对应的公钥
func (*ExtendedKey) GetUncompressedPublicKeyBytes ¶
func (k *ExtendedKey) GetUncompressedPublicKeyBytes() []byte
//GetPublicKeyUncompressedBytes 获取当前密钥对应的公钥(未压缩,且去除04)
func (*ExtendedKey) OWEncode ¶
func (k *ExtendedKey) OWEncode() string
type MultiSigShare ¶ added in v1.1.13
type MultiSigShare struct {}
func ChainDecode ¶ added in v1.1.13
func ChainDecode(owchain string) (*MultiSigShare, error)
func (MultiSigShare) ChianEncode ¶ added in v1.1.13
func (ms MultiSigShare) ChianEncode() string
Click to show internal directories.
Click to hide internal directories.