open-web3-stack / open-runtime-module-library

Substrate Open Runtime Module Library
Apache License 2.0
459 stars 298 forks source link

DKG and Randomness Beacon pallets #349

Open mike1729 opened 3 years ago

mike1729 commented 3 years ago

Together with my colleagues, we have implemented a pallet for Distributed Key Generation (DKG) and a randomness beacon pallet using keys generated by the DKG. Our work was founded by a web3 grant.

Here is a description of the architecture of the dkg pallet, here of the randomness beacon pallet, here are some slides explaining a high level overview of both pallets, and here are some benchmarks results and further details on how to use the pallets.

There are numerous benefits of such general purpose pallets as DKG and randomness beacon and among the most popular ones are: threshold cryptography, privacy preserving messaging services, e-voting protocols, gambling and lottery services.

As we are new to the substrate rich ecosystem, we had wanted to merge our pallets to substrate itself (see issue) but was then enlightened that your library is a better place for the pallets. Hence, the question is: are such pallets of interest to you and would you like to merge them into your library?

This is our first-time working with substrate, so while we did our best to learn it from the excellent docs on substrate.dev, by reading its high quality code, and asking questions on riot, we are sure that our architecture and code is not perfect, and would love to fix/adjust whatever may be missing or is not quite optimal.

If you would be interested in merging, but require us to make even substantial changes, then we would be more than happy to introduce them.

burdges commented 3 years ago

I wrote this elsewhere but it'll make more sense here..

I'd suggest basing production randomness beacons off some future production version of https://github.com/kobigurk/aggregatable-dkg which implements https://eprint.iacr.org/2021/005.pdf It changes the crypto dramatically but makes doing a randomness beacon much more viable.

I have not reviewed either the crates linked above, aside from quick comments in https://github.com/paritytech/substrate/issues/7820#issuecomment-756389294, or kobi's code, although 2021/005 does a stellar job of taking many important applied or semi-applied concerns into account (VUF vs VRF, DKG rounds, etc.).

xlc commented 3 years ago

Hi @mike1729! Thanks for considering contribute into ORML.

We are open to any generalized reusable pallets and happy to accept the DKG and Randomness Beacon pallets.

Few things to keep in mind in your PR:

The master is currently using this commit of Substrate, so you may need to update your code to work with it: https://github.com/open-web3-stack/open-runtime-module-library/blob/master/Cargo.dev.toml#L18

I am not qualified to evaluate the cryptography part of the work so would like you to put a disclaimer somewhere to indicate this is unaudited (unless it is actually audited and you have an audit report) and may not suitable for production usage.

Make sure your code is well documented.