Zero knowledge proof certification and validation for any datatype
ZeroK provides a simple API for message certification and verification without the verifier needing to know anything about the message contents.
It accepts any datatype which is converted to string, encryped, then a zero knowledge proof certificate is generated for later message verification.
Zerok was inspired by the Paillier Zero Knowledge Proof code from this presentation.
const Zerok = require('./index.js')
const zerok = new Zerok(512)
let message = Math.random() // message to verify
let proof = zerok.proof(message)
let pubkey = zerok.keypair.publicKey
let isValid = zerok.verify(message, proof, pubkey)
console.log('Valid:', isValid) // true
let corruptedMessage = message + 1
let isNotValid = zerok.verify(corruptedMessage, proof, pubkey)
console.log('Valid:', isNotValid) // false
keypair = zerok.newKey(32)
pubkey = zerok.keypair.publicKey
isNotValid = zerok.verify(message, proof, pubkey)
console.log('Valid:', isNotValid) // false
npm i zerok
npm run test
<script src="https://cdn.jsdelivr.net/gh/draeder/zerok@master/dist/zerok.dist.js">
const zerok = new Zerok(512)
// ...
</script>
Creates an instance of Zerok to certify messages with keys created with the passed in bit length
Generates keypair used to certify the next message
Returns a proof certificate object for the passed in message
Verifies that the passed in message matches the original certified by the passed in proof certificate object and pubkey object
Verifies that the passed in proof certificate is valid for the cipher it contains. This option is useful for verification without any knowledge of the original message.
Returns the instance's current keypair
⚠️ Warning TheprivateKey
is sensitive data and should never be shared!
This property is provided to allow developers more flexibility in how they use this library. Please take proper security precautions into consideration if using! It is the zerok instance password! If storing, it should be stored securely.