This post explains an inherent tension between BLS signature and Hashed Elgamal in the context of a threshold network, and then presents a way to augment such threshold network such that a smart contract can efficiently verify a signature and decrypt/verify encryption onchain.
Introduction
For encryption/decryption and signing, we (usually) require a group, i.e. a single elliptic curve. However, using pairings, we have to choose between and (and even ), each group have their pros and cons depending on the cryptographic protocol we want to use. In practice, is usually preferred given it is much shorter and faster to compute in it, than its counterparties.
This choice of group comes up when designing threshold networks. Indeed, there is a distributed key lying in a group which could be any of the three groups aforementionned. In particular, when using pairing equipped curves, a threshold network can be used to create threshold BLS signatures (which has lots of nice properties and is used more than even in the blockchain space) but it can also be used as a decryption oracle. In the latter, users encrypts towards the threshold network and push the encryption onchain.
This posts shows the pros and cons of using and for each and shows there is a tension between the two. This posts then shows a simple solution to get the best of both worlds. The technique is heavily inspired by a post by Kobi Gurkan on efficient multisignature verification onchain.
Reminder on the cryptographic schemes
BLS Signatures
There are many references on the web that will explain BLS signatures. This post by Remco Bloemen is one of them!
Workflow: user creates a signature and push it onchain. The smart contract will verify the validity of this signature.
Hashed El Gamal
For succinctness and simplicity, we present this CCA version of El Gamal encryption scheme. Note that are many versions and also IBE based encryption scheme (such as the one used for timelock encryption), that will expose the same problem laid in this post.
Workflow: a user encrypts a message, and push it onchain. The smart contract will verify the “validity” of this ciphertext.
Assume we have a generic group , then
- Encryption of msg m is happening on bundled with a DLEQ proof (such as the one used in Privacy Pass by Cloudflare) lying in group .
- Verification of the correctness of the ciphertext involves verifying the DLEQ proof using group operations on G. We do not show it here for succinctness.
- Verification of this proof is done on the smart contract !
Distributed Key Generation
Such protocol is used to generate a distributed private key, such that each node has a share of it, but no one individually can recover the private key. The public key is known. The set of all nodes can act as if it was a single entity.
Let’s assume we have participants, with a threshold of , a distributed public key , with each node having a share -The “public share” can also be computed publicly
To recover the private key , the network would need to come together and compute
Pubkey in , Signature in
- Threshold network public key
- Encryption to threshold network:
- BLS signature σ verification from network:
- where
- This is computed on the smart contract !
In this situation, the trade off is as follow:
- DLEQ proof verification is FAST because only group operations in are involved.
- BLS signature verification is SLOW because of the the hash-to-curve operations which requires to handle operations in . This is especially relevant in context of blockchain where smart contract operations are usually costly.
Pubkey in , Signature in
- Threshold network public key
- Encryption to threshold network:
- BLS signature σ verification from network:
- where
In this situation, the trade off is as follow:
- DLEQ verification is SLOW because group operations in are involved. It is especially relevant in the context of blockchain where we want to verify this DLEQ proof onchain.
- BLS signature verification is FAST because the hash-to-curve operation is fast, as it only involves operations.
Goal
We want the best of both worlds:
- “Encryption to public key” on to get cheap decryption/verification
- “Signature public key” on to get cheap signature verification
- Still having the same “secret key” behind
The end user now have to use the corresponding key depending on which protocol he needs.
Creating a key from the key
The goal is to have a second public key , using the same share, representing the same secret key !
The network must perform the following steps (off chain):
- Each node creates its symmetrical version of its share on and broadcasts it:
- everyone (including third parties) can verify the validity of the new share using the following equations:
- The “public key in can be recovered via regular lagrange interpolation
This key can now be used for BLS signature on !
Verification on chain of the equivalence
How does the contract know what is the new ? How can he verify it is correct ?
We assume the contract already knows the original distributed key P.
An aggregator that performs (a) and (b) can submit on chain. Contract then only need to perform a simple pairing check
This works because both have the same dlog / secret key !
Eviction of malicious node
A node might not generate its second version of its share or give an invalid one. How do you attest of that fact to the smart contract so he can be slashed / excluded ?
Given we now have “cheap” BLS signature, the threshold network (who have a majority of honest nodes) can “BLS sign” on the eviction of this node !
Another solution would for the contract to check (a) using the malicious node values but that might be more expensive to perform because the smart contract may not know in advance. This value requires evaluating the distributed public polynomial and this is linear in the threshold.
Acknowledgements
Thanks to Rosario Gennaro for help on the proof sketch, and Kobi for his post on the idea of translating between and .
Appendix: Proof Sketch
Publishing keys in both group is safe
Assume we have groups and a pairing function
Let
is the public key of a BLS signature scheme where a message is signed by first hashing it into as and the signature is computed as
The verification is
is the public key of a Hashed ElGamal encryption scheme where the encryption of a message is computed as with and together with a DLEQ proof . Decryption is performed only if the proof holds and . The DLEQ proof provides another group element and proves that .
Let’s assume the following problem is hard in
Given
This is the Augmented Computational Diffie-Hellman problem in where we account for the fact that is also known to the adversary.
The aCDH problem is what is needed to prove BLS in Asymmetric Pairings setting (see page 15 of Boneh et al).
Using same secret key for both BLS and El Gamal is safe
We need to show that the simultaneous security of BLS (unforgeable under chosen message attack) and Hashed ElGamal (under chosen ciphertext attack).
Our simulator is given , , from the aCDH problem. It sets as the BLS public key, as the Hashed ElGamal public key and sets for a random
When the adversary is given and asks for a signature on a message the simulator sets for a random and then the signature is .
If the adversary queries a ciphertext to the decryptor, the simulator answers if the proof is not valid. Otherwise we know that and therefore and
On the message that the adversary wants to forge (which is guessed at random by the simulator), the simulator sets then the signature output by the forger must be as desired.
If the adversary issues a “distinguishing query” on Hashed ElGamal by presenting two messages , the simulator chooses at random and encrypts as where is a random string, is a random group element and is a simulated proof that . Note that the simulator is implicitly defining in the above simulation (implicitly since it does not know ). If the adversary guesses with probability better than 1/2 it must have queried B to the random oracle. Note that the simulator can detect when B is queried since so when that queries happens it answers with and outputs B as the desired solution.