Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure evidence and correctness proofs #129

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

fjarri
Copy link
Member

@fjarri fjarri commented Jul 8, 2024

No description provided.

#[derive(Debug, Clone)]
pub struct Evidence<Res: ProtocolResult<Verifier>, Sig, Verifier> {
party: Verifier,
result: Res::ProvableError,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why call this a "result"? It seems more like it's used to build up a trace and a context to uphold
the evidence. Would calling this "trace" work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Naming is kind of messy for now, must have been an oversight.

Comment on lines +25 to +28
Res: ProtocolResult<Verifier>,
Sig: Clone + for<'de> Deserialize<'de>,
Verifier: Clone + Ord,
> Evidence<Res, Sig, Verifier>
Copy link
Contributor

Choose a reason for hiding this comment

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

Total nitpick, but I would prefer having the bounds in a where-clause, especially when there are
lots of them like here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder if there's some rustfmt setting where we can formalize it. In this case I agree, it should be in the outer clause.


impl<
Res: ProtocolResult<Verifier>,
Sig: Clone + for<'de> Deserialize<'de>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Remind me again, Sig is usually read "Signature" yes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I'm not particularly happy with this abbreviation, but I didn't come up with anything better. I would prefer to use single letters, but unfortunately Signer and Signature get mixed up.


/// A trait specifying which messages the evidence needs to prove a party's fault,
/// and how to do it.
// TODO: rename this
Copy link
Contributor

Choose a reason for hiding this comment

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

A few ideas: EvidenceContext, EvidenceTrace, BehaviorTranscript, BehaviorTrace,
EvidenceData, InteractionTrace

/// A trait specifying which messages the evidence needs to prove a party's fault,
/// and how to do it.
// TODO: rename this
// TODO (#74): this trait should not be visible to the user,
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you mean "visible"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Either not pub, or at least sealed (I think it'll have to be public).

malicious_round!(MRound3, Round3);

malicious_to_next_round!(MRound1, MRound2);
malicious_to_next_round!(MRound2, MRound3);
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a bug in the macro I think: it does not allow me to specify the type with a path, e.g. crate::some::path::to::MyType.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I don't have a lot of experience with macros and macro hygiene. I'll look into it.

Comment on lines +59 to +61
#[test]
fn execute_keygen() {
let mut shared_randomness = [0u8; 32];
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this still allows users to do silly things like e.g.:

    malicious_to_next_round!(MRound1, Round2); // <–– This shouldn't be allowed right?
    malicious_to_next_round!(MRound2, MRound3);
    malicious_to_result!(Round1); // <–– makes no sense

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if it's possible to prevent this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not without a lot of types and work. And I don't think it's worth it. A proc-macro could look at what the allowed type combinations are and make sure that the rounds fit together but I suspect it would be brittle and awkward to work with.

let mut shared_randomness = [0u8; 32];
OsRng.fill_bytes(&mut shared_randomness);

let ids = BTreeSet::from([Id(0), Id(1), Id(2)]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be called execute_keyinit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you're right. Copy-paste artifact.

return Err(KeyInitError::R3InvalidSchProof);
return Err(KeyInitError {
error: KeyInitErrorType::R3InvalidSchProof,
phantom: (PhantomData, PhantomData),
Copy link
Contributor

Choose a reason for hiding this comment

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

To make it easier to read perhaps we can spell it out like so:

Suggested change
phantom: (PhantomData, PhantomData),
phantom: (PhantomData::<P>, PhantomData::<I>),

Comment on lines +22 to +27
let mut bitvecs = bitvecs;
let mut result = bitvecs.next().unwrap().clone();
for bitvec in bitvecs {
result ^= bitvec;
}
result
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work here?

        bitvecs.fold(Self::default(), |mut result, bitvec| {
            result ^= bitvec;
            result
        })

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that looks better. Maybe should even go into a BitVec method.

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.

2 participants