-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: proposal acceptance signatures are submitted and validated (#4288)
Description --- * feat(base_layer): added proposal acceptance signature validation * refactor(base_layer): DRYing the check of proposal in transaction outputs with a new `output_contains_proposal` function * feat(dan_layer): `AcceptanceManager` now also publishes update proposals, and with the correct signature * fix(integration_test): `proposal_id` value in fixtures is not consistent Motivation and Context --- Proposal acceptances need to be signed by the validator node submitting them. Also, the base layer should validate that the signature is valid. Similar to [recent PRs](#4269), the proposal acceptance signatures follow: `e = H_1(signer_public_key || public_nonce || H_2(contract_id||proposal_id||proposal_commitment))` How Has This Been Tested? --- * New unit test to check the base layer validation of proposal acceptance signatures * For the validation node part, the existing integration test do not raise the signature error
- Loading branch information
Showing
11 changed files
with
281 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ctions/transaction_components/side_chain/contract_update_proposal_acceptance_challenge.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2022. The Tari Project | ||
// | ||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
// following conditions are met: | ||
// | ||
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
// disclaimer. | ||
// | ||
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the | ||
// following disclaimer in the documentation and/or other materials provided with the distribution. | ||
// | ||
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote | ||
// products derived from this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE | ||
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
use digest::Digest; | ||
use tari_common_types::types::{Commitment, FixedHash, HashDigest}; | ||
use tari_utilities::ByteArray; | ||
|
||
#[derive(Debug, Clone, Copy)] | ||
pub struct ContractUpdateProposalAcceptanceChallenge(FixedHash); | ||
|
||
impl ContractUpdateProposalAcceptanceChallenge { | ||
pub fn new(constiution_commitment: &Commitment, contract_id: &FixedHash, proposal_id: u64) -> Self { | ||
// TODO: Use new tari_crypto domain-separated hashing | ||
let hash = HashDigest::new() | ||
.chain(constiution_commitment.as_bytes()) | ||
.chain(contract_id.as_slice()) | ||
.chain(proposal_id.to_le_bytes()) | ||
.finalize() | ||
.into(); | ||
Self(hash) | ||
} | ||
} | ||
|
||
impl AsRef<[u8]> for ContractUpdateProposalAcceptanceChallenge { | ||
fn as_ref(&self) -> &[u8] { | ||
self.0.as_ref() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.