sign

package
v0.0.0-...-11acf48 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2018 License: BSD-3-Clause Imports: 3 Imported by: 13

Documentation

Overview

Package sign implements a digital signature scheme using the Edwards form of Curve25519.

Index

Constants

View Source
const (
	// PrivateKeySize is the size of the private-key in bytes.
	PrivateKeySize = 64
	// PublicKeySize is the size of the public-key in bytes.
	PublicKeySize = 32
	// SignatureSize is the size of the created signature in bytes.
	SignatureSize = 64
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey ed25519.PrivateKey

PrivateKey wraps the underlying private-key (ed25519.PrivateKey). It provides some wrapper methods: Sign(), Public()

func GenerateKey

func GenerateKey(rnd io.Reader) (PrivateKey, error)

GenerateKey generates and returns a fresh random private-key, from which the corresponding public-key can be derived (by calling Public() on it). It will use the passed io.Reader rnd as a source of randomness, or, if rnd is nil it will use a sane default (rand.Reader).

It returns an error if the key couldn't be properly generated. This, for example, can happen if there isn't enough entropy for the randomness.

func (PrivateKey) Public

func (key PrivateKey) Public() (PublicKey, bool)

Public derives the corresponding public-key from the underlying private-key. It returns the derived key, if possible, and a boolean flag which indicates if the operations to derive the public-key were successful.

func (PrivateKey) Sign

func (key PrivateKey) Sign(message []byte) []byte

Sign returns a signature on the passed byte slice message using the underlying private-key. The passed slice won't be modified.

type PublicKey

type PublicKey ed25519.PublicKey

PublicKey wraps the underlying public-key type. It can be used to verify a signature which was created by using a corresponding PrivateKey

func (PublicKey) Verify

func (pk PublicKey) Verify(message, sig []byte) bool

Verify verifies a signature sig on message using the underlying public-key. It returns true if and only if the signature is valid. The passed slices aren't modified.

Jump to

Keyboard shortcuts

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