Skip to content

SignMessage rpc#954

Open
bitcoin-coder-bob wants to merge 1 commit intomasterfrom
bob/SignMessage
Open

SignMessage rpc#954
bitcoin-coder-bob wants to merge 1 commit intomasterfrom
bob/SignMessage

Conversation

@bitcoin-coder-bob
Copy link
Collaborator

@bitcoin-coder-bob bitcoin-coder-bob commented Mar 4, 2026

requested by: #904 (review)

  • Proto: Added SignMessage RPC to SignerService with request/response messages
  • Generated files: Updated .pb.go, .pb.rgw.go, _grpc.pb.go, and OpenAPI spec
  • Port interface: Added SignMessage to SignerService interface
  • Infrastructure client: Implemented SignMessage on signerClient
  • Wallet types: Added SignMessage to WalletService interface
  • Wallet service: Implemented SignMessage using schnorr signing
  • gRPC handler: Added SignMessage handler to signerHandler
  • Tests: New test file with comprehensive SignMessage tests + fixture

Summary by CodeRabbit

  • New Features
    • Message signing capability has been added to the wallet service, allowing users to sign arbitrary messages using their loaded signing keys. The feature provides enhanced flexibility for cryptographic operations and is now fully integrated and available for immediate use.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Walkthrough

A new SignMessage capability is added to the signer service across API specifications, interface definitions, client implementation, wallet service logic, gRPC handlers, and accompanying unit tests with fixtures.

Changes

Cohort / File(s) Summary
API Specifications
api-spec/openapi/swagger/signer/v1/service.openapi.json, api-spec/protobuf/signer/v1/service.proto
Added new POST /v1/sign-message endpoint with SignMessageRequest (containing message bytes) and SignMessageResponse (containing signature bytes) schemas in both OpenAPI and protobuf definitions.
Port & Interface Definitions
internal/core/ports/signer.go, pkg/arkd-wallet/core/application/types.go
Extended SignerService and WalletService interfaces with new SignMessage(ctx context.Context, message []byte) ([]byte, error) method.
Client Implementation
internal/infrastructure/signer/client.go
Implemented SignMessage method on signerClient that invokes the RPC, sends message bytes, and returns signature bytes with standard error handling.
Wallet Service Implementation
pkg/arkd-wallet/core/application/wallet/service.go
Added SignMessage implementation that hashes input with chainhash.HashB, signs with Schnorr using loaded SignerKey, and returns serialized signature; includes error handling for missing signer key.
gRPC Handler
pkg/arkd-wallet/interface/grpc/handlers/signer_handler.go
Added SignMessage RPC handler method that delegates to wallet service and returns response or error.
Test Fixtures & Tests
pkg/arkd-wallet/core/application/wallet/fixtures/service_fixtures.json, pkg/arkd-wallet/core/application/wallet/service_test.go
Created fixture data with test keys and message scenarios; added 219 lines of unit tests validating signature generation, Schnorr verification, deterministic behavior across keys/messages, and error cases.

Sequence Diagram

sequenceDiagram
    actor Client
    participant Handler as gRPC Handler
    participant Wallet as Wallet Service
    participant Signer as Signer Infrastructure
    
    Client->>Handler: SignMessage(message)
    Handler->>Wallet: SignMessage(ctx, message)
    Wallet->>Wallet: Hash message with chainhash.HashB
    Wallet->>Signer: Sign hash with Schnorr key
    Signer-->>Wallet: signature bytes
    Wallet-->>Handler: signature bytes
    Handler-->>Client: SignMessageResponse(signature)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #702: Foundation PR that established the SignerService/wallet plumbing that this PR extends with the new SignMessage RPC method, schemas, and implementations across all layers.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'SignMessage rpc' directly matches the main change: adding a new SignMessage RPC endpoint to the SignerService across proto, generated, interface, and implementation layers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bob/SignMessage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@bitcoin-coder-bob bitcoin-coder-bob marked this pull request as ready for review March 4, 2026 17:03
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/arkd-wallet/core/application/wallet/service_test.go (1)

37-46: Mark test helper functions with t.Helper().

This improves assertion failure locations by attributing failures to callers instead of helper internals.

♻️ Suggested patch
 func loadServiceFixtures(t *testing.T) *serviceFixtures {
+	t.Helper()
 	data, err := os.ReadFile("fixtures/service_fixtures.json")
 	require.NoError(t, err)
@@
 func getTestKey(t *testing.T, fixtures *serviceFixtures, keyName string) *btcec.PrivateKey {
+	t.Helper()
 	for _, k := range fixtures.SignMessageTests.TestKeys {

Also applies to: 48-59

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/arkd-wallet/core/application/wallet/service_test.go` around lines 37 -
46, Add t.Helper() at the start of test helper functions so failures attribute
to the caller; specifically, update loadServiceFixtures(t *testing.T) to call
t.Helper() as the first statement and do the same for the other helper function
defined around lines 48-59 (the other helper's name in the diff) so all
assertions inside those helpers point to the test that invoked them.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/arkd-wallet/core/application/wallet/service_test.go`:
- Around line 37-46: Add t.Helper() at the start of test helper functions so
failures attribute to the caller; specifically, update loadServiceFixtures(t
*testing.T) to call t.Helper() as the first statement and do the same for the
other helper function defined around lines 48-59 (the other helper's name in the
diff) so all assertions inside those helpers point to the test that invoked
them.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62b4605c-d0f2-4235-badb-cbb21d5856e9

📥 Commits

Reviewing files that changed from the base of the PR and between 8615412 and cafe919.

⛔ Files ignored due to path filters (3)
  • api-spec/protobuf/gen/signer/v1/service.pb.go is excluded by !**/*.pb.go, !**/gen/**
  • api-spec/protobuf/gen/signer/v1/service.pb.rgw.go is excluded by !**/gen/**
  • api-spec/protobuf/gen/signer/v1/service_grpc.pb.go is excluded by !**/*.pb.go, !**/gen/**
📒 Files selected for processing (9)
  • api-spec/openapi/swagger/signer/v1/service.openapi.json
  • api-spec/protobuf/signer/v1/service.proto
  • internal/core/ports/signer.go
  • internal/infrastructure/signer/client.go
  • pkg/arkd-wallet/core/application/types.go
  • pkg/arkd-wallet/core/application/wallet/fixtures/service_fixtures.json
  • pkg/arkd-wallet/core/application/wallet/service.go
  • pkg/arkd-wallet/core/application/wallet/service_test.go
  • pkg/arkd-wallet/interface/grpc/handlers/signer_handler.go

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.

1 participant