Photo by Bernard Hermant on Unsplash

Accumulators, Witnesses and Zero Knowledge Proofs in Node.js

--

While many will see Python as the natural language to turn to in Cybersecurity, Node.js is just as good, and probably provides access to more library, and is widely compatiable on systems. Perhaps Python and Node.js suffer from a poor usage of syntax, but they are so usual in scripting code.

In this case we will implement an accumulator and allows Bob to add values onto a fixed-length digest, and to provide proof of the values added, without revealing them within the accumulated value. In this case we will use a basic ECC method to make commitments to data elements and use Node.js to implement.

The code in Node.js to add e and which is a hash of a message (msg) onto the secret key of sk is:

acc = acc.multiply(e.add(sk).mod(n))

This takes the current accumulator value (acc) and multiplies by e+sk. The reason that we have methods for the arithmetic operations, is that we are dealing with Big Integers, and which have a much greater scope than our integer data types.

To remove the added value:

z = z.multiply(e.add(sk).mod(n).modInverse(n))

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.