Lamport one-time signature scheme is a simple but effective mechanism for creating signatures built on top of hash functions. Any cryptograph hash function can be used to implement the scheme. Signatures using large hash functions are understood so far to be "quantum resistant"
The lamport one-time signature scheme uses 50% of your private key as the signature, this is why they are for one time use only.
Do not use a single private key to sign more than once piece of data.
npm install --save lamport-ots
yarn add lamport-ots
const lamportSHA256 = require('lamport')
const { publicKey, privateKey } = lamportSHA256.keys()
const message = 'Hello, world!'
const signature = lamportSHA256.sign(message, privateKey)
// elsewhere...
if (lamportSHA256.verify(message, signature, publicKey)) {
// Authenticity of message confirmed
} else {
// Falsified signature, or tampered message
}
const lamport = require('lamport')
const lamportSomeHash = lamport(function (stringOrBuffer) {
return someHashFrom(stringOrBuffer)
})
const { publicKey, privateKey } = lamportSomeHash.keys()
const message = 'Hello, world!'
const signature = lamportSomeHash.sign(message, privateKey)
// elsewhere...
if (lamportSomeHash.verify(message, signature, publicKey)) {
// Authenticity of message confirmed
} else {
// Falsified signature, or tampered message
}
hash
must be a function that accepts either a String or a Buffer, and returns a Buffer of fixed length.
Returns a lamport "instance" with the following methods
keys()
sign(message, privateKey)
verify(message, signature, publicKey)
Returns an Object with a publicKey
and privateKey
property.
message
must be either a String or a Buffer
privateKey
should be a privateKey returned from keys that hasn't been used before.
Returns a Buffer representing the signature
message
must be either a String or a Buffer
signature
must be a Buffer
publicKey
should be a publicKey returned from keys()
Returns a Boolean representing the validity of the signature
The module exposes a lamport "instance" created with the sha256 hash function, which you can use directly.
Contributions are welcome from anyone and everyone and the collaboration model used is the Collective Code Construction Contract