lms

package module
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: MIT Imports: 10 Imported by: 1

README

The Leighton-Micali Signatures [LMS]

version tag build status license

Copyright (c) 2017-2018 LoCCS.
Project to implement the Leighton-Micali signature scheme according to Hash-Based Signatures: draft-mcgrew-hash-sigs-08.

Contents

Requirement

  • git
  • go 1.9+
    are required to compile the library.

Installation

By go get
$ go get -u github.com/LoCCS/lms
By dep
  1. download the source code into local disks
  2. invoke dep to build up dependencies
$ dep ensure

Usage

Please refer to ExampleVerify() in example_test.go

Contributing

Kind advices and contributions are always welcomed, but to avoid chaos or destabilization in existing work, we have processes that bring people in gradually. In general the process is:

  • Find a specific bug you'd like to fix or a specific feature you’d like to add (check out the issues list if to get some ideas)
  • Fix the bug in your own clone and ensure that it's working
  • Submit the change to the master branch via a pull request

Development Resources

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashFunc

func HashFunc() hash.Hash

HashFunc returns a consistent hash function for usage across the whole project

func Verify

func Verify(root []byte, hash []byte, merkleSig *MerkleSig) bool

Verify verifies a Merkle signature

Example
const H = 4
seed := make([]byte, lmots.N)
rand.Reader.Read(seed)
merkleAgent, err := NewMerkleAgent(H, seed)
if nil != err {
	panic(err)
}

msg := make([]byte, lmots.N)
rand.Reader.Read(msg)
// what if no more leaf to use in the Merkle agent
_, sig, err := Sign(merkleAgent, msg)
if nil != err {
	panic(err)
}

fmt.Println(Verify(merkleAgent.Root, msg, sig))
Output:

true

Types

type KeyIterator

type KeyIterator struct {

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

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

func NewKeyIterator

func NewKeyIterator(compactSeed []byte) *KeyIterator

NewKeyIterator makes a prkg

func (*KeyIterator) Deserialize

func (prkg *KeyIterator) Deserialize(data []byte) error

Deserialize unmarshals the prkg from gob bytes

func (*KeyIterator) GobDecode

func (prkg *KeyIterator) GobDecode(data []byte) error

GobDecode customizes the Gob decoding scheme for KeyIterator

func (KeyIterator) GobEncode

func (prkg KeyIterator) GobEncode() ([]byte, error)

GobEncode customizes the Gob encoding scheme for KeyIterator

func (*KeyIterator) Next

func (prkg *KeyIterator) Next() (*lmots.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** key returned by this prkg

func (*KeyIterator) Serialize

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

Serialize marshals a prkg into gob bytes

type MerkleAgent

type MerkleAgent struct {
	H uint32

	Root []byte
	// contains filtered or unexported fields
}

MerkleAgent implements a agent working according to the Merkle signature scheme

func NewMerkleAgent

func NewMerkleAgent(H uint32, seed []byte) (*MerkleAgent, error)

NewMerkleAgent makes a fresh Merkle signing routine by running the generate key and setup procedure

func (*MerkleAgent) GobDecode

func (agent *MerkleAgent) GobDecode(data []byte) error

GobDecode customizes the Gob decoding for MerkleAgent

func (*MerkleAgent) GobEncode

func (agent *MerkleAgent) GobEncode() ([]byte, error)

GobEncode customizes the Gob encoding for MerkleAgent

func (*MerkleAgent) LeafIdx

func (agent *MerkleAgent) LeafIdx() uint32

LeafIdx returns the index of next leaf to use

func (*MerkleAgent) Rebuild

func (agent *MerkleAgent) Rebuild(data []byte, secret []byte) error

Rebuild restores the merkle agent from serialized bytes and secret bytes

func (*MerkleAgent) Serialize

func (agent *MerkleAgent) Serialize() ([]byte, error)

Serialize encodes all the information about the merkle tree that can be stored as plaintext

func (*MerkleAgent) SerializeSecretKey

func (agent *MerkleAgent) SerializeSecretKey() []byte

SerializeSecretKey encodes all the secret data which shall be encrypted

func (*MerkleAgent) Traverse

func (agent *MerkleAgent) Traverse()

Traverse updates both auth path and retained stack for next use

type MerkleSig

type MerkleSig struct {
	Opts  *lmots.LMOpts
	LMSig *lmots.Sig // OTS signature

	Auth [][]byte
}

MerkleSig is the container for the signature generated according to LMS

func Sign

func Sign(agent *MerkleAgent, hash []byte) (*lmots.PrivateKey, *MerkleSig, error)

Sign produces a Merkle signature

func (*MerkleSig) Deserialize

func (sig *MerkleSig) Deserialize(data []byte) error

Deserialize unmarshals the MerkleSig from gob bytes

func (*MerkleSig) Serialize

func (sig *MerkleSig) Serialize() ([]byte, error)

Serialize marshals a MerkleSig into gob bytes

type Node

type Node struct {
	Height uint32
	Nu     []byte
	Index  uint32
}

Node is a node in the Merkle tree

type TreeHashStack

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

TreeHashStack is a stack tracing the running state of the tree hash algo

func NewTreeHashStack

func NewTreeHashStack(startingLeaf, h uint32) *TreeHashStack

NewTreeHashStack makes a new tree hash instance

func (*TreeHashStack) Deserialize

func (ths *TreeHashStack) Deserialize(data []byte) error

Deserialize unmarshals the TreeHashStack from the Gob bytes

func (*TreeHashStack) GobDecode

func (ths *TreeHashStack) GobDecode(data []byte) error

GobDecode customizes the Gob decoding scheme for TreeHashStack

func (TreeHashStack) GobEncode

func (ths TreeHashStack) GobEncode() ([]byte, error)

GobEncode customizes the Gob encoding scheme for TreeHashStack

func (*TreeHashStack) Init

func (th *TreeHashStack) Init(startingLeaf, h uint32) error

Init initializes the tree hash instance to target specific height and the range of leaves

func (*TreeHashStack) IsCompleted

func (th *TreeHashStack) IsCompleted() bool

IsCompleted checks if the tree hash instance has completed

func (*TreeHashStack) LowestTailHeight

func (th *TreeHashStack) LowestTailHeight() uint32

LowestTailHeight returns the lowest height of tail nodes in this tree hash instance

func (*TreeHashStack) Serialize

func (ths *TreeHashStack) Serialize() ([]byte, error)

Serialize marshals the TreeHashStack as Gob bytes

func (*TreeHashStack) SetLeaf

func (th *TreeHashStack) SetLeaf(leaf uint32)

SetLeaf updates the leaf index

func (*TreeHashStack) Top

func (th *TreeHashStack) Top() *Node

Top returns the node in the top of the stack

func (*TreeHashStack) Update

func (th *TreeHashStack) Update(I []byte, numOp uint32, nodeHouse [][]byte)

Update executes numOp updates on the instance, and add on the new leaf derived by keyItr if necessary

Directories

Path Synopsis
container

Jump to

Keyboard shortcuts

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