Skip to content

Commit

Permalink
Remove proof commitment
Browse files Browse the repository at this point in the history
Unnecessary
  • Loading branch information
Lederstrumpf committed Oct 6, 2021
1 parent 9a7186c commit 65a4948
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 70 deletions.
3 changes: 2 additions & 1 deletion src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ where
}
}

impl_strict_encoding!(Proof<Ctx>, Ctx: Swap);

/// Alice parameters required for the initialization step of a swap and used to generate the
/// [`CommitAliceParameters`] and [`RevealAliceParameters`] protocol messages in the commit/reveal
/// round.
Expand Down Expand Up @@ -128,7 +130,6 @@ where
}

impl_strict_encoding!(AliceParameters<Ctx>, Ctx: Swap);
impl_strict_encoding!(Proof<Ctx>, Ctx: Swap);

impl<Ctx> From<protocol_message::RevealAliceParameters<Ctx>> for AliceParameters<Ctx>
where
Expand Down
70 changes: 1 addition & 69 deletions src/protocol_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,74 +190,6 @@ where
type Strategy = AsStrict;
}

// CommitProof

/// Forces Alice to commit to the result of her cryptographic setup before receiving Bob's setup.
/// This is done to remove adaptive behavior in the cryptographic parameters.
#[derive(Clone, Debug, Display)]
#[display(Debug)]
pub struct CommitProof<Ctx: Swap> {
/// The swap identifier related to this message.
pub swap_id: SwapId,
/// Commitment to the proof.
pub proof: Ctx::Commitment,
}

impl<Ctx> CommitProof<Ctx>
where
Ctx: Swap,
{
pub fn commit_to_bundle(
swap_id: SwapId,
wallet: &impl Commit<Ctx::Commitment>,
bundle: bundle::Proof<Ctx>,
) -> Self {
Self {
swap_id,
proof: wallet.commit_to(bundle.proof.as_canonical_bytes()),
}
}

pub fn verify_with_reveal(
&self,
wallet: &impl Commit<Ctx::Commitment>,
reveal: RevealProof<Ctx>,
) -> Result<(), crypto::Error> {
wallet.validate(reveal.proof.as_canonical_bytes(), self.proof.clone())
}
}

impl<Ctx> Encodable for CommitProof<Ctx>
where
Ctx: Swap,
{
fn consensus_encode<W: io::Write>(&self, s: &mut W) -> Result<usize, io::Error> {
let len = self.swap_id.consensus_encode(s)?;
Ok(len + self.proof.as_canonical_bytes().consensus_encode(s)?)
}
}

impl<Ctx> Decodable for CommitProof<Ctx>
where
Ctx: Swap,
{
fn consensus_decode<D: io::Read>(d: &mut D) -> Result<Self, consensus::Error> {
Ok(Self {
swap_id: Decodable::consensus_decode(d)?,
proof: Ctx::Commitment::from_canonical_bytes(unwrap_vec_ref!(d).as_ref())?,
})
}
}

impl_strict_encoding!(CommitProof<Ctx>, Ctx: Swap);

impl<Ctx> Strategy for CommitProof<Ctx>
where
Ctx: Swap,
{
type Strategy = AsStrict;
}

// CommitBobParameters

/// Forces Bob to commit to the result of his cryptographic setup before receiving Alice's setup.
Expand Down Expand Up @@ -392,7 +324,7 @@ where

// RevealProof

/// Reveals the parameters commited by the [`CommitProof`] protocol message.
/// Reveals the proof.
#[derive(Clone, Debug, Display)]
#[display(Debug)]
pub struct RevealProof<Ctx: Swap> {
Expand Down

0 comments on commit 65a4948

Please sign in to comment.