signedjson

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2019 License: MIT Imports: 6 Imported by: 2

README

signedjson

port of matrix/python-signedjson to golang

Documentation

Index

Constants

View Source
const NACL_ED25519 = "ed25519"

NACL_ED25519 default algorithm

Variables

View Source
var SupportedAlgorithms = []string{NACL_ED25519}

SupportedAlgorithms a list of supported algorithms

Functions

func DecodeBase64

func DecodeBase64(v string) ([]byte, error)

func EncodeBase64

func EncodeBase64(v []byte) string

Types

type Key

type Key struct {
	PublicKey  ed25519.PublicKey
	PrivateKey ed25519.PrivateKey
	Version    string
	Alg        string
}

Key contains keys used to sign and verify messages,

func DecodeSigningKeyBase64

func DecodeSigningKeyBase64(alg, version, key string) (*Key, error)

DecodeSigningKeyBase64 returns a Key with PrivateKey decoded from base64 encoded key.

func DecodeVerifyKeyBase64

func DecodeVerifyKeyBase64(alg, version, key string) (*Key, error)

DecodeVerifyKeyBase64 returns a Key with PublicKey decoded from base64 encoded key.

func DecodeVerifyKeyBytes

func DecodeVerifyKeyBytes(keyID string, verify []byte) (*Key, error)

DecodeVerifyKeyBytes returns *Key with verify as public key.

func New

func New(version string) (*Key, error)

New generates a new private/public key and returns a *Key instance that uses the given version.

func (*Key) KeyID

func (key *Key) KeyID() string

KeyID returns a string which is used to store the signature.

func (*Key) Sign

func (key *Key) Sign(object Message, signatureName string) error

Sign signs json object v according to matrix specification

func (*Key) Verify

func (key *Key) Verify(message Message, signatureName string) (err error)

Verify returns nil if message was signed by the key pair for the public key stored in this struct.

type Message

type Message map[string]interface{}

Message represents arbitrary decoded json object. Note that maps are passed by reference in go. Key.Sign and Key.Verify modifies the passed object so be careful make sure you have a copy before passing this object to the mentioned methods.

func (Message) SignatureID

func (m Message) SignatureID(name string) []string

Jump to

Keyboard shortcuts

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