Skip to content

arkd-signer: native ArkadeScript signing via emulator library#1122

Draft
Kukks wants to merge 13 commits into
arkd-signerfrom
arkd-signer-emulator
Draft

arkd-signer: native ArkadeScript signing via emulator library#1122
Kukks wants to merge 13 commits into
arkd-signerfrom
arkd-signer-emulator

Conversation

@Kukks

@Kukks Kukks commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Draft / stacked on arkd-signer (#1118), which introduced the txsigner library. Depends on emulator#102 (the signing library): the three emulator modules are pinned to a pseudo-version off that PR's branch, to be repointed to the merged commit before un-drafting.

Summary

Gives arkd-signer native ArkadeScript signing for all four spend shapes (onchain, offchain-tx, intent, finalization), signing-only, by importing the emulator as a library (emulator#102) instead of running a separate emulator process.

  • Constructs emulator.Service with the operator key, arkd-signer's own pubkey as arkdPubKey, and a nil finalizer (signing-only — no arkd round-trip, no go-sdk).
  • Registers EmulatorService (+ REST gateway) on arkd-signer's existing gRPC server, next to SignerService.
  • Shared key: the operator key doubles as the emulator's arkade-signing key. Safe because the emulator's reject check matches the raw operator key, while arkade closures carry the tweaked key — so arkade closures get signed and raw-operator closures are refused (those belong to SignerService).
  • Config: ARKD_SIGNER_EMULATOR_COMPUTE_LIMITS (optional VM caps); no ARKD_SIGNER_ARKD_URL.
  • Root go.mod gains gnark-crypto (the VM's pairing) only — no go-sdk.

Compatibility

  • No signerv1 / emulatorv1 wire-protocol changes.
  • Independent emulation under a separate key remains available by running a standalone emulator alongside.

Testing

  • pkg/arkd-signer unit tests pass, incl. a synthetic onchain arkade-signing test asserting the tweaked-key signature (no Nigiri).
  • e2e integration smoke (internal/test/e2e): dials the running arkd-signer's emulatorv1 SubmitOnchainTx and round-trips an onchain arkade spend, asserting the tweaked-key signature — exercised by the Nigiri integration suites (postgres/redis + sqlite/badger).
  • cmd/arkd-signer + arkd + ./... cross-build (linux/amd64).
  • Verified zero go-sdk in arkd-signer + root go.mod/go.sum.

Before un-drafting


CI note — repo-wide security bump (self-dropping): This branch also carries a golang.org/x/crypto→v0.52.0 / golang.org/x/net→v0.55.0 bump across all 10 modules, clearing a newly-published Trivy CVE batch (x/crypto/ssh + x/net/html) that was failing every arkd build (master included). x/net 0.55 deprecates h2c.NewHandler, so SA1019 is suppressed via a targeted .golangci.yml exclusion (not inline //nolint, which trips the golines length limit). The bump is shared with #1118 and self-drops when this rebases onto a master that already carries it. Migrating off h2c to http.Server’s Protocols field is a tracked follow-up.

Kukks added 7 commits June 19, 2026 23:04
- go.mod: require + replace for emulator/pkg/emulator, emulator/pkg/arkade,
  emulator/api-spec; all pointing to C:/Git/_emulator_ref local paths.
  grpchandler is a sub-package of pkg/emulator (no separate module).
- config: add ComputeLimits field parsed from ARKD_SIGNER_EMULATOR_COMPUTE_LIMITS
  (empty => DefaultComputeLimits(), OPCODE=limit overrides via OpcodeByName map).
- config_test: add TestComputeLimitsDefault asserting non-nil ComputeLimits.
…Service

- config: build emulator.Service in initServices() with nil finalizer
  (signing-only). Converts []DeprecatedSignerKey -> []*btcec.PrivateKey.
  Sets arkdPubKey = our own operator pubkey so SubmitOnchainTx rejects
  inputs that also contain the arkd signer key.
- service.go Start(): register grpchandler.New("", emulatorSvc) as
  EmulatorServiceServer and wire REST gateway handler beside the signer.
- emulator_signing_test.go: TestEmulatorGetInfoReturnsOperatorPubkey
  constructs emulator.New with nil finalizer, asserts GetInfo returns the
  operator pubkey both via the Service interface and via the gRPC handler.
TestArkdSignerSignsOnchainArkade builds a fully synthetic PSBT — no
explorer, no chain access — by deriving the funding txid directly from
prevoutTx.TxHash(). The prevout tx uses a coinbase-style input to avoid
the btcd segwit-marker ambiguity that causes MsgTx.Deserialize to fail
on zero-input transactions. Asserts that SubmitOnchainTx produces a
TaprootScriptSpendSig entry keyed by the arkade-tweaked operator pubkey.
Root gains gnark-crypto (VM pairing) + the 3 emulator modules; no go-sdk.
The emulator replaces point to a local checkout for dev; switch to the
released tag before opening the PR.
Switch the 3 emulator modules (pkg/emulator, pkg/arkade, api-spec) from
local dev replaces to pseudo-versions off the arkade-library-export branch
(emulator#102). Repoint to the merged commit once #102 lands.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 728a2916-7266-4a19-adf9-0267986bcf44

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch arkd-signer-emulator

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.

@Kukks
Kukks requested a review from louisinger June 22, 2026 20:18
Add TestArkdSignerEmulatorOnchainSigning to internal/test/e2e that dials
the running arkd-signer gRPC service (localhost:6061, insecure h2c) and
exercises SubmitOnchainTx end-to-end with a synthetic onchain ArkadeScript
spend PSBT built against the compose-default operator key. Asserts that the
returned signed PSBT carries a TaprootScriptSpendSig for the tweaked operator
key, proving the real server signs correctly.

Also promotes emulator/api-spec and emulator/pkg/arkade from indirect to
direct in go.mod (same pinned pseudo-version; no version bump). The compose
port mapping 6061:6061 was already present and required no change.
@Kukks
Kukks force-pushed the arkd-signer-emulator branch from ba969fb to e8ec560 Compare June 23, 2026 06:44
…A1019

x/net 0.55 deprecates h2c.NewHandler; suppress SA1019 via golangci-lint
exclusion. Mirrors the #1118 base fix; self-drops on rebase onto a bumped master.
@Kukks
Kukks force-pushed the arkd-signer-emulator branch from 6c9b3ad to 4ea6916 Compare June 23, 2026 07:16
Add offchain, intent, finalization-guard, and arkd-key-reject signing
tests; fold the onchain test into emulator_signing_test.go as t.Run
subtests. Wrap the initServices error with %w.
Bring in the updated base (merged with master). Conflicts in
pkg/arkd-signer/config, both resolved:
- config.go: keep the base's json:"-" redaction on SignerSvc and extend it
  to EmulatorSvc, which likewise holds the operator key; keep the added
  EmulatorSvc/ComputeLimits fields.
- config_test.go: keep both TestComputeLimitsDefault and the base's
  TestConfigStringRedactsSecrets.
…essage

Bump the three emulator modules (api-spec, pkg/arkade, pkg/emulator)
from the 17dd9d4 pseudo-version to 24936ba, the current emulator#102
(arkade-library-export) tip.

emulator.Intent.Message is now the IntentMessage interface, so pass
&intent.RegisterMessage{} (Decode has a pointer receiver) in the
signing test.

Interim pin to the PR branch tip; repoint again to the squash/merge
commit once emulator#102 lands on master.
…tests

parseComputeLimits now logs a WARN on each skipped entry (malformed pair,
bad value, unknown opcode) instead of silently swallowing it, so an
operator typo cannot quietly weaken the VM compute guard.

Add TestArkdSignerEmulator/SharedKeyNeverSignsRawOperatorKey: in shared-key
signing-only mode, with the raw operator pubkey in the vtxo closure next to
the tweaked arkade key, the emulator must sign only its tweaked key and
never the raw operator key. Locks that guarantee on the offchain path.

Consolidate the compute-limit config test into a grouped TestComputeLimits
(default/valid/malformed/unknown), and close EmulatorSvc on service Stop().
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