signature

package
v0.0.0-...-8220f0d Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package signature provides support for digital signature algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Algorithm

type Algorithm uint8

Algorithm represents a digital signature algorithm.

const (
	Ed25519 Algorithm = iota + 1
)

The various digital signature schemes that are currently supported.

func AlgorithmFromString

func AlgorithmFromString(s string) (Algorithm, error)

func (Algorithm) String

func (s Algorithm) String() string

type KeyPair

type KeyPair interface {
	Algorithm() Algorithm
	PrivateKey() PrivateKey
	PublicKey() PublicKey
	Sign(data []byte) (sig []byte)
	Value() []byte
	Verify(data []byte, sig []byte) bool
}

KeyPair represents the combined public/private keypair for a digital signature algorithm.

func GenKeyPair

func GenKeyPair(s Algorithm) (KeyPair, error)

GenKeyPair generates a new keypair for the given digital signature algorithm. It uses crypto/rand's Reader behind the scenes as the source of randomness.

func LoadKeyPair

func LoadKeyPair(s Algorithm, value []byte) (KeyPair, error)

LoadKeyPair deserialises the given value into a type representing the combined public/private keypair for the given digital signature algorithm.

type PrivateKey

type PrivateKey interface {
	Algorithm() Algorithm
	Sign(data []byte) (sig []byte)
	Value() []byte
}

PrivateKey represents the private key for a digital signature algorithm. It can be used to sign data that can be verified by holders of the corresponding public key.

func LoadPrivateKey

func LoadPrivateKey(s Algorithm, value []byte) (PrivateKey, error)

LoadPrivateKey deserialises the given value into a type implementing the PrivateKey interface for the given digital signature algorithm.

type PublicKey

type PublicKey interface {
	Algorithm() Algorithm
	Value() []byte
	Verify(data []byte, sig []byte) bool
}

PublicKey represents the public key for a digital signature algorithm. It can be used to verify data that has been signed by the corresponding private key.

func LoadPublicKey

func LoadPublicKey(s Algorithm, value []byte) (PublicKey, error)

LoadPublicKey deserialises the given value into a type implementing the PublicKey interface for the given digital signature algorithm.

Jump to

Keyboard shortcuts

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