dashmsg package - github.com/dashhive/dashmsg - Go Packages

This section is empty.

View Source

var (
	
	CheckVersion = "4c" 

	
	CheckVersionTest = "8c" 

	
	WIFVersion = "cc" 

	
	WIFVersionTest = "ef" 

	
	MagicBytes = []byte("DarkCoin Signed Message:\n")
)

AddressToCointype reads the magic version (coin / network type) from the base58check address

DoubleHash simply runs one sha256 sum in series with another

func EncodeToBCVarint(m int) []byte

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.

GenerateWIF creates a new wallet private key as WIF

func MagicConcat(magicBytes, msg []byte) []byte

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

MagicHash combines the magic bytes and message, with their respective lengths (encoded as BCVarint) prepended to each, and then double hashes the result

MagicSign scopes the signature of a message to the Dash network

MagicVerify checks that the given public key hash payment address can be used to verify the given base64 signature and arbitrary message

MarshalPublicKey uses elliptic.Marshal to output the secp256k1.S256() curve public key

PublicKeyToAddress transforms a PublicKey into a PubKeyHash address is Base58Check format

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)

WIFToPrivateKey decodes the base58check (WIF) into the network magicVersion and a standard(ish) ECDSA private key

Base58Check indicates that the given string should be in Base58Check encoded (coint type prefix on double hash of public key, BaseX-style Base58 encoding)

Base64 indicates that the given string should be Base64 encoded (std, with padding)

type CompactSignature struct {
	I int
	R []byte
	S []byte
}

CompactSignature is the 65-byte Dash signature with the magic "i" recovery int as the first byte

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