VER-005: Maintainability and Documentation Findings - #6
Draft
gnosed wants to merge 1 commit into
Draft
Conversation
gnosed
force-pushed
the
audit/ver-005-maintainability-and-documentation
branch
2 times, most recently
from
August 26, 2026 11:15
01e38cf to
c442b37
Compare
Veridise VER-005 (#1290), all ten items, plus the tracking docs. 1. hash_to_point range-checks sampled coefficients in release builds, returning false (verification failure) rather than a debug-only assert, so __check_auth stays panic-free. 2. hash_to_point documents the unframed nonce||message absorption and the fixed 40-byte nonce requirement (plus a debug_assert on the length). 3. Smart-account module docs cover the 897-byte instance-storage footprint against the 64 KiB shared entry limit, as a design constraint for anyone adding instance state. 4/8. FALCON_512_NI = 128 (R/512 mod Q) in falcon-512-core lib.rs replaces the nine-step halving of R in ntt_inverse; a compile-time assert pins NI * N == R (mod Q) via FALCON_512_LOGN. field_halve deleted, dead once the loop went. 5. __check_auth pubkey-length check kept, documented as load-bearing: it is what makes the fixed-buffer copy panic-free. 6. decode_pubkey documents that h is unspecified and must be discarded when decoding fails. 7. verify_raw_512 made private with its caller-established invariants documented; ntt.rs narrowed to pub(crate)/private per actual callers. 9. Unreachable acc_len leftover-bits check replaced with debug_assert_eq!(acc_len, 0) plus the 896*8 = 512*14 tiling that holds the invariant up. 10. init/rotate events migrated off the deprecated Events::publish to FalconInit/FalconRotate #[contractevent] types, wire shape unchanged so existing indexers keep working. Also reworks the surrounding comments: audit finding IDs dropped in favour of the reasoning they pointed at, and the prose tightened throughout. Tests (unit, KAT, testutils integration), clippy, and both WASM builds pass.
gnosed
force-pushed
the
audit/ver-005-maintainability-and-documentation
branch
from
August 27, 2026 12:49
c442b37 to
132b85f
Compare
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.
Remediates all ten items reported in Veridise VER-005 (issue #1290).
Important
This branch is stacked on VER-001 (#2). Its base is currently
main, sothe diff shown here includes VER-001's five commits as well as this one.
Either retarget the base to
audit/ver-001-nonstandard-0x29-signatures, ormerge #2 first — after which GitHub retargets this PR to
mainautomaticallyand the diff narrows to the single VER-005 commit.
The dependency is real, not incidental: item 7 edits
verify.rs, the samefile VER-001 rewrites, and VER-005's original pass had rewritten the
"Accepted signature formats" module docs that VER-001 establishes were
factually wrong. VER-001's corrected text was taken wholesale for that
region.
What changed
debug_assert!(v < Q)is dropped from release buildshash_to_pointreturnsbool;verify_512treatsfalseas verification failure. See deviation below.nonce || messageabsorption is undocumenteddebug_assert_eq!on the lengthlet logn = 9duplicatesFALCON_512_LOGN__check_authlength check is redundantdecode_pubkeymay leavehpartially writtenhonfalseverify_raw_512andntt.rsover-exposedverify_raw_512now private with its three caller-established invariants documented;ntt.rsispub(crate)for exactly the six functionsverify.rsimports, private for everything elsenirecomputed by halvingRnine timesFALCON_512_NI = 128inlib.rs, used directly; a compile-time assert pinsNI * N ≡ R (mod Q)acc_lencheck can never firedebug_assert_eq!(acc_len, 0)plus the896 * 8 == 512 * 14reasoning that holds it upEvents::publishis deprecatedFalconInit/FalconRotate#[contractevent]types, wire shape unchanged so existing indexers keep workingDeviation from the recommendation (item 1)
The finding asks for "a runtime assertion." This PR does not use
assert!.assert!panics, and__check_authmust not: a panic there traps the hostcall instead of returning
Err(VerificationFailed), which is a worse on-chainoutcome than a clean rejection.
hash_to_pointtherefore returnsboolandthe caller fails verification. The safeguard runs in release builds either
way, which is what the finding is actually after.
Two notes on scope
Item 4 was satisfied by deletion rather than substitution. Item 8 removed
the halving loop that was
logn's only consumer, so the duplicate local isgone;
FALCON_512_LOGNis still used inntt.rs, in the assert pinning thenew constant.
Item 9 left one
acc_lencheck in place, indecode_sig_compressed.Signature bodies are variable-length, so its accumulator genuinely can hold
leftover bits. Only
decode_pubkey's copy was ineffective, because the896-byte gate makes that arithmetic exact.
Verification
falcon-512-core7 tests,soroban-falcon-smart-account18 (incl.testutilsintegration),soroban-falcon-verifier8 — all passingFALCON_512_NIsubstitutionand the visibility changes are behaviour-preserving
stellar contract buildcargo clippyshows no new warningsAlso in this PR
Comments across the touched files were rewritten for clarity, and audit
finding IDs (
VER-,DEC-,DRS-,F-00, PR references) were removed fromcode comments — they belong in
docs/audit/, not in the source, where they gostale and mean nothing to a reader without the tracker. The reasoning each ID
pointed at was written out in place instead. One pointer to
docs/audit/constant-time-analysis.mdis kept deliberately: it is the onlything explaining why the modular reduction is four unrolled subtractions
rather than a loop that lowers to
UDIV.The regression test
test_dec002_arbitrary_padding_rejectedwas renamed totest_arbitrary_padding_rejected; theAUD-001row inremediation-log.mdwas updated to match.