-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run distributed key generation on-chain, storing Ack
s and Part
s in a contract.
#35
Comments
@varasev: For this we would need an additional smart contract—not too smart, though: It just needs to record the history of messages that were exchanged during the key generation process. Validators—and only the ones that were selected for the next staking epoch—can commit one |
Actually: Can Parity record events in blocks even without a specific contract? Then we could just store the key generation messages directly. |
Please take a look at the draft of the contract: https://github.com/poanetwork/pos-contracts/blob/master/contracts/KeyGenHistory.sol Is this approximately what we need? |
Looks great! |
Also, we'll probably need events for the messages: It should be possible for a restarting node to read the key generation messages from the blockchain and reconstruct its key shares. |
Ok, I've made corresponding changes: https://github.com/poanetwork/pos-contracts/blob/master/contracts/KeyGenHistory.sol The |
Please pay attention to the next things:
|
Thanks, that looks great, and these three requirements make perfect sense. 👍 I assume |
I propose to simply increment |
You're right, always incrementing is simpler. 👍 |
I think there's one more thing we'll have to store on the blockchain (probably in |
(On the other hand, it would also be feasible to exchange these via Whisper, so they don't necessarily need to go into the contract.) |
We could add the next function for that: mapping(address => bytes) public publicKey;
function savePublicKey(address _validator, bytes _key) public onlySystem {
publicKey[_validator] = _key;
} or (for batch saving) function savePublicKeys(address[] _validators, bytes[] _keys) public onlySystem {
require(_validators.length == _keys.length);
for (uint256 i = 0; i < _validators.length; i++) {
publicKey[_validators[i]] = _keys[i];
}
} Is this correct? Should there be any function to remove the key from the contract after its using? E.g.: function removePublicKey(address _validator) public onlySystem {
delete publicKey[_validator];
} |
Yes, that would be perfect! |
Ok, the |
No, I think it would be called by the validator themselves. |
Ok, function savePublicKey(bytes _key) public {
require(doesPoolExist(msg.sender));
publicKey[msg.sender] = _key;
} I.e., the The second possible variant is function savePublicKey(bytes _key) public {
require(isValidator(msg.sender));
publicKey[msg.sender] = _key;
} I.e., the |
Sorry, I'm still confused about the notions "validator", "observer", "staker" and "pool". (Please also take a look at poanetwork/hbbft#347 — let's make sure we find a consistent naming scheme for all layers of the stack.) (To clarify, this is a full public key, to which the node has the full secret key. These are different from the key shares for threshold encryption that are created in the distributed key generation process.) |
Thanks for the link! In the terminology of the current ReportingValidatorSet contract:
Should I rename |
Thanks for the clarification! I wouldn't rename it just yet, but I'll quote your comment on the naming discussion thread. With the notions as they are right now, I think that an observer should always publish their public key from the beginning. There shouldn't ever be an observer in the contract without a (BLS/threshold_crypto) public key. |
I.e. I imagine the public key should be a field in |
Good idea, I'll think about that. I've added the checking of public key existence when an address tries to become an observer: poanetwork/posdao-contracts@935cb03 Will the public key have an exact length in bytes? Can an address change its public key while it is an observer? E.g., it will call |
Yes… I was going to say "48 bytes", but instead I opened this issue. 😩 (Edit: We'll definitely fix that, of course, so it's going to be 48 bytes.)
We don't have concrete plans for that yet, but I guess in general it's a good idea to allow them to periodically generate a new key? |
Yes, I think so too. |
Got it. |
The |
@DemiMarie Please see my comments in Slack. |
There's an |
@varasev: I think this line isn't right: https://github.com/poanetwork/pos-contracts/blob/98ec9196ceb911891f78bd200c8cb953f0d0c146/contracts/KeyGenHistory.sol#L68 Each It's probably not worth adding a lot of code for this: For our purposes it's enough if the contract just records the events, without any knowledge about the messages' meanings. Sorry for the confusion! I should have given more details in the issue in the first place. |
@afck Please take a look: https://github.com/poanetwork/pos-contracts/blob/7febced6e1cdf292b83cca9b0388429544e95d7b/contracts/KeyGenHistory.sol - is it ok now? |
That looks good, thanks! 👍 |
We agreed that we'll use the |
This is fixed, I believe. |
Is this still relevant? |
Closed in favor of #157. |
Whenever the set of validators changes (due to a new staking epoch or a faulty node being removed), the new validators need to generate their threshold keys, so Honey Badger can be restarted with the new configuration.
To do this, each of the new validators needs to create a
SyncKeyGen
instance with all new validators' public key, and publish theirPart
message on the contract. After each block, they handle all key gen messages stored on the contract. After the first block with whichSyncKeyGen::count_complete
is at least N - f—i.e. ⅔ of the new validators' parts are complete—, the new keys are generated. All old validators terminate their Honey Badger instances, and the new ones start theirs, beginning at the next block.The text was updated successfully, but these errors were encountered: