Skip to content

feat: define Signed<M, A> message #321

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

Merged
merged 7 commits into from
May 22, 2025
Merged

Conversation

Farhad-Shabani
Copy link
Member

Closes: #320

@Farhad-Shabani Farhad-Shabani changed the title feat: define signed message feat: define Signed<M, S> message May 14, 2025
fn verify(&self, pub_key: HexBinary, msg: impl AsRef<[u8]>) -> Result<(), Error>;
}

impl Verifier for Signature<SpendAuth> {
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 added this example impl to showcase what a Verifier implementation might look like and to explain why the verify method has that particular signature. Once the changes are approved, I’ll remove this along with the decaf377-rdsa dependency.

Side note: one reason we introduced this Signed type was to avoid the orphan rule, where we’d need to implement the Quartz trait (in our case, HasUserData) for a foreign type. But it seems not avoidable. Even with this Signed type, we’d still need to wrap the signature in our usecase as a newtype so can implement this Verifier trait. Unless there’s another approach I’ve missed?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think you're right 😓 , the newtype is unavoidable. Ig the other option is to have a third generic field in the Signed struct that implements the verifier e.g. ->

#[derive(Clone, Debug, PartialEq)]
pub struct Signed<M, S, V = EcdsaSigVerifier> {  // Provide a PenumbraSigVerifier too
    msg: M,
    sig: S,
    verifier: PhantomData<V>, 
}

Haven't thought this through but it might be more restrictive if we just used PhantomData especially if the verifier needed its own state. I think what you implemented is better.

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, that makes sense. if the verifier ends up needing internal state, that could be limiting.

BTW, we can keep this PR open for a bit before merging, just to see how everything plays out on the prime side after integrating this signed message, if that makes sense?

@Farhad-Shabani Farhad-Shabani marked this pull request as ready for review May 14, 2025 05:15
@Farhad-Shabani Farhad-Shabani requested a review from hu55a1n1 May 14, 2025 05:15
@Farhad-Shabani Farhad-Shabani changed the title feat: define Signed<M, S> message feat: define Signed<M, A> message May 21, 2025
@Farhad-Shabani
Copy link
Member Author

While working on the epoch-based clearing issue, I experimented with this new message format to see what it could handle. Mainly to (1) limit who can request a clearing, and (2) tell apart signed requests from the enclave vs. those from admins. Turns out, we can't just use SignedMsg as-is. We’ll need to make some decisions or do a bit of refactoring around which public key to use there.

That said, after some trial and internal discussions, the implementation got a few updates. I added an Auth trait to make things more flexible. The nice part is we don’t need to define a newtype wrapper in Prime anymore (Demoed here.)

So as for this PR, I think we’re good to go now, unless there’s anything else?

@Farhad-Shabani Farhad-Shabani merged commit 23b0671 into main May 22, 2025
8 checks passed
@Farhad-Shabani Farhad-Shabani deleted the farhad/define-signed-msg branch May 22, 2025 21:44
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.

Avoid remote attestations for enclave messages by having them signed by the enclave pubkey
2 participants