subkey

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 2 Imported by: 67

README

go-subkey

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.Derive(scheme, uri)
Hex encoded Seed
    uri := "0x6ea8835d60351a39a1e2293b2902d7bd6e12e526e72c46f4fda4a233809c4379"
    scheme := sr25519.Scheme{}
    kr, err := subkey.Derive(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)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Derive

func Derive(scheme Scheme, uri string) (common.KeyPair, error)

Derive derives the Keypair from the URI using the provided cryptography scheme.

Types

type Scheme

type Scheme interface {
	fmt.Stringer
	Generate() (common.KeyPair, error)
	FromSeed(seed []byte) (common.KeyPair, error)
	FromPhrase(phrase, password string) (common.KeyPair, error)
	Derive(pair common.KeyPair, djs []common.DeriveJunction) (common.KeyPair, error)
}

Scheme represents a cryptography scheme.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL