winternitz

package
v0.0.0-...-f05ec83 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SecurityLevel256 = 32 // 256 bits
	SecurityLevel512 = 64 // 512 bits
	SecurityLevel    = SecurityLevel256
)

security parameter

Variables

This section is empty.

Functions

func ToBase

func ToBase(out []byte, X []byte, baseWidth uint8)

ToBase outputs an array `out` of integers between 0 and ((2<<baseWidth) - 1) len(out) is REQUIRED to be <=8*len(X)/baseWidth and baseWidth should be a member in set {1,2,4,8}. Otherwise, the result is unpredictable

func Verify

func Verify(pk *PublicKey, hash []byte, wtnSig *WinternitzSig) bool

Verify verifies the Merkle signature on a message digest against the claimed public key and the opts should have the same seed and key-pair index as that of generating key pairs

Types

type KeyIterator

type KeyIterator struct {

	// options specifying stuff like nonce for
	//	randomizing hash function
	*WtnOpts
	// contains filtered or unexported fields
}

KeyIterator is a prkgator to produce a key chain for user based on a seed

func NewKeyIterator

func NewKeyIterator(compactSeed []byte) *KeyIterator

NewKeyIterator makes a key pair prkgator

func (*KeyIterator) Init

func (prkg *KeyIterator) Init(compositeSeed []byte) bool

Init initialises the prkgator with the composite seed exported by Serialize()

func (*KeyIterator) Next

func (prkg *KeyIterator) Next() (*PrivateKey, error)

Next estimates and returns the next sk-pk pair

func (*KeyIterator) Offset

func (prkg *KeyIterator) Offset() uint32

Offset returns 0-based index of the **next** running prkgation

func (*KeyIterator) Serialize

func (prkg *KeyIterator) Serialize() []byte

Serialize encodes the key iterator as +---------------------------------------------+ | len(seed)||seed||offset||len(nonce)||nonce | +---------------------------------------------+ the byte slice export from here makes up everything needed to recovered the state the prkg So unless it's your first-time use, you should store this byte slice so as to snapshot the prkg

type PrivateKey

type PrivateKey struct {
	PublicKey
	// contains filtered or unexported fields
}

PrivateKey as container for private key, it also embeds its corresponding public key

func GenerateKey

func GenerateKey(opts *WtnOpts, rng io.Reader) (*PrivateKey, error)

GenerateKey generates a one-time key pair according to specification (nonce, key-pair-index) in opts and by getting randomness from rng

type PublicKey

type PublicKey struct {
	*WtnOpts
	Y [][]byte
}

PublicKey as container for public key

func (*PublicKey) Clone

func (pk *PublicKey) Clone() *PublicKey

Clone returns a copy of this public key

type WinternitzSig

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

WinternitzSig as container for the Winternitz one-time signature

func DeserializeWinternitzSig

func DeserializeWinternitzSig(sigBytes []byte) *WinternitzSig

Deserialize decodes the winternitz signature from bytes

func Sign

func Sign(sk *PrivateKey, hash []byte) (*WinternitzSig, error)

Sign generates the signature for a message digest based on the given private key the opts should have the same seed and key-pair index and as that of generating key pairs

func (*WinternitzSig) Serialize

func (sig *WinternitzSig) Serialize() []byte

Serialize encodes the winternitz signature

type WtnOpts

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

WtnOpts provides a container specifying options for W-OTS

var DummyWtnOpts *WtnOpts = NewWtnOpts(SecurityLevel)

DummyWtnOpts is a dummy WtnOpts with a random nonce

func Deserialize

func Deserialize(optsBytes []byte) *WtnOpts

Deserialize recovers the WtnOpts from bytes

func NewWtnOpts

func NewWtnOpts(securityLevel uint32) *WtnOpts

NewWtnOpts makes a WtnOpts of the specified security level and securityLevel should be in {32, 64}

func (*WtnOpts) Clone

func (opts *WtnOpts) Clone() *WtnOpts

Clone makes a copy of this WtnOpts

func (*WtnOpts) Nonce

func (opts *WtnOpts) Nonce() []byte

Nonce returns the nonce employed by this WtnOpts

func (*WtnOpts) SecurityLevel

func (opts *WtnOpts) SecurityLevel() uint32

SecurityLevel returns the security level specified by this WtnOpts, should be the same length as the nonce in use

func (*WtnOpts) Serialize

func (opts *WtnOpts) Serialize() []byte

Serialize encodes the winternitz options

func (*WtnOpts) SetKeyIdx

func (opts *WtnOpts) SetKeyIdx(i uint32)

SetKeyIdx sets the index of the key-pair in use

func (*WtnOpts) SetNonce

func (opts *WtnOpts) SetNonce(nonce []byte)

SetNonce sets the nonce for this WtnOpts

Jump to

Keyboard shortcuts

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