Categorygithub.com/dashhive/dashmsg
modulepackage
0.10.4
Repository: https://github.com/dashhive/dashmsg.git
Documentation: pkg.go.dev

# README

dashmsg

Sign and Verify messages with Dash Private Keys

dashmsg sign --cointype 0x4c \
    'XK5DHnAiSj6HQNsNcDkawd9qdp8UFMdYftdVZFuRreTMJtbJhk8i' \
    'dte2022-akerdemelidis|estoever|mmason'
dashmsg verify \
    'Xn4A2vv5fb7LvmiiXPPMexYbSbiQ29rzDu' \
    'dte2022-akerdemelidis|estoever|mmason' \
    'H2Opy9NX72iPZRcDVEHrFn2qmVwWMgc+DKILdVxl1yfmcL2qcpu9esw9wcD7RH0/dJHnIISe5j39EYahorWQM7I='

Also useful for and inspecting debugging:

  • coin type (network) byte
  • payment address of private key
  • i (quadrant), r, and s of signature

Usage

dashmsg help
dashmsg v0.9.1 (xxxxxxx) 2022-03-13T11:45:52-0700

Usage
    dashmsg <command> [flags] args...

See usage: dashmsg help <command>

Commands:
    version
    gen [--cointype '0xcc'] [name.wif]
    sign [--cointype '0x4c'] <key> <msg>
    inspect [--cointype '0x4c'] <key | address | signature>
    decode (alias of inspect)
    verify <payment address> <msg> <signature>

Examples:
    dashmsg gen ./dash.wif

    dashmsg sign dash.wif ./msg.txt
    dashmsg sign dash.wif 'my message'
    dashmsg sign 'Xxxx...ccc' 'my message'

    dashmsg inspect --verbose 'Xxxxxxxxxxxxxxxxxxxxxxxxxxxxcccccc'

    dashmsg verify Xxxx...ccc 'my message' 'II....signature...'
    dashmsg verify ./addr.b58c.txt ./msg.txt ./sig.b64.txt

How to Build

git clone https://github.com/dashhive/dashmsg
pushd ./dashmsg/
go build -mod=vendor -o dashmsg ./cmd/dashmsg/

GoReleaser

Because one of the dependencies requires CGO_ENABLED=1 and uses low-level syscalls (I have no idea why - probably completely unnecessary), it must be built on and released from the respective OSes.

goreleaser -f .goreleaser.yml --rm-dist --single-target --skip-validate
--single-target - build only for the current OS
--skip-validate - uploads the image even though it can update the checksums

Note: MacOS actually can build both the amd64 and arm64 versions on an M1.

Go Library

Documentation at https://pkg.go.dev/github.com/dashhive/dashmsg.

# Packages

No description provided by the author

# Functions

AddressToCointype reads the magic version (coin / network type) from the base58check address.
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.
DoubleHash simply runs one sha256 sum in series with another.
EncodeToBCVarint is a special variable-width byte encoding for 8, 16, 32, or 64-bit integers.
GenerateWIF creates a new wallet private key as WIF.
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.
WIFToPrivateKey decodes the base58check (WIF) into the network magicVersion and a standard(ish) ECDSA private key.

# Variables

Dash mainnet (vs 0x00 for BC).
Dash testnet.
MagicBytes is the secure delimiter that scopes a message to a particular network.
Dash mainnet (vs 0x80 for BC).
Dash testnet.

# Structs

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

# Type aliases

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).