modulepackage
0.0.0-20220614131247-ee3a8da30fde
Repository: https://github.com/cessproject/go-keyring.git
Documentation: pkg.go.dev
# README
go-keyring
Implement go utilities compatible with Substrate sr25519 keys.
usage
package main
import (
"fmt"
"log"
keyring "github.com/CESSProject/go-keyring"
)
func main() {
// generate keyring from secret uri
secretURI := "head achieve piano online exhaust bulk trust vote inflict room keen maximum"
kr, _ := keyring.FromURI(secretURI, keyring.NetSubstrate{})
// output public SS58 formatted address
ss58, _ := kr.SS58Address()
log.Printf("SS58 Address: %s", ss58)
// sign message
msg := []byte("test message")
sig, _ := kr.Sign(kr.SigningContext(msg))
// create new keyring from SS58 public address to verify message signature
verkr, _ := keyring.FromURI(ss58, keyring.NetSubstrate{})
fmt.Println(verkr.Verify(verkr.SigningContext(msg), sig))
}
# Functions
DecodeHex decodes the hex string to bytes and truncates any prefix used.
DecodeSS58Address takes a string and checks if it is a validly encoded SS58 address and returns the raw address in bytes.
EncodeHex encodes the raw bytes into a hex encoded string and appends any prefix required.
FromPublic returns a KeyRing from the raw bytes of a public key.
FromURI returns a KeyRing from the given Secret URI.
Generate creates a new KeyRing with a randomly created mnemonic of the specified number of words.
NewSecretURI takes a given string Secret URI and splits it into Phrase, Path, and Password components given the format <phrase><path>///<password> and returns it as a struct.
SS58Address derives ss58 address from the address, network, and checksumType.
# Constants
AccountID uses the address as the blake2b hash pre-image.
MiniSecretKeyLength is the length of the MiniSecret Key.
No description provided by the author
No description provided by the author
No description provided by the author
SecretKeyLength is the length of the SecretKey.
SS58Checksum uses the concat(address-type, address) as blake2b hash pre-image.
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
Errors.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
KeyRing defines a key pair from a derive Secret URI.
NetSubstrate implements the Network interface to define Substrates mainnet settings.
SecretURI defines a struct consisting of the parts of a Secret URI.
# Interfaces
Network defines the interface for a specific networks settings to be used for key generation and address formatting.
# Type aliases
ChecksumType represents the one or more checksum types.
DerivablePrivateKey indicates if the returned sr25519.DerivableKey is a PublicKey or SecretKey.
HexPrefix defines a prefix used in the hex encoded output.
PhraseType specifies the type of data that was passed as the phrase component in a Secret URI.
WordCount defines the type for specifying the number of words in a mnemonic.