modulepackage
0.1.0
Repository: https://github.com/proofzero/go-multikeypair.git
Documentation: pkg.go.dev
# README
go-multikeypair
A multiformats-inspired module for encoding cryptographic keypairs.
Install
At a shell within your go module:
go get github.com/proofzero/go-multikeypair
Build Instructions
go build
Testing
go test
Usage
Pseudo-golang for excercising the Encode and Decode API for a given hardcoded keypair of a given crypto algorithm:
// Keys:
private := []byte("Wn3Sf5Ke/3:PA:Tm{KCf59Wg6j%/g*#d")
public := []byte("cv-sB6?r*RW8vP5TuMSv_wvw#dV4nUP!@y%u@pmK!P-S2gYVLve!PfdC#kew5Q7U")
// Cypher:
code := multikeypair.ED_25519
name := multikeypair.Codes[ED_25519]
// Encode:
mk, err := multikeypair.Encode(private, public, code)
if err != nil {
panic(err)
}
// Decode:
kp, err := multikeypair.Decode(mk)
if err != nil {
panic(err)
}
Documentation is inline with code as comments. See tests in keypair_test.go
.
Contribute
We would appreciate your help to make this a useful utility. For code contributions, please send a pull request. First outlining your proposed change in an issue or discussion thread to get feedback from other developers is a good idea for anything but small changes. Other ways to contribute include:
- making a feature request
- reporting a bug
- writing a test
- adding some documentation
- providing feedback on the project direction
- reporting your experience using it
For most things we will use GitHub issues and discussions, but feel free to join the project Matrix room to chat or ask questions.
# Functions
Decode unpacks a multikeypair into a Keypair struct.
Encode a keypair into a Multikeypair, specifying the keypair type using an integer code.
EncodeName encodes a keypair into a Multikeypair, specifying the keypair type using a string name instead of an integer code.
KeypairFromB58 parses a base58-encoded hex string into a Keypair.
MultikeypairFromB58 parses a base58-encoded hex string into a Multikeypair.
PackCode packs a cipher code as varint.
UnpackCode unpacks a varint cipher code.
# Constants
Support ciphers.
Support ciphers.
Support ciphers.
Support ciphers.
Minimum and maximum key lengths in bytes.
Minimum and maximum key lengths in bytes.
Support ciphers.
# Variables
Codes is a mapping from cipher code to name.
Keypair-specific errors this module exports.
Keypair-specific errors this module exports.
Keypair-specific errors this module exports.
Keypair-specific errors this module exports.
Keypair-specific errors this module exports.
Keypair-specific errors this module exports.
Names is a mapping from cipher name to code.
# Type aliases
Multikeypair is a byte slice with the following form: [length] (24-bit length prefix) [code length]<code> (16-bit length prefix, uvarint code) [private key length]<private key> (16-bit length prefix) [public key length]<public key> (16-bit length prefix).