fix: require ownership proof for /epoch/enroll#2117
Merged
Scottcjn merged 1 commit intoScottcjn:mainfrom Apr 6, 2026
Merged
Conversation
Contributor
Author
|
For bounty payout, please use RTC wallet: RTC1d48d848a5aa5ecf2c5f01aa5fb64837daaf2f35. |
Owner
|
Merged. Payment: 50 RTC. Addresses #2116. Adds Ed25519 signature verification on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Add Ed25519 signature verification to /epoch/enroll
Problem
POST /epoch/enrollaccepted arbitraryminer_pubkeywithout cryptographic proof of ownership. Any caller who knew a pubkey with a recent attestation could enroll it, enabling:INSERT OR REPLACE INTO miner_header_keysChanges
Server-side (
node/rustchain_v2_integrated_v2.2.1_rip200.py)record_attestation_success(): Addedsigning_pubkeyparameter; stores the Ed25519 public key from attestation inminer_attest_recent.signing_pubkey(idempotentALTER TABLEmigration).enroll_epoch(): Whensignature+public_keyare provided:PUBKEY_MISMATCH→ 400)miner_pubkey|miner_id|epoch(INVALID_ENROLLMENT_SIGNATURE→ 400)ED25519_UNAVAILABLE→ 503)Client-side (
rustchain-miner/src/miner.rs,rustchain-miner/src/attestation.rs)Minerstruct: Addedsigning_key: SigningKeyandpublic_key_hex: Stringfields.Miner::new(): Generates Ed25519 keypair at startup (reused for attestation + enrollment).do_attestation(): Uses newattest_with_key()function with the stored keypair.enroll(): Signsminer_pubkey|miner_id|epochwith the same keypair used in attestation.attestation.rs: Addedattest_with_key()function (accepts pre-generated keypair); originalattest()retained for backward compatibility.Tests (
node/tests/test_enroll_signature_verification.py)7 test cases:
PUBKEY_MISMATCH)INVALID_ENROLLMENT_SIGNATURE)INVALID_ENROLLMENT_SIGNATURE)Compatibility
ALTER TABLE miner_attest_recent ADD COLUMN signing_pubkey TEXT— safe to run on existing databases.attest()function is retained alongside the newattest_with_key().Verification
cargo checkpasses (no warnings)test_attest_signature_verification.pyandtest_attestation_overwrite_reward_loss.pyunaffected