Skip to content

Commit

Permalink
Pass compressed public key in nextPublicKeySignatureSumbitted and pub…
Browse files Browse the repository at this point in the history
…licKeySignatureChanged events (#704)

* Pass compressed public key

* update checkout to v3
  • Loading branch information
1xstj authored Sep 5, 2023
1 parent b8b8c6c commit 7641439
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Check markdown links
uses: gaurav-nelson/github-action-markdown-link-check@v1
Expand All @@ -33,7 +33,7 @@ jobs:
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install latest nightly
uses: dtolnay/rust-toolchain@stable
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
sudo rm -rf /var/lib/apt/lists/*
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Toolchain
uses: dtolnay/rust-toolchain@stable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-rust-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: docs
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install apt dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
sudo apt-get clean
- name: Checkout Sources
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Restore Cache
if: always()
Expand Down
13 changes: 11 additions & 2 deletions pallets/dkg-metadata/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ pub mod pallet {
pub_key: Vec<u8>,
/// The Signature of the data above, concatenated.
signature: Vec<u8>,
/// The compressed pub key
compressed_pub_key: Vec<u8>,
},
/// Current Public Key Changed.
PublicKeyChanged { compressed_pub_key: Vec<u8> },
Expand All @@ -733,6 +735,8 @@ pub mod pallet {
pub_key: Vec<u8>,
/// The Signature of the data above, concatenated.
signature: Vec<u8>,
/// The compressed pub key
compressed_pub_key: Vec<u8>,
},
/// Misbehaviour reports submitted
MisbehaviourReportsSubmitted {
Expand Down Expand Up @@ -1871,9 +1875,9 @@ impl<T: Config> Pallet<T> {
RefreshNonce::<T>::put(next_nonce);

// Emit events so other front-end know that.
let compressed_pub_key = next_pub_key.1;
let compressed_pub_key = next_pub_key.1.clone();
Self::deposit_event(Event::PublicKeyChanged {
compressed_pub_key: compressed_pub_key.into(),
compressed_pub_key: compressed_pub_key.clone().into(),
});

// At this point the refresh proposal should ALWAYS exist
Expand All @@ -1885,6 +1889,7 @@ impl<T: Config> Pallet<T> {
nonce: curr.nonce,
pub_key: curr.pub_key,
signature: next_pub_key_signature.into(),
compressed_pub_key: compressed_pub_key.to_vec(),
});

CurrentRefreshProposal::<T>::kill();
Expand Down Expand Up @@ -2427,6 +2432,9 @@ impl<T: Config> OnSignedProposal<T::MaxProposalLength> for Pallet<T> {
ensure!(proposal.is_signed(), Error::<T>::ProposalNotSigned);

if proposal.kind() == ProposalKind::Refresh {
let (_, next_pub_key) =
Self::next_dkg_public_key().ok_or(Error::<T>::NoNextPublicKey)?;

// Check if a signature is already submitted. This should also prevent
// against manipulating the ECDSA signature to replay the submission.
ensure!(
Expand Down Expand Up @@ -2466,6 +2474,7 @@ impl<T: Config> OnSignedProposal<T::MaxProposalLength> for Pallet<T> {
voter_count: curr.voter_count,
nonce: curr.nonce,
pub_key: curr.pub_key,
compressed_pub_key: next_pub_key.into(),
});
};

Expand Down

0 comments on commit 7641439

Please sign in to comment.