keys

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	N = 16384
	R = 8
	P = 8
)

Variables

View Source
var KeyCases = []Ktype{
	{
		Passphrase: "neo3-gogogo",
		PrivateKey: "831cb932167332a768f1c898d2cf4586a14aa606b7f078eba028c849c306cce6",
		PublicKey:  "03b7a7f933199f28cc1c48d22a21c78ac3992cf7fceb038a9c670fe55444426619",
		Wif:        "L1caMUAsHr2dKwhqbMpYRcCzmzvZTfYZSCBefgARhz9iimAFRn1z",
		Nep2key:    "6PYXStTdYPTC3XzscAyL3MZikD4hTWgeV1aaDqTSxiWKWfk9VjZcUbm6Uz",
		ScriptHash: "0685cf3f7b1ea94f8f61be3fb8e06d081af34cc9",
		Address:    "NeGMBsEZ44B52dEvnm73ZU2QqLoRmTzMfr",
	},
	{
		Passphrase: "",
		PrivateKey: "82a4ff38f5de304c2fae62d1a736c343816412f7e4fe3badaf5e1e940c8f07c3",
		PublicKey:  "027d73c8b02e446340caceee7a517cddff72440e60c28cbb84884f307760ecad5b",
		Wif:        "L1bfdDaFQErh7gGMz32zgBXZCN65AKeexKzxeEvS7d4Cq6zf2Rpf",
		Nep2key:    "6PYL8gFU1rZZ5qbKqJJAK7fPTvM8RJfEiF8k7ranqjKKgzB3RxxbH1uySg",
		ScriptHash: "97c96fe6fcb153de1293cc5537337b62ab2c84cb",
		Address:    "NeU4hLo5Lgkp4RkZnMbQjbNSLtYYxJ6eZG",
	},
	{
		Passphrase: "密码@👍",
		PrivateKey: "31ab808b68c25377b2068500e264f164d1d75eda748a8e0a98db4c74db181b66",
		PublicKey:  "038a2151948a908cdf2d680eead6512217769e34b9db196574572cb98e273516a1",
		Wif:        "KxtGC6QHFKSiHVLY1ANkwS78ebfhworv6LnkJH2MUxE8AbbgAHVW",
		Nep2key:    "6PYS6KAwfyD26moSEE3L7DvQ4LSjdyy9HA35oC82Yaiu8523HHzYxzxoFc",
		ScriptHash: "8febbbd7e397c2c784b4bdef2992e2bbe6edca65",
		Address:    "NVCCXuVjRKt1ac7ri4WuVC8sDrYeZ6NeCx",
	},
}

Arr contains a set of known keys in Ktype format.

Functions

func PublicKeyToAddress

func PublicKeyToAddress(p *crypto.ECPoint, version byte) string

returns a base58-encoded NEO-specific address based on the key hash.

func PublicKeyToScriptHash

func PublicKeyToScriptHash(p *crypto.ECPoint) *helper.UInt160

returns a NEO-specific hash of the public key.

func ToECDsa

func ToECDsa(key []byte) *ecdsa.PrivateKey

ecdsa converts the private key byte[] to a usable ecdsa.PrivateKey for signing data.

func VerifyMultiSig

func VerifyMultiSig(message []byte, signatures [][]byte, pubKeys []crypto.ECPoint) bool

func VerifySignature

func VerifySignature(message []byte, signature []byte, p *crypto.ECPoint) bool

Verify returns true if the signature is valid and corresponds to the hash and public key

Types

type KeyPair

type KeyPair struct {
	PrivateKey []byte
	PublicKey  *crypto.ECPoint
}

func GenerateKeyPair

func GenerateKeyPair() (*KeyPair, error)

func NewKeyPair

func NewKeyPair(privateKey []byte) (*KeyPair, error)

func NewKeyPairFromNEP2

func NewKeyPairFromNEP2(nep2 string, passphrase string, version byte, N, R, P int) (*KeyPair, error)

func NewKeyPairFromWIF

func NewKeyPairFromWIF(wif string) (*KeyPair, error)

func (*KeyPair) CompareTo

func (p *KeyPair) CompareTo(q *KeyPair) int

func (*KeyPair) ExistsIn

func (p *KeyPair) ExistsIn(list []KeyPair) bool

ExistsIn returns true if p is in list

func (*KeyPair) Export

func (p *KeyPair) Export() string

export wif string

func (*KeyPair) ExportWithPassword

func (p *KeyPair) ExportWithPassword(password string, version byte, N, R, P int) (string, error)

export nep2 key string

func (*KeyPair) Sign

func (p *KeyPair) Sign(message []byte) ([]byte, error)

sign message with KeyPair

func (*KeyPair) String

func (p *KeyPair) String() string

String implements the Stringer interface.

func (*KeyPair) ToECDsa

func (p *KeyPair) ToECDsa() *ecdsa.PrivateKey

ecdsa converts the key to a usable ecdsa.PrivateKey for signing data.

type KeyPairSlice

type KeyPairSlice []KeyPair

func (KeyPairSlice) Len

func (kps KeyPairSlice) Len() int

func (KeyPairSlice) Less

func (kps KeyPairSlice) Less(i, j int) bool

func (KeyPairSlice) Swap

func (kps KeyPairSlice) Swap(i, j int)

type Ktype

type Ktype struct {
	Address,
	PrivateKey,
	PublicKey,
	Wif,
	Passphrase,
	Nep2key,
	ScriptHash string
}

Ktype represents key test case values (different encodings of the key).

Jump to

Keyboard shortcuts

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