Repository navigation
test: generate test key material at runtime instead of committing it - #1163
Conversation
Add test_support::keys (seed, secret_bytes, secret_key, private_key, wif, mnemonic, plus process-stable labelled_* variants keyed by a per-process salt; DET_TEST_KEY_SALT replays it). The module is compiled only for unit tests and the testing/bench features. The shared leak-test secrets now come from it, and AGENTS.md states that test key material is generated at runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Golden vectors that pin DET's own formats (at-rest seed envelope, BLS signature bytes) keep their fixed inputs, now marked as exempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pinned DIP-15 contact vectors and the BIP-32 parity vector keep their fixed inputs, now marked as exempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… database tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
testnet_core_address, seed_hd_wallet, the top-up wallet fixture and both auth_pubkey_cache pubkey helpers derive from labelled keys; the DIP-15 ECDH key-pair helper draws a random key. The ECDH pinned vector keeps its fixed inputs, now marked as exempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The HD signer parity tests use a random seed; only hd_derivation_matches_pinned_vector keeps the fixed seed. In dashpay.rs, TEST_SEED and TEST_SECRET remain only in the two F3 pinned-value tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…placeholders Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split the runtime-key rule into two sentences and name test_support::keys, labelled_* and DET_TEST_KEY_SALT. Document why the salt prints once per thread: libtest shows only a failing test's captured output, so a single process-wide print would miss the test that failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedToo many files! This PR contains 104 files, which is 4 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.
|
|
✅ Final review complete — no blockers (commit d897bfe) · triage: critical · Phase 2 only (no Phase 1 for this repository) |
The seeds in these tests became random, but the checks still looked for fixed byte sequences, so a leak could no longer fail them. Build the forbidden text from the seed under test instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
Move the remaining fixed seeds and secrets in the secret access, legacy key recovery, wallet rename and new identity tests to test_support::keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
The test uses the vector's seed bytes and never read the phrase quoted in its comment. Refer to the vector by name instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
Move the fixed seeds and secrets in the wallets, send, top-up, MCP resolve and legacy migration tests to test_support::keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
These checks still looked for fixed byte sequences. Three of them could no longer fail, because their secrets became random. Build the forbidden text from the secret under test in all four. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
|
Waiting for bot review — coderabbitai skipped after its own rate limit · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
The runtime key-generation helper is well-factored, and the CI snapshot shows successful Test Suite and Clippy checks for the reviewed head. Three in-scope test-maintenance gaps remain: redaction checks only cover the first eight bytes, and two valid fixed private-key fixtures are still committed. These are non-production suggestions, so the appropriate action is COMMENT.
🟡 3 suggestion(s)
2 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Remove the remaining fixed private-key bytes from the identity test
src/backend_task/identity/load_identity.rs:1561
PrivateKeyData::Clear([id as u8; 32]) still embeds the valid secp256k1 scalars [8; 32] and [9; 32] in repository test code. These are private-key values rather than identifiers, so they remain committed key material contrary to this PR's runtime-generation objective. Use a labelled runtime secret so each key remains distinct and replayable.
PrivateKeyData::Clear(crate::test_support::keys::labelled_secret(
"backend_task::identity::load_identity::protected_merge_retains_keys_after_failed_write_and_removal_cleans_them",
id as u64,
)),
source: gpt-6.1-sol (phase2-reviewer: rust-quality)
🟡 Suggestion: Replace the fixed masternode test private keys
src/context/wallet_lifecycle/tests.rs:2541
PrivateKeyData::Clear([0x70 + key_id as u8; 32]) stores three valid secp256k1 private scalars in test source. Although this fixture exercises a failure path, the values remain committed key material and violate the runtime-generation rule established by the PR. A labelled runtime secret preserves per-key distinction and makes failures replayable.
PrivateKeyData::Clear(crate::test_support::keys::labelled_secret(
"context::wallet_lifecycle::tests::clear_network_database_reports_incomplete_when_masternode_key_delete_fails",
key_id as u64,
)),
source: gpt-6.1-sol (phase2-reviewer: rust-quality)
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large cross-cutting diff that changes cryptographic key and secret generation across wallet, identity, signing, encryption, and key-storage tests, including files such as src/test_support/keys.rs and src/wallet_backend/secret_seam.rs. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/test_support/keys.rs`:
- [SUGGESTION] src/test_support/keys.rs:106-111: Check complete secret representations in redaction tests
`rendered_forms` only returns the hex and decimal representations of the first eight bytes. The redaction tests using this helper can therefore pass if a `Debug` implementation leaks only a suffix or another portion after those bytes. This weakens the previous full-hex assertion in the wallet redaction test; the complete runtime-generated secret can be checked without committing key material.
In `src/backend_task/identity/load_identity.rs`:
- [SUGGESTION] src/backend_task/identity/load_identity.rs:1561: Remove the remaining fixed private-key bytes from the identity test
`PrivateKeyData::Clear([id as u8; 32])` still embeds the valid secp256k1 scalars `[8; 32]` and `[9; 32]` in repository test code. These are private-key values rather than identifiers, so they remain committed key material contrary to this PR's runtime-generation objective. Use a labelled runtime secret so each key remains distinct and replayable.
In `src/context/wallet_lifecycle/tests.rs`:
- [SUGGESTION] src/context/wallet_lifecycle/tests.rs:2541: Replace the fixed masternode test private keys
`PrivateKeyData::Clear([0x70 + key_id as u8; 32])` stores three valid secp256k1 private scalars in test source. Although this fixture exercises a failure path, the values remain committed key material and violate the runtime-generation rule established by the PR. A labelled runtime secret preserves per-key distinction and makes failures replayable.
|
Ready for review — files with no dedicated owner: lklimek. |
|
Policy satisfied — this can merge. |
TL;DR: Tests used to build wallets and keys from fixed byte patterns like
[0x42; 64]or[0x2B; 32]. Those patterns are valid private keys, so the repository effectively held hundreds of committed keys. Tests now generate seeds, private keys, WIFs and mnemonics when they run, through one shared helper. Fixed bytes remain only in published compatibility vectors and in golden vectors that pin DET's own formats, and AGENTS.md now says so.Detailed discussion
Follow-up to a review finding on #1151: a fixed pattern is still a valid key, even when it is only meant as a placeholder.
Helper:
test_support::keysCompiled only for unit tests and the
testing/benchfeatures. Release builds don't contain it: the release library's metadata has nolabelled_secretsymbol. Kittest, backend-e2e and the bench reach it asdash_evo_tool::test_support::keys.seed(),secret_bytes(),secret_key(),private_key(net),wif(net)andmnemonic(words)return fresh random material on every call.secret_bytes()rejection-samples, so the result is always a valid secp256k1 scalar.labelled_seed,labelled_secretandlabelled_wif(domain, index)are for helpers whose contract is "the same index gives the same key", such asaddr(n)andknown_wif(). They hash a random per-process salt, so a label gives the same key within a run and a different key on every run. Each test thread prints the salt to stderr, so it appears in a failing test's captured output. To replay a run, setDET_TEST_KEY_SALT=<hex>.Call sites
About 700 lines across model, wallet_backend, context, backend_task, ui/mcp/app/database, kittest, backend-e2e and benches.
TEST_SEED,known_wif(),[seed_byte; 64],[key_byte; 32]) became labelled helpers.Kept on purpose (compatibility and golden vectors)
Each site is commented "exempt from runtime key generation".
model/dashpay_derivation/dip14.rs).backend_task/grovestark.rs).backend_task/dashpay/contact_info.rs,contacts.rs), and the DIP-15 ECDH shared-key pin (ecdh_shared_key_matches_pinned_vector).model/wallet/encryption.rs, Argon2id + AES-GCM), which pins our on-disk format.model/qualified_identity/mod.rs).hd_derivation_matches_pinned_vector(wallet_backend/det_signer.rs). The parity tests use random seeds.wallet_backend/dashpay.rsuse the fixedTEST_SEED/TEST_SECRET.[0; 32],[0xff; 32]) or a phrase with a bad checksum (["abandon"; 12]).IMPORTED_PRIVATE_KEY, untouched.Docs
Risk
Values that used to be fixed now differ on every run. Keys stay distinct and valid by construction, and equality contracts hold through locals or labels. No assertion compares against a value derived from a fixed seed, except the golden vectors above, which keep their fixed inputs.
Testing
cargo test --all-features --workspacepasses:cargo clippy --all-features --all-targets -- -D warningsis clean.checkpasses, andcargo fmtis clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01WunYYhY7P2FJqHVgkHiXtT
🤖 Co-authored by Claudius the Magnificent AI Agent
PR Hygiene ·
d897bfeAGENTS.md,benches/wallet_hydration.rs,docs/ai-design/2026-03-09-password-input/wireframe.htmland 101 more) — approved by lklimekWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.