Documentation ¶
Index ¶
- Constants
- func NEP2Encrypt(priv *PrivateKey, passphrase string) (s string, err error)
- func WIFEncode(key []byte, version byte, compressed bool) (s string, err error)
- type PrivateKey
- func NEP2Decrypt(key, passphrase string) (*PrivateKey, error)
- func NewPrivateKey() (*PrivateKey, error)
- func NewPrivateKeyFromASN1(b []byte) (*PrivateKey, error)
- func NewPrivateKeyFromBytes(b []byte) (*PrivateKey, error)
- func NewPrivateKeyFromHex(str string) (*PrivateKey, error)
- func NewPrivateKeyFromWIF(wif string) (*PrivateKey, error)
- type PublicKey
- func (p *PublicKey) Address() string
- func (p *PublicKey) Bytes() []byte
- func (p *PublicKey) Cmp(key *PublicKey) int
- func (p *PublicKey) DecodeBinary(r *io.BinReader)
- func (p *PublicKey) DecodeBytes(data []byte) error
- func (p *PublicKey) EncodeBinary(w *io.BinWriter)
- func (p *PublicKey) Equal(key *PublicKey) bool
- func (p *PublicKey) GetScriptHash() util.Uint160
- func (p *PublicKey) GetVerificationScript() []byte
- func (p *PublicKey) IsInfinity() bool
- func (p PublicKey) MarshalJSON() ([]byte, error)
- func (p *PublicKey) String() string
- func (p *PublicKey) UncompressedBytes() []byte
- func (p *PublicKey) UnmarshalJSON(data []byte) error
- func (p *PublicKey) Verify(signature []byte, hash []byte) bool
- type PublicKeys
- func (keys *PublicKeys) Bytes() []byte
- func (keys PublicKeys) Contains(pKey *PublicKey) bool
- func (keys PublicKeys) Copy() PublicKeys
- func (keys *PublicKeys) DecodeBytes(data []byte) error
- func (keys PublicKeys) Len() int
- func (keys PublicKeys) Less(i, j int) bool
- func (keys PublicKeys) Swap(i, j int)
- func (keys PublicKeys) Unique() PublicKeys
- type ScryptParams
- type WIF
Constants ¶
const (
// WIFVersion is the version used to decode and encode WIF keys.
WIFVersion = 0x80
)
Variables ¶
This section is empty.
Functions ¶
func NEP2Encrypt ¶
func NEP2Encrypt(priv *PrivateKey, passphrase string) (s string, err error)
NEP2Encrypt encrypts a the PrivateKey using a given passphrase under the NEP-2 standard.
Types ¶
type PrivateKey ¶
type PrivateKey struct {
ecdsa.PrivateKey
}
PrivateKey represents a NEO private key and provides a high level API around ecdsa.PrivateKey.
func NEP2Decrypt ¶
func NEP2Decrypt(key, passphrase string) (*PrivateKey, error)
NEP2Decrypt decrypts an encrypted key using a given passphrase under the NEP-2 standard.
func NewPrivateKey ¶
func NewPrivateKey() (*PrivateKey, error)
NewPrivateKey creates a new random Secp256k1 private key.
func NewPrivateKeyFromASN1 ¶
func NewPrivateKeyFromASN1(b []byte) (*PrivateKey, error)
NewPrivateKeyFromASN1 returns a NEO Secp256k1 PrivateKey from the ASN.1 serialized key.
func NewPrivateKeyFromBytes ¶
func NewPrivateKeyFromBytes(b []byte) (*PrivateKey, error)
NewPrivateKeyFromBytes returns a NEO Secp256r1 PrivateKey from the given byte slice.
func NewPrivateKeyFromHex ¶
func NewPrivateKeyFromHex(str string) (*PrivateKey, error)
NewPrivateKeyFromHex returns a Secp256k1 PrivateKey created from the given hex string.
func NewPrivateKeyFromWIF ¶
func NewPrivateKeyFromWIF(wif string) (*PrivateKey, error)
NewPrivateKeyFromWIF returns a NEO PrivateKey from the given WIF (wallet import format).
func (*PrivateKey) Address ¶
func (p *PrivateKey) Address() string
Address derives the public NEO address that is coupled with the private key, and returns it as a string.
func (*PrivateKey) Bytes ¶
func (p *PrivateKey) Bytes() []byte
Bytes returns the underlying bytes of the PrivateKey.
func (*PrivateKey) GetScriptHash ¶
func (p *PrivateKey) GetScriptHash() util.Uint160
GetScriptHash returns verification script hash for public key associated with the private key.
func (*PrivateKey) PublicKey ¶
func (p *PrivateKey) PublicKey() *PublicKey
PublicKey derives the public key from the private key.
func (*PrivateKey) Sign ¶
func (p *PrivateKey) Sign(data []byte) []byte
Sign signs arbitrary length data using the private key.
func (*PrivateKey) String ¶
func (p *PrivateKey) String() string
String implements the stringer interface.
func (*PrivateKey) WIF ¶
func (p *PrivateKey) WIF() string
WIF returns the (wallet import format) of the PrivateKey. Good documentation about this process can be found here: https://en.bitcoin.it/wiki/Wallet_import_format
type PublicKey ¶
PublicKey represents a public key and provides a high level API around ecdsa.PublicKey.
func NewPublicKeyFromASN1 ¶
NewPublicKeyFromASN1 returns a NEO PublicKey from the ASN.1 serialized key.
func NewPublicKeyFromBytes ¶ added in v0.90.0
NewPublicKeyFromBytes returns public key created from b using given EC.
func NewPublicKeyFromString ¶
NewPublicKeyFromString returns a public key created from the given hex string.
func (*PublicKey) Address ¶
Address returns a base58-encoded NEO-specific address based on the key hash.
func (*PublicKey) Bytes ¶
Bytes returns byte array representation of the public key in compressed form (33 bytes with 0x02 or 0x03 prefix, except infinity which is always 0).
func (*PublicKey) DecodeBinary ¶
DecodeBinary decodes a PublicKey from the given BinReader using information about the EC curve to decompress Y point. Secp256r1 is a default value for EC curve.
func (*PublicKey) DecodeBytes ¶
DecodeBytes decodes a PublicKey from the given slice of bytes.
func (*PublicKey) EncodeBinary ¶
EncodeBinary encodes a PublicKey to the given BinWriter.
func (*PublicKey) GetScriptHash ¶
GetScriptHash returns a Hash160 of verification script for the key.
func (*PublicKey) GetVerificationScript ¶
GetVerificationScript returns NEO VM bytecode with CHECKSIG command for the public key.
func (*PublicKey) IsInfinity ¶
IsInfinity checks if the key is infinite (null, basically).
func (PublicKey) MarshalJSON ¶ added in v0.75.0
MarshalJSON implements the json.Marshaler interface.
func (*PublicKey) UncompressedBytes ¶ added in v0.76.0
UncompressedBytes returns byte array representation of the public key in uncompressed form (65 bytes with 0x04 prefix, except infinity which is always 0).
func (*PublicKey) UnmarshalJSON ¶ added in v0.75.0
UnmarshalJSON implements json.Unmarshaler interface.
type PublicKeys ¶
type PublicKeys []*PublicKey
PublicKeys is a list of public keys.
func (*PublicKeys) Bytes ¶ added in v0.90.0
func (keys *PublicKeys) Bytes() []byte
Bytes encodes PublicKeys to the new slice of bytes.
func (PublicKeys) Contains ¶
func (keys PublicKeys) Contains(pKey *PublicKey) bool
Contains checks whether passed param contained in PublicKeys.
func (PublicKeys) Copy ¶ added in v0.90.0
func (keys PublicKeys) Copy() PublicKeys
Copy returns copy of keys.
func (*PublicKeys) DecodeBytes ¶
func (keys *PublicKeys) DecodeBytes(data []byte) error
DecodeBytes decodes a PublicKeys from the given slice of bytes.
func (PublicKeys) Len ¶
func (keys PublicKeys) Len() int
func (PublicKeys) Less ¶
func (keys PublicKeys) Less(i, j int) bool
func (PublicKeys) Swap ¶
func (keys PublicKeys) Swap(i, j int)
func (PublicKeys) Unique ¶
func (keys PublicKeys) Unique() PublicKeys
Unique returns set of public keys.
type ScryptParams ¶
ScryptParams is a json-serializable container for scrypt KDF parameters.
func NEP2ScryptParams ¶
func NEP2ScryptParams() ScryptParams
NEP2ScryptParams returns scrypt parameters specified in the NEP-2.
type WIF ¶
type WIF struct { // Version of the wallet import format. Default to 0x80. Version byte // Bool to determine if the WIF is compressed or not. Compressed bool // A reference to the PrivateKey which this WIF is created from. PrivateKey *PrivateKey // The string representation of the WIF. S string }
WIF represents a wallet import format.