Skip to content

Document acp-118 message verification #3925

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 1 commit into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions network/p2p/acp118/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ var _ p2p.Handler = (*Handler)(nil)

// Verifier verifies that a warp message should be signed
type Verifier interface {
// Verify verifies that the provided message is valid for this node to sign
// based on the provided justification.
//
// Implementations of Verify are not expected to verify the NetworkID or
// SourceChainID fields of the message. Verification of these fields should
// be performed externally to Verify.
Verify(
ctx context.Context,
message *warp.UnsignedMessage,
Expand Down Expand Up @@ -90,10 +96,13 @@ func (h *Handler) AppRequest(
return signatureToResponse(signatureBytes)
}

// Verify that the payload is valid to sign.
if err := h.verifier.Verify(ctx, msg, request.Justification); err != nil {
return nil, err
}

// The signer internally verifies that the NetworkID and SourceChainID are
// populated with the expected values.
signature, err := h.signer.Sign(msg)
if err != nil {
return nil, &common.AppError{
Expand Down