v0.0.45 - Display qrexec service name (qubes.NsignerRpc) in signer connection info; use human-readable timestamps in activity log; fix static release build by adding miner.c to Dockerfile.alpine-musl

This commit is contained in:
Laan Tungir
2026-07-11 19:12:34 -04:00
parent 1b5af2fd33
commit 6fd7b8ce1f
14 changed files with 1644 additions and 12 deletions

View File

@@ -178,6 +178,7 @@ Request shape is JSON-RPC with NIP-46-style methods and optional trailing select
{ "id": "2", "method": "sign_event", "params": ["<event_json>", { "role": "main" }] }
{ "id": "3", "method": "sign_event", "params": ["<event_json>", { "nostr_index": 7 }] }
{ "id": "4", "method": "sign_event", "params": ["<event_json>", { "role_path": "m/84'/0'/0'/0/5", "purpose": "bitcoin", "curve": "secp256k1" }] }
{ "id": "5", "method": "mine_event", "params": ["<event_json>", { "difficulty": 20, "threads": 4, "timeout_sec": 30, "nostr_index": 0 }] }
```
Implemented signer verbs in this build:
@@ -186,6 +187,42 @@ Implemented signer verbs in this build:
- `sign_event`
- `nip04_encrypt` / `nip04_decrypt`
- `nip44_encrypt` / `nip44_decrypt`
- `mine_event` — add NIP-13 proof-of-work and sign (see below)
### `mine_event` — NIP-13 Proof-of-Work
Mines proof-of-work (adds a `nonce` tag per NIP-13) and signs the event in one step. The mining runs in a detached thread so the server stays responsive.
**Parameters (in options object):**
| Option | Required | Default | Description |
|--------|----------|---------|-------------|
| `difficulty` | One of difficulty/timeout | 0 (no target) | Target leading zero bits. Stops early if reached. |
| `timeout_sec` | One of difficulty/timeout | 600 (safety) | Time budget in seconds. Always returns best result found. |
| `threads` | No | 1 | Number of mining threads (max 32). |
At least one of `difficulty` or `timeout_sec` must be specified. If both are given, mining stops when either condition is met. The response always includes the best event found — timeout is not an error.
**Response format:**
```json
{
"id": "5",
"result": {
"event": "<signed event JSON with nonce tag>",
"achieved_difficulty": 18,
"target_difficulty": 20,
"target_reached": false,
"elapsed_sec": 30,
"attempts": 4523456
}
}
```
**Error codes:**
- `1007``no_termination_condition` (neither difficulty nor timeout_sec specified)
- `1008``mining_failed` (internal error)
Selector resolution order:
@@ -215,6 +252,7 @@ Selector resolution chooses *which* role. Enforcement decides *whether the reque
Example:
- `sign_event` requires `purpose="nostr"` and `curve="secp256k1"`.
- `mine_event` requires `purpose="nostr"` and `curve="secp256k1"` (same as `sign_event`).
- If caller selects a Bitcoin-role key for `sign_event`, request fails with `purpose_mismatch`.
This prevents cross-protocol misuse inside one mnemonic-rooted signer process.