Skip to content

[examples] Remove prost#709

Merged
patrick-ogrady merged 23 commits into
mainfrom
bc/prost-examples
Apr 18, 2025
Merged

[examples] Remove prost#709
patrick-ogrady merged 23 commits into
mainfrom
bc/prost-examples

Conversation

@BrendanChou
Copy link
Copy Markdown
Collaborator

@BrendanChou BrendanChou commented Apr 10, 2025

Fixes #707

@BrendanChou BrendanChou force-pushed the bc/prost-examples branch 7 times, most recently from acbf094 to eee51f3 Compare April 16, 2025 04:16
@BrendanChou BrendanChou marked this pull request as ready for review April 16, 2025 04:18
Comment thread examples/bridge/README.md
Comment thread examples/bridge/src/bin/indexer.rs Outdated
Comment thread examples/bridge/src/wire.rs Outdated
Comment thread examples/bridge/src/wire.rs Outdated
Comment thread examples/bridge/src/wire.rs Outdated
Comment thread examples/vrf/src/handlers/arbiter.rs Outdated
};
if !C::verify(Some(ACK_NAMESPACE), &payload, public_key, &sig) {
let payload = payload(round, &sender, &commitment);
if !C::verify(Some(ACK_NAMESPACE), &payload, public_key, &signature) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest building verify() into the type we are verifying itself. See #735 for examples of how to do this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it might be nice, I think it doesn't make things that much cleaner in this case. Since each of the enum types are quite different, it doesn't make sense to have a verify() function on the top-level enum (because some types like Abort don't need any information to validate), meaning that there would just be optional verify() functions on the individual structs.

Here's what that would look like, which is actually pretty decent, just kind of weird that you have to re-pass-in the round variable even though it is on the Commitment itself

impl<C: Verifier> Commitment<C> {
    /// Verifies the acknowledgments against the dealer's public commitment.
    pub fn verify(
        &self,
        round: u64,
        dealer: C::PublicKey,
        participants: &Vec<C::PublicKey>,
    ) -> bool {
        let payload = payload(round, &dealer, &self.commitment);
        for (i, signature) in self.acks.iter() {
            let Some(public_key) = participants.get(*i as usize) else {
                return false;
            };
            if !C::verify(Some(ACK_NAMESPACE), &payload, public_key, signature) {
                return false;
            }
        }
        true
    }
}

In this case, most of the actual validation work for Commitment occurs in cryptography/src/bls12381/dkgs/arbiter.rs, so the validation function isn't actually able to remove that much work unless I start reaching into the cryptography module

Especially since this is an example, I suggest we just leave it for now

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have cleaned up the section of code that would have used this function, making it less useful

Comment thread examples/vrf/src/handlers/contributor.rs
Comment thread examples/vrf/src/handlers/wire.rs
@BrendanChou BrendanChou force-pushed the bc/prost-examples branch 3 times, most recently from 694b5d2 to bf32c5a Compare April 17, 2025 22:19
@patrick-ogrady
Copy link
Copy Markdown
Contributor

This should now be unblocked!

Comment thread examples/bridge/src/wire.rs Outdated
Comment thread examples/vrf/src/handlers/arbiter.rs
payload.put_u64(round);
payload.extend_from_slice(dealer);
payload.extend_from_slice(commitment);
pub fn payload<P: Array>(round: u64, dealer: &P, commitment: &poly::Public) -> Vec<u8> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it is worth just creating an Ack object and implementing Codec over it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It mirrors the function here

Let me create an issue to consider modifying both of these functions at once

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrendanChou BrendanChou force-pushed the bc/prost-examples branch 2 times, most recently from b513ccc to 9ca32ec Compare April 18, 2025 21:24
Comment thread examples/bridge/src/application/actor.rs
Comment thread examples/bridge/src/application/actor.rs Outdated
@patrick-ogrady patrick-ogrady merged commit 50b3599 into main Apr 18, 2025
7 checks passed
@patrick-ogrady patrick-ogrady deleted the bc/prost-examples branch April 18, 2025 22:45
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.37%. Comparing base (ea036be) to head (7d6ab4b).
Report is 2 commits behind head on main.

@@           Coverage Diff           @@
##             main     #709   +/-   ##
=======================================
  Coverage   89.37%   89.37%           
=======================================
  Files         165      165           
  Lines       41293    41305   +12     
=======================================
+ Hits        36904    36915   +11     
- Misses       4389     4390    +1     
Files with missing lines Coverage Δ
codec/src/types/primitives.rs 98.94% <100.00%> (-0.02%) ⬇️
cryptography/src/bls12381/dkg/arbiter.rs 96.49% <100.00%> (-0.03%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea036be...7d6ab4b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[examples] Remove prost in favor of commonware_codec

2 participants