Published
Edited
Mar 22, 2020
Digital Signature
Lamport Diffie One Time Signature Schema
Insert cell
Insert cell
Insert cell
n = 128
Insert cell
Insert cell
f = input => {
return parseInt(input, 2)
.toString(2)
.split("")
.reverse()
.join(""); // This is obviously NOT a one-way function
}
Insert cell
Insert cell
MD5 = require('https://bundle.run/md5.js@1.3.5')
Insert cell
g = input => {
return parseInt(new MD5().update(input.toString()).digest('hex'), 16)
.toString(2)
.padStart(128, '0');
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
X = getRandomData(n)
Insert cell
Insert cell
Y = X.map(pair => pair.map(bitstring => f(bitstring)))
Insert cell
Insert cell
Insert cell
Insert cell
d = g(M)
Insert cell
Insert cell
indexKey = (signatureKey, messageDigest) => {
const signature = [];
for (let i = 0; i < n; i++) {
signature.push(signatureKey[i][parseInt(messageDigest.charAt(i), 2)]);
}
return signature;
}
Insert cell
σ = indexKey(X, d)
Insert cell
Insert cell
Insert cell
dv = g(M)
Insert cell
Insert cell
σCheck = indexKey(Y, dv)
Insert cell
Insert cell
Insert cell
arraysEqual(σ.map(bitstring => f(bitstring)), σCheck)
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more