Skip to content

Commit

Permalink
Validators: uses Ethereum address for proof of possession (#1494)
Browse files Browse the repository at this point in the history
* Uses Ethereum address for the PoP and latest hashing algorithm

* Temporarily changes Geth tests branch to kobigurk/proof_of_possesion_zexe_upgrade

* lint

* changes ci tests to point back to master for some of the tests

* CI: makes exit test use temp branch

* CI: changes attestations tests to work against the temp branch

* Uses latest bls12377js
  • Loading branch information
kobigurk authored Oct 31, 2019
1 parent 51c359d commit 6cf95b7
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 38 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ jobs:
command: |
set -e
cd packages/celotool
./ci_test_transfers.sh checkout master
./ci_test_transfers.sh checkout kobigurk/proof_of_possesion_zexe_upgrade
end-to-end-geth-exit-test:
<<: *e2e-defaults
Expand All @@ -518,7 +518,7 @@ jobs:
command: |
set -e
cd packages/celotool
./ci_test_exit.sh checkout master
./ci_test_exit.sh checkout kobigurk/proof_of_possesion_zexe_upgrade
end-to-end-geth-governance-test:
<<: *e2e-defaults
Expand All @@ -538,7 +538,7 @@ jobs:
command: |
set -e
cd packages/celotool
./ci_test_governance.sh checkout master
./ci_test_governance.sh checkout kobigurk/proof_of_possesion_zexe_upgrade
end-to-end-geth-sync-test:
<<: *e2e-defaults
Expand All @@ -557,7 +557,7 @@ jobs:
command: |
set -e
cd packages/celotool
./ci_test_sync.sh checkout master
./ci_test_sync.sh checkout kobigurk/proof_of_possesion_zexe_upgrade
end-to-end-geth-integration-sync-test:
<<: *e2e-defaults
Expand Down Expand Up @@ -592,7 +592,7 @@ jobs:
command: |
set -e
cd packages/celotool
./ci_test_attestations.sh checkout master
./ci_test_attestations.sh checkout kobigurk/proof_of_possesion_zexe_upgrade
end-to-end-geth-validator-order-test:
<<: *e2e-defaults
Expand Down
2 changes: 1 addition & 1 deletion packages/celotool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"bignumber.js": "^7.2.0",
"bip32": "^1.0.2",
"bip39": "^2.5.0",
"bls12377js": "https://github.com/celo-org/bls12377js#4f596cabb659c4f8969ae4b617f185f2bc74cbbb",
"bls12377js": "https://github.com/celo-org/bls12377js#cada1105f4a5e4c2ddd239c1874df3bf33144a10",
"dotenv": "6.1.0",
"ecurve": "^1.0.6",
"js-yaml": "^3.13.1",
Expand Down
12 changes: 9 additions & 3 deletions packages/protocol/contracts/governance/Validators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ contract Validators is
publicKeysData.length == (64 + 48 + 96)
);
// Use the proof of possession bytes
require(checkProofOfPossession(publicKeysData.slice(64, 48 + 96)));
require(checkProofOfPossession(msg.sender, publicKeysData.slice(64, 48 + 96)));

address account = getLockedGold().getAccountFromActiveValidator(msg.sender);
require(!isValidator(account) && !isValidatorGroup(account));
Expand All @@ -377,9 +377,15 @@ contract Validators is
* @param proofOfPossessionBytes The public key and signature of the proof of possession.
* @return True upon success.
*/
function checkProofOfPossession(bytes memory proofOfPossessionBytes) private returns (bool) {
function checkProofOfPossession(
address sender,
bytes memory proofOfPossessionBytes
) private returns (bool) {
bool success;
(success, ) = PROOF_OF_POSSESSION.call.value(0).gas(gasleft())(proofOfPossessionBytes);
(success, ) = PROOF_OF_POSSESSION
.call
.value(0)
.gas(gasleft())(abi.encodePacked(sender, proofOfPossessionBytes));
return success;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/protocol/migrations/17_elect_validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ async function registerValidator(
const blsPublicKey = bls12377js.BLS.privateToPublicBytes(blsValidatorPrivateKeyBytes).toString(
'hex'
)
const blsPoP = bls12377js.BLS.signPoP(blsValidatorPrivateKeyBytes).toString('hex')
const blsPoP = bls12377js.BLS.signPoP(
blsValidatorPrivateKeyBytes,
Buffer.from(address.slice(2), 'hex')
).toString('hex')
const publicKeysData = publicKey + blsPublicKey + blsPoP

await lockGold(
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@0x/subproviders": "^5.0.0",
"@celo/utils": "^0.1.0",
"apollo-client": "^2.4.13",
"bls12377js": "https://github.com/celo-org/bls12377js#4f596cabb659c4f8969ae4b617f185f2bc74cbbb",
"bls12377js": "https://github.com/celo-org/bls12377js#cada1105f4a5e4c2ddd239c1874df3bf33144a10",
"chai-subset": "^1.6.0",
"csv-parser": "^2.0.0",
"csv-stringify": "^4.3.1",
Expand Down
Loading

0 comments on commit 6cf95b7

Please sign in to comment.