ring

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2018 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyMessage is returned when trying to sign an empty message.
	ErrEmptyMessage = errors.New("you should provide a message to sign")

	// ErrInvalidSignerIndex is returned when an invalid signer index is provided to Sign.
	ErrInvalidSignerIndex = errors.New("the index of the signer should be in the ring")

	// ErrRingTooSmall is returned when the ring contains less than two participants.
	ErrRingTooSmall = errors.New("the ring is too small: you need at least two participants")
)

Functions

func ConfigDecodeKey

func ConfigDecodeKey(keyStr string) ([]byte, error)

ConfigDecodeKey decodes a key from its friendly string format.

func ConfigEncodeKey

func ConfigEncodeKey(key []byte) string

ConfigEncodeKey encodes a key to a friendly string format that can be stored in configuration files.

func Generate

func Generate(rand io.Reader) (PublicKey, PrivateKey)

Generate generates a new public-private key pair. If no random generator is provided, Generate will use go's default cryptographic random generator. The private key should be safely stored. The public key can be shared with anyone.

Types

type PrivateKey

type PrivateKey []byte

PrivateKey defines a private key in assymetric encryption.

func (PrivateKey) Sign

func (sk PrivateKey) Sign(
	rand io.Reader,
	message []byte,
	ringKeys []PublicKey,
	signerIndex int,
) (*Signature, error)

Sign creates a ring signature for the given message.

type PublicKey

type PublicKey []byte

PublicKey defines a public key in assymetric encryption.

type Signature

type Signature struct {
	// contains filtered or unexported fields
}

Signature is the struct representing a ring signature.

func (*Signature) Decode

func (sig *Signature) Decode(data string) error

Decode decodes a signature from its friendly string representation.

func (*Signature) Encode

func (sig *Signature) Encode() (string, error)

Encode encodes a signature to a friendly string representation.

func (*Signature) Marshal

func (sig *Signature) Marshal() ([]byte, error)

Marshal marshals a signature to a byte representation.

func (*Signature) Unmarshal

func (sig *Signature) Unmarshal(data []byte) error

Unmarshal unmarshals a signature from its byte representation.

func (*Signature) Verify

func (sig *Signature) Verify(message []byte) bool

Verify verifies the validity of the message signature. It does not detail why the signature validation failed.

Jump to

Keyboard shortcuts

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