Blind Threshold BLS Signatures
This library provides wasm bindings for producing and verifying blind threshold signatures
on BLS12-377. This is done by utilizing wasm-pack
and
the underlying Rust library.
You can find details on the functionalities provided per function by inspecting
the Typescript types file
Install by running: npm install @celo/blind-threshold-bls
Examples
Currently there are 2 examples available. You can run them and inspect the comments in the files
by executing:
$ node examples/blind.js
$ node examples/tblind.js
Usage
Simple signing
const threshold = require("@celo/blind_threshold_bls")
const crypto = require('crypto')
const msg = Buffer.from("hello world")
const user_seed = crypto.randomBytes(32)
const blinded_msg = threshold.blind(msg, user_seed)
const blind_msg = blinded_msg.message
const service_seed = crypto.randomBytes(32)
const keypair = threshold.keygen(service_seed)
const private_key = keypair.privateKey
const public_key = keypair.publicKey
const blind_sig = threshold.sign(private_key, blind_msg)
const unblinded_sig = threshold.unblind(blind_sig, blinded_msg.blindingFactor)
threshold.verify(public_key, msg, unblinded_sig)
console.log("Verification successful")
Threshold Signatures
const threshold = require("@celo/blind_threshold_bls")
const crypto = require('crypto')
function flattenSigsArray(sigs) {
return Uint8Array.from(sigs.reduce(function(a, b){
return Array.from(a).concat(Array.from(b));
}, []));
}
const msg = Buffer.from("hello world")
const userSeed = crypto.randomBytes(32)
const blinded = threshold.blind(msg, userSeed)
const blindedMessage = blinded.message
const t = 3;
const n = 4;
const keys = threshold.thresholdKeygen(n, t, crypto.randomBytes(32))
const shares = keys.shares
const polynomial = keys.polynomial
let sigs = []
for (let i = 0 ; i < keys.numShares(); i++ ) {
const sig = threshold.partialSign(keys.getShare(i), blindedMessage)
sigs.push(sig)
}
for (const sig of sigs) {
threshold.partialVerify(polynomial, blindedMessage, sig)
}
const blindSig = threshold.combine(t, flattenSigsArray(sigs))
const sig = threshold.unblind(blindSig, blinded.blindingFactor)
threshold.verify(keys.thresholdPublicKey, msg, sig)
console.log("Verification successful")