Repository navigation
Description
Motivation
StakingRegistry.registerNode / bindNodeId / reclaimNodeId prove ownership of an iroh NodeId by verifying an ed25519 signature over an on-chain challenge (ADR 003 § NodeId Ownership Verification). Today only the interface contracts/src/interfaces/IEd25519Verifier.sol and a test stub contracts/test/mocks/MockEd25519Verifier.sol (always returns the toggled accept) exist. The real verifier is a deploy blocker for the staking surface: without it, NodeId ownership is unverified and any address could bind any NodeId.
This is not blocking other contract work — StakingRegistry's unit tests use the mock, and the verifier is consumed only at deploy time (Partition D wiring passes the deployed verifier address into the StakingRegistry constructor).
Exact requirement (interface is frozen — do not change it)
function verify(bytes32 publicKey, bytes32 messageHash, bytes calldata signature)
external view returns (bool ok);publicKey— 32-byte ed25519 public key = the iroh NodeId (a compressed Edwards point, RFC 8032 little-endian wire encoding).messageHash— 32-byte digest. The node signs these 32 bytes directly as the message M with standard RFC 8032 ed25519 (Sign(sk, M)— NOT ed25519ph / prehashed). So verification must computek = SHA-512(R ‖ A ‖ M) mod Land check[s]B == R + [k]A. InStakingRegistry,messageHash = keccak256(abi.encodePacked(nodeId, msg.sender, block.chainid, registrationNonce[nodeId])).signature— 64 bytes (R ‖ s).view— callers reach it viaSTATICCALL(the interface's reentrancy story depends on this; keep itview).
Environment / constraints
- Solidity
0.8.28, Foundry,evm = cancun. - Target chains: Arbitrum One + Arbitrum Sepolia. No ed25519 precompile (RIP-7212 is secp256r1, not relevant); no SHA-512 precompile (only SHA-256 at
0x02) — SHA-512 must be done in-EVM. Themodexpprecompile (0x05) is available for field inversion / square roots. - Must agree with iroh's verifier (iroh uses ed25519-dalek
verify_strict): cofactorless equation[S]B = R + [k]A, reject small-orderRandA, canonicals(s < L). NOT ZIP-215. A more-permissive on-chain verifier than dalek is a correctness bug.
Work to do
- Find and evaluate a Solidity ed25519 verification library against these criteria, and record the comparison in the PR:
- professionally audited (link the audit), permissively licensed (MIT/Apache), maintained, compiles on 0.8.x;
- does full RFC 8032 over a raw message with internal SHA-512 (so a 32-byte message M works), or composes cleanly from audited SHA-512 + curve primitives;
- realistic gas (on-chain ed25519 is ~0.5–2M gas; measure on an Arbitrum fork, not L1 assumptions);
- acceptance-set parity with
verify_strict(or document precisely where it differs).
Prefer the narrowest audited footprint; pin the exact upstream commit and vendor only the files actually compiled (keep them undercontracts/lib/so fmt/lint/coverage/slither skip them).
- Implement
contracts/src/Ed25519Verifier.solbehind the frozenIEd25519Verifierinterface. Decompress the 32-byte NodeId → curve point with the safety checksverify_strictenforces: canonicaly(y < p), on-curve, and small-order-Arejection. Document the failure-mode contract (returnfalsevs revert) for malformed keys. - Wire it in the Partition D deploy script (pass the deployed address to
StakingRegistry); keepMockEd25519VerifierforStakingRegistryunit tests.
Testing requirements
- RFC 8032 known-answer vectors through the public
verify(...)shape. - Differential vectors generated from
ed25519-dalek(iroh's exact library): independently produce(publicKey, 32-byte messageHash, signature)triples in Rust, hardcode them, assertverify == true; include small-order / non-canonical edge cases and assert parity withverify_strict. - Negatives: tampered signature, wrong key, non-canonical
y, malleables(s >= L), small-order point → rejected. forge test --gas-reporton an Arbitrum fork; record per-verify gas in the PR.
Acceptance criteria
-
Ed25519VerifierimplementsIEd25519Verifier.verifyand passes RFC 8032 + dalek differential KATs. - Canonical-
y, on-curve, small-order-Achecks present and tested. - Chosen library is audited + permissively licensed, pinned to a commit, narrowest-footprint vendored under
lib/, with the evaluation recorded in the PR. - Gas measured on an Arbitrum fork.
- Deploy script passes the real verifier to
StakingRegistry; mock retained for unit tests.
References
contracts/src/interfaces/IEd25519Verifier.solcontracts/src/StakingRegistry.sol—_verifyEd25519OwnershipSignature,registerNode,bindNodeId,reclaimNodeId- ADR 003 § NodeId Ownership Verification, § Reclaim flow
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
github-actions commentedon May 22, 2026
🎯 Triage report
This is a well-scoped implementation task to ship the production
Ed25519Verifiercontract that is currently a deploy blocker for the staking surface. The interface is frozen (IEd25519Verifier.verify), the acceptance criteria are fully specified (RFC 8032 KATs, dalek differential vectors, gas profiling on an Arbitrum fork, deployment wiring), and the security constraints are precise — the verifier must matched25519-dalek verify_strictsemantics, requiring full in-EVM SHA-512 since no precompile is available on Arbitrum. The issue explicitly notes this is apoc-blockingdeploy blocker onceStakingRegistryneeds to go live.📊 Assessment
highadded; existingenhancement,security,technical,poc-blockingare accurate🔗 Similar issues
ProbeResponse/StreamResponse; explicitly carves out that the on-chain NodeId-ownership proof inStakingRegistry.registerNodeis unrelated and stays. Confirms this issue is the surviving load-bearing use of ed25519 on-chain.💡 Notes and suggestions
Library evaluation shortlist
The most commonly cited audited Solidity ed25519 libraries:
witnet/elliptic-curve-solidity— MIT, audited by Cure53, general EC primitives (not ed25519-specific; you'd compose with an SHA-512 impl).JonahGroendal/pk-tree— no independent audit.nicholasgasior/ed25519-sol— unaudited.androlo/standard-contracts— old, unmaintained.1inch/solidity-utilsEd25519 — check audit status; 0.8.x support.The most widely deployed production-grade path on Ethereum (used by LayerZero v2, among others) is the
daimo-eth/p256-verifier-style composition approach: a standalone SHA-512 impl (e.g.,ensdomains/bufferor the sha512 impl in thetoniq-labs/ton-bridgecontracts) paired with ed25519 curve arithmetic. The implementer should check if SNARKs for ed25519 proofs are a viable gas-reduction path (single-SNARK proof submitted once perregisterNode— but this adds a proving infrastructure dep outside scope).Gas reality check
forge test --gas-report --fork-url <arbitrum-sepolia-rpc>.registerNodeis a one-time call per node, so even 1M gas is acceptable if it passes the gas-limit ceiling (Arbitrum block gas limit is typically 32M).verify_strictparity checklistThe implementer must confirm the chosen library (or composed implementation) handles all of:
s: reject ifs >= L(malleable signature)ycoordinate: reject ify >= p(non-canonical encoding)A(public key / NodeId)RandA(8 small-order points on Curve25519)[S]B == R + [k]A(not the cofactor variant[8][S]B == [8](R + [k]A))Sub-task checklist
ed25519-dalekto emit hardcoded(pk, msg_hash_32, sig)test vectors including edge casescontracts/src/Ed25519Verifier.solwith allverify_strictchecksforge testwith RFC 8032 KATs + Rust differential vectorsAdd this agentic workflows to your repo
To install this agentic workflow, run
alpergundogdu commentedon May 29, 2026
Library decision:
get-smooth/crypto-lib(Smoo.th Crypto Lib / SCL)We're using get-smooth/crypto-lib — specifically
src/lib/libSCL_EIP6565.sol(its RIP-6565 ed25519 verifier).Pinned commit:
d714e9824e2e2e44be3c8fd498e0de651ddc9425(2024-12-14,main).Evaluation against the criteria in this issue
doc/Audits/VAR_SmoothCryptoLib_*.pdf) and CryptoExperts (doc/Audits/CRX_smooth_report_*.pdf), 0 residual risks per the project's summary. The library is Ethereum Foundation–funded (it's the reference impl behind RIP-6565). Exact Veridise scope re: the EIP-6565/ed25519 path will be quoted in the PR after reading the report PDF.LICENSE).pragma solidity >=0.8.19 <0.9.0— compatible with our pinned0.8.28.HashInternalcomputesSHA-512(R ‖ A ‖ M)entirely in-EVM via a vendored SHA-512 (external/sha512/Sha2Ext.sol). It's PureEdDSA (not ed25519ph), so our 32-bytemessageHashis passed directly as the messageM. Matches the issue'sk = SHA-512(R ‖ A ‖ M) mod Lrequirement.VerifyrecomputesR' = [S]B + [n−k]A(cofactorless[S]B = R + [k]A, not the[8]cofactor variant) and compares the canonical compressed encoding ofR'to the signature'sRbytes — so a non-canonicalRencoding is implicitly rejected.s(s < L)Verify_LErejectss == 0 || s >= n.forge test --gas-report; recorded in the PR. (This is aview/STATICCALL, so per-verify compute cost is identical on Arbitrum vs L1; only calldata/storage pricing differs, which doesn't apply here.)SCL provides no on-chain public-key decompression. Its
Verify(m, r, s, extKpub)consumes a pre-expanded public keyextKpub(Weierstrass affine coords + compressed form). Every path that buildsextKpub(SCL_EIP6565_UTILS.SetKey) derives it from the secret and is explicitly marked "NEVER USE THIS ONCHAIN." The only decompression code in the repo (edDecompressX) lives in their test file and performs none of theverify_strictsafety checks.On-chain we only have the 32-byte compressed NodeId. So
Ed25519Verifier.solmust do the security-critical decompression itself, then call SCL'sVerify_LE:(y, sign)from the little-endian NodeId; reject non-canonicaly(y ≥ p).xviax² = (y²−1)/(d·y²+1)using SCL'sSqrtMod; reject if not a QR (off-curve); apply the RFC 8032 sign rule (and thex = 0, sign = 1failure case).A(the 8 torsion points) to matchverify_strict(is_small_order).Edwards2WeierStrass) to buildextKpub[0..1]; setextKpub[4]to the compressed key for the hash.SCL_EIP6565.Verify_LE(messageHash, R, s, extKpub).verify_strictparity is therefore wrapper-enforced: SCL covers canonical-s+ cofactorless + canonical-R; our wrapper adds canonical-y+ on-curve + small-order-A. The one residual gap vs. dalek is small-order-Rrejection (SCL never decompressesR); the PR will either add an explicit cofactor check on the recomputedR'or document the divergence precisely, per this issue's "(or document precisely where it differs)" clause.Vendoring plan
Narrowest footprint — the actual compile closure of
libSCL_EIP6565.sol, vendored undercontracts/lib/crypto-lib/at the pinned commit (so fmt/lint/coverage/slither skip it), with a@solidity/=lib/crypto-lib/src/remapping:(
libSCL_eddsaUtils.solis offchain-only / test-only andlibSCL_eccUtils.solpulls in secp256r1 — both excluded from the production closure.)Testing plan
verify(pk, msgHash, sig)shape (decompressing the public key on-chain, not viaSetKey).ed25519-dalek(already a workspace dep; iroh's verifier) — a small Rust helper emits(publicKey, 32-byte messageHash, signature)triples incl. small-order / non-canonical edge cases; asserts parity withverify_strict.y, malleables (≥ L), small-order point → rejected.forge test --gas-report; per-verify gas recorded in the PR.Wiring
script/DeployProtocol.s.solcurrently takes the verifier address fromED25519_VERIFIER_ADDRESS. The PR will deploy the realEd25519Verifierfrom the script (with the env var retained as an override), and keepMockEd25519VerifierforCapacityBondunit tests.(Note: the consumer is
CapacityBond, notStakingRegistry— renamed since this issue was filed; theregisterNode/bindNodeId/reclaimNodeId+_verifyEd25519OwnershipSignaturesurface is unchanged.)test(contracts): full ADR 030 updateRegion e2e — EIP-712 + ed25519 re…
ci(ed25519-vectors): guard differential-vector drift (#1008) (#1075)