Categorygithub.com/amintalebi/go-subkey
modulepackage
1.0.4
Repository: https://github.com/amintalebi/go-subkey.git
Documentation: pkg.go.dev

# README

go-subkey

Go Reference

Subkey port in Go

Usage

Generate Key pair

Sr25519

    kr, err := sr25519.Scheme{}.Generate()

Ed25519

    kr, err := ed25519.Scheme{}.Generate()

Ecdsa

    kr, err := ecdsa.Scheme{}.Generate()

Deriving keypair from a mnemonic or seed

Mnemonic

    uri := "crowd swamp sniff machine grid pretty client emotion banana cricket flush soap//foo//42///password"
    scheme := sr25519.Scheme{}
    kr, err := subkey.DeriveKeyPair(scheme, uri)

Hex encoded Seed

    uri := "0x6ea8835d60351a39a1e2293b2902d7bd6e12e526e72c46f4fda4a233809c4379"
    scheme := sr25519.Scheme{}
    kr, err := subkey.DeriveKeyPair(scheme, uri)

Hex encoded Seed with derivation

    uri := "0x6ea8835d60351a39a1e2293b2902d7bd6e12e526e72c46f4fda4a233809c4379//foo//42///password"
    scheme := sr25519.Scheme{}
    kr, err := subkey.DeriveKeyPair(scheme, uri)

Sign and verify using Keypair

    kr, err := ed25519.Scheme{}.Generate()
    msg := []byte("test message")
    sig, err := kr.Sign(msg)
    ok := kr.Verify(msg, sig)

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
nolint.
No description provided by the author

# Functions

DecodeHex decodes the hex string to bytes.
No description provided by the author
DeriveKeyPair derives the Keypair from the URI using the provided cryptography scheme.
No description provided by the author
EncodeHex encodes bytes to hex `0x` prefix is added.
SS58Address derives ss58 address from the accountID and network uses SS58Checksum checksum type SS58Checksum uses the concat(network, accountID) as blake2b hash pre-image More here: https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58)#checksum-types.
SS58AddressWithAccountIDChecksum derives ss58 address from the accountID, network uses AccountID checksum type AccountIDChecksum uses the accountID as the blake2b hash pre-image More here: https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58)#checksum-types.

# Constants

DevPhrase is default phrase used for dev test accounts.

# Structs

No description provided by the author

# Interfaces

KeyPair can sign, verify using a seed and public key.
Scheme represents a cryptography scheme.
Signer signs the message and returns the signature.
Verifier verifies the signature.