Documentation ¶
Index ¶
- Variables
- func AddressToCointype(addr string) (string, error)
- func DoubleHash(buf []byte) []byte
- func EncodeToBCVarint(m int) []byte
- func GenerateWIF(magicVersion string) string
- func MagicConcat(magicBytes, msg []byte) []byte
- func MagicHash(msg []byte) []byte
- func MagicSign(priv *ecdsa.PrivateKey, msg []byte) ([]byte, error)
- func MagicVerify(addr Base58Check, msg []byte, sig Base64) error
- func MarshalPublicKey(pub ecdsa.PublicKey) []byte
- func PublicKeyToAddress(magicVersion string, pub ecdsa.PublicKey) string
- func SigToPub(magichash, dsig []byte) (*ecdsa.PublicKey, error)
- func WIFToPrivateKey(wif string) (string, *ecdsa.PrivateKey, error)
- type Base58Check
- type Base64
- type CompactSignature
Constants ¶
This section is empty.
Variables ¶
var ( // CheckVersion is the Base58Check magic version (coin / network type) byte signifying the payment address coin type (i.e. Dash, Public Key, mainnet) CheckVersion = "4c" // Dash mainnet (vs 0x00 for BC) // CheckVersionTest is CheckVersion, but for testnet CheckVersionTest = "8c" // Dash testnet // WIFVersion is the Base58Check magic version (coin / network type) byte signifying the wallet type (i.e. Dash, Private Key, mainnet) WIFVersion = "cc" // Dash mainnet (vs 0x80 for BC) // WIFVersionTest is WIFVersion, but for testnet WIFVersionTest = "ef" // Dash testnet // MagicBytes is the secure delimiter that scopes a message to a particular network MagicBytes = []byte("DarkCoin Signed Message:\n") )
Functions ¶
func AddressToCointype ¶ added in v0.10.0
AddressToCointype reads the magic version (coin / network type) from the base58check address
func DoubleHash ¶
DoubleHash simply runs one sha256 sum in series with another
func EncodeToBCVarint ¶
EncodeToBCVarint is a special variable-width byte encoding for 8, 16, 32, or 64-bit integers. For integers less than 253 bytes it uses a single bit. 253, 254, and 255 signify a 16, 32, and 64-bit (2, 4, and 8-byte) little-endian encodings respectively.
func GenerateWIF ¶
GenerateWIF creates a new wallet private key as WIF
func MagicConcat ¶
MagicConcat combines the magic bytes (which signify the network the message belongs to) and message, with their respective lengths (encoded as BCVarint) prepended to each
func MagicHash ¶
MagicHash combines the magic bytes and message, with their respective lengths (encoded as BCVarint) prepended to each, and then double hashes the result
func MagicSign ¶
func MagicSign(priv *ecdsa.PrivateKey, msg []byte) ([]byte, error)
MagicSign scopes the signature of a message to the Dash network
func MagicVerify ¶ added in v0.10.1
func MagicVerify(addr Base58Check, msg []byte, sig Base64) error
MagicVerify checks that the given public key hash payment address can be used to verify the given base64 signature and arbitrary message
func MarshalPublicKey ¶
MarshalPublicKey uses elliptic.Marshal to output the secp256k1.S256() curve public key
func PublicKeyToAddress ¶
PublicKeyToAddress transforms a PublicKey into a PubKeyHash address is Base58Check format
func SigToPub ¶
SigToPub computes the public key from the message's magichash and the recovery signature (has the magic byte, a.k.a. "i" at the front of it)
func WIFToPrivateKey ¶
func WIFToPrivateKey(wif string) (string, *ecdsa.PrivateKey, error)
WIFToPrivateKey decodes the base58check (WIF) into the network magicVersion and a standard(ish) ECDSA private key
Types ¶
type Base58Check ¶ added in v0.10.1
type Base58Check = string
Base58Check indicates that the given string should be in Base58Check encoded (coint type prefix on double hash of public key, BaseX-style Base58 encoding)
type Base64 ¶ added in v0.10.1
type Base64 = string
Base64 indicates that the given string should be Base64 encoded (std, with padding)
type CompactSignature ¶
CompactSignature is the 65-byte Dash signature with the magic "i" recovery int as the first byte
func DecodeSignature ¶
func DecodeSignature(b64 string) (*CompactSignature, error)
DecodeSignature will break a Dash message signature into its component parts of "i" (the pub key recovery int), and "r" and "s" - the normal (non-ASN.1) ECDSA signature parts