Repository navigation
Follow SV Node v1.2.3 Chronicle and signature rules in the interpreter - #18
Merged
Merged
Conversation
Add the chronicle verification flag, implied by the afterChronicle era, and match SV Node v1.2.3 where the interpreter differed from it: - Splice operands use the node int64 decoding: at most 9 bytes, then saturate to Int32. - LSHIFTNUM and RSHIFTNUM reject shifts the node rejects; a negative right shift rounds toward zero. - The post-Chronicle number limit is 32,000,000 bytes. - SIGHASH_CHRONICLE signatures are verified with the original digest; the ForkID digest is used only when ForkID is enabled. - The original digest serializes script code as the node does after a failed final push, and FindAndDelete removes only exact pushes. - Malleability rules are relaxed for version > 1 transactions under Chronicle. - The alt stack is cleared between scripts. - Public keys are checked for empty signatures. - NULLFAIL covers every failed signature. - Multisig counts are 4-byte numbers. Record the change as COMP-064 and update the Go parity notes.
…rithmetic bound - Compute the ForkID digest over raw script-code bytes, so a Chronicle unlocking-plus-locking script code is bounded only by the transaction limits and fails with a typed ScriptExecutionError. - Apply only the node's structural DER rule under strict encoding. A signature with an out-of-range r or s now fails CHECKSIG without an error, as in SV Node. - After Genesis, reject arithmetic results longer than the script-number limit, as the node's big-number operators do. - Document the meaning of bip143SignatureHash and when callers must set chronicle themselves, and record the caller-visible changes in COMP-064. - Remove the unused legacy digest overload and add tests for: - multisig NULLFAIL relaxation; - multisig in the unlocking script under Chronicle; - OP_0 removal for an empty signature; - the zero left-shift boundary.
…-node-rules # Conflicts: # Documentation/Compatibility/Rulings.md
A structurally valid signature that the strict parser rejects is now checked for LOW_S the way CPubKey::CheckLowS reads it: values longer than 32 bytes or not below the curve order read as the zero signature, otherwise the real s is compared with half the order. So r = 0 with a high s fails LOW_S, as in the node, instead of failing the signature check. Fix the IsValidSignatureEncoding line range and the pre-Genesis result-size wording, and add a 2MUL result-bound test.
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.
Before: the Swift interpreter differed from SV Node v1.2.3 on Chronicle rules (splice operands, shift counts, number limits, SIGHASH_CHRONICLE/OTDA, alt-stack clearing, malleability relaxation) and on some signature edge cases, so some spends verified differently in Swift than on the network.
After: the interpreter matches SV Node v1.2.3 for every rule checked, including all 21 TS vectors, and the review probes give the node's verdict.
How: each rule was ported from node source (interpreter.cpp, script_num.cpp, pubkey.cpp, big_int.cpp) with a test that fails on the old code. Details and node line references are in COMP-064.
Behaviour changes callers will see
ScriptVerificationFlags.chronicle..afterChronicleimplies it; callers using.afterGenesisor.beforeGenesisfor outputs spent at or after mainnet height 943,816 must pass.chroniclethemselves..enableForkID, a signature without the ForkID bit is now rejected (illegalForkID), as the node's MUST_USE_FORKID does. It used to be accepted against the legacy digest.illegalChronicleandscriptNumberOverflow..lowS, s is read the way the node's lax parser reads it, so r = 0 with a high s is rejected.ScriptExecutionError.transaction(.scriptTooLarge)..bip143SignatureHashnow only requires the ForkID bit under strict encoding and no longer chooses the digest (documented and tested).Testing
swift testin swift:6.1 (Linux): 905 tests passed, 0 failures; only live and opt-in tests skipped. Reviewed line by line against SV Node v1.2.3 source with probes, including a second review of the follow-up fixes.