go-varsig
is a go implementation of the varsig
specification.
Built with ❤️ by Consensys.
Include the go-varsig
library by running the following command:
go get github.com/ucan-wg/go-varsig@latest
func ExampleDecode() {
example, err := base64.RawStdEncoding.DecodeString("NAHtAe0BE3E")
handleErr(err)
vs, err := varsig.Decode(example)
handleErr(err)
fmt.Printf("%T\n", vs)
fmt.Printf("Algorithm: %d\n", vs.Algorithm())
fmt.Printf("Hash: %d\n", vs.Hash())
fmt.Printf("PayloadEncoding: %d\n", vs.PayloadEncoding())
// Output:
// varsig.EdDSAVarsig
// Algorithm: 237
// Hash: 19
// PayloadEncoding: 3
}
func ExampleEncode() {
edDSAVarsig := varsig.NewEdDSAVarsig(
varsig.CurveEd25519,
varsig.HashSha2_512,
varsig.PayloadEncodingDAGCBOR,
)
b64 := base64.RawStdEncoding.EncodeToString(edDSAVarsig.Encode())
fmt.Print(b64)
// Output:
// NAHtAe0BE3E
}
Documentation for this library is provided as Go docs at https://pkg.go.dev/github.com/ucan-wg/go-varsig.
Install the required development tools using asdf
by running the
following command in this repository (or install them manually):
asdf install
This repository contains a set of pre-commit hooks that are run prior to
each git commit
. You can also run these checks manually using the
following command:
pre-commit run --all-files
ASDF installs act
to support Github workflow development - in general,
follow these steps to test the workflow:
If you're using podman
instead of docker
, use the podman
socket to
simulate the docker
daemon:
export DOCKER_HOST=unix:///var/run/podman/podman.sock
The simplest command to test it is:
act
This project is dual-licensed under Apache 2.0 and MIT terms:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)