signaturescheme

package
v0.2.4-0...-2c2ceb1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0, BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BLSSignatureSize represents the length in bytes of a BLS signature.
	BLSSignatureSize = 64

	// BLSPublicKeySize represents the length in bytes of a BLS public key.
	BLSPublicKeySize = 128

	// BLSPrivateKeySize represents the length in bytes of a BLS private key.
	BLSPrivateKeySize = 32

	// BLSFullSignatureSize represents the length in bytes of a full BLS signature.
	BLSFullSignatureSize = 1 + BLSPublicKeySize + BLSSignatureSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BLSSignature

type BLSSignature [BLSFullSignatureSize]byte

BLSSignature represents a signature created with the BLS signature scheme.

func BLSSignatureFromBytes

func BLSSignatureFromBytes(data []byte) (result *BLSSignature, consumedBytes int, err error)

BLSSignatureFromBytes unmarshals a BLS signature from a sequence of bytes.

func NewBLSSignature

func NewBLSSignature(pubKey, signature []byte) *BLSSignature

NewBLSSignature creates BLS signature from raw public key and signature data

func (*BLSSignature) Address

func (sig *BLSSignature) Address() address.Address

Address returns the address that this signature signs.

func (*BLSSignature) Bytes

func (sig *BLSSignature) Bytes() []byte

Bytes marshals the signature into a sequence of bytes.

func (*BLSSignature) IsValid

func (sig *BLSSignature) IsValid(signedData []byte) bool

IsValid returns true if the signature correctly signs the given data.

func (*BLSSignature) PublicKeySize

func (sig *BLSSignature) PublicKeySize() int

PublicKeySize returns the size of the public key.

func (*BLSSignature) SignatureSize

func (sig *BLSSignature) SignatureSize() int

SignatureSize returns the size of the signature.

func (*BLSSignature) String

func (sig *BLSSignature) String() string

type ED25519Signature

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

ED25519Signature represents a signature for an addresses that uses elliptic curve cryptography.

func Ed25519SignatureFromBytes

func Ed25519SignatureFromBytes(bytes []byte, optionalTargetObject ...*ED25519Signature) (result *ED25519Signature, consumedBytes int, err error)

Ed25519SignatureFromBytes unmarshals an ed25519 signatures from a sequence of bytes. It either creates a new signature or fills the optionally provided object with the parsed information.

func (*ED25519Signature) Address

func (signature *ED25519Signature) Address() address.Address

Address returns the address, that this signature signs.

func (*ED25519Signature) Bytes

func (signature *ED25519Signature) Bytes() []byte

Bytes returns a marshaled version of the signature.

func (*ED25519Signature) IsValid

func (signature *ED25519Signature) IsValid(signedData []byte) bool

IsValid returns true if the signature is valid for the given data.

func (*ED25519Signature) PublicKeySize

func (signature *ED25519Signature) PublicKeySize() int

PublicKeySize returns the size of the public key.

func (*ED25519Signature) SignatureSize

func (signature *ED25519Signature) SignatureSize() int

SignatureSize returns the size of the signature.

type Signature

type Signature interface {
	// IsValid returns true if the signature is valid for the given data.
	IsValid(signedData []byte) bool

	// Bytes returns a marshaled version of the signature.
	Bytes() []byte

	// Address returns the address that this signature signs.
	Address() address.Address

	// PublicKeySize returns the size of the public key.
	PublicKeySize() int

	// SignatureSize returns the size of the signature.
	SignatureSize() int
}

Signature defines an interface for an address signature generated by the corresponding signature scheme.

func AggregateBLSSignatures

func AggregateBLSSignatures(sigs ...Signature) (Signature, error)

AggregateBLSSignatures combined multiple Signatures into a single one.

type SignatureScheme

type SignatureScheme interface {
	// Version returns the version byte that is associated to this signature scheme.
	Version() byte

	// Address returns the address that this signature scheme instance is securing.
	Address() address.Address

	// Sign creates a valid signature for the given data according to the signature scheme implementation.
	Sign(data []byte) Signature
}

SignatureScheme defines an interface for different signature generation methods (i.e. ED25519, WOTS, and so on ...).

func BLS

func BLS(priKey, pubKey []byte) (SignatureScheme, error)

BLS creates an instance of BLS signature scheme from given private and public keys in marshaled binary form

func ED25519

func ED25519(keyPair ed25519.KeyPair) SignatureScheme

ED25519 creates an instance of a signature scheme, that is used to sign the corresponding address.

func RandBLS

func RandBLS() SignatureScheme

RandBLS creates a RANDOM instance of a signature scheme, that is used to sign the corresponding address. only for testing: each time same sequence!

Jump to

Keyboard shortcuts

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