Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Documentation/Compatibility/GoSDK-v1.3.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Public:
- `Debugger` lifecycle hooks.
- `ScriptNumber`: construction, sign-magnitude bytes, arithmetic/comparisons, integer conversions.
- `CheckMinimalDataEncoding`, `MinimallyEncode`, external signature-verifier injection.
- Era/limit constants: pre-Genesis op/stack/script/element/number/pubkey limits and 32 MiB Chronicle number limit.
- Era/limit constants: pre-Genesis op/stack/script/element/number/pubkey limits and 32 MiB Chronicle number limit. Swift uses the SV Node limit of 32,000,000 bytes instead (COMP-064).

Edges: EC/hash, script, transaction, sighash, `x/crypto/ripemd160`.

Expand Down Expand Up @@ -893,7 +893,10 @@ License warning: these live under the Open BSV-licensed upstream. Use the Go ora
5. Era boundaries:
- pre-Genesis number length 4 and classic script/stack/op limits,
- post-Genesis number ceiling 750,000 bytes,
- post-Chronicle number ceiling 32 MiB,
- post-Chronicle number ceiling 32,000,000 bytes (SV Node
`MAX_SCRIPT_NUM_LENGTH_AFTER_CHRONICLE`; Go uses 32 MiB, see COMP-064),
- post-Chronicle `OP_RSHIFTNUM` rounds a negative value toward zero, as
SV Node does; Go floors it (COMP-064),
- Chronicle reactivates/version-gates `VER`, `VERIF`, `VERNOTIF`, `2MUL`, `2DIV`, `SUBSTR`, `LEFT`, `RIGHT`, numeric shifts.
6. Minimal-push is checked at numeric evaluation/policy-dependent points, not indiscriminately for every unevaluated push.
7. Legacy `SIGHASH_SINGLE` out-of-range “hash of 1” bug is consensus.
Expand Down
3 changes: 2 additions & 1 deletion Documentation/Compatibility/Rulings.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ behind the general rule.
| COMP-018 | Pinned Go SDK call sites use ordinary standard Base64 decoding, which tolerates CR/LF and non-zero discarded bits; Go Base58 rejects forbidden characters but reports a non-indexed error. | Swift Hex accepts ASCII case but otherwise rejects malformed input. Swift Base64 requires canonical encoding, rejects all whitespace including CR/LF, and rejects non-zero discarded bits. Swift Base58 rejects every non-alphabet character with its zero-based UTF-8 byte offset. Every Swift text decoder requires an explicit output maximum. | Deterministic cross-platform parsing and bounded hostile-input handling outweigh permissive decoder parity. Canonical encoders remain interoperable. Test the strict Swift results against the SDK-like non-strict Base64 oracle policy, and verify that both Base58 decoders reject forbidden input while preserving their documented error-detail difference. |
| COMP-021 | Go v1.3.3 classifies a one-input transaction with a zero previous hash as coinbase when either the previous-output index or sequence is `0xffffffff`. | Require the consensus null outpoint: one input, zero previous hash, and previous-output index `0xffffffff`; sequence is irrelevant. | Avoids misclassifying an ordinary null-hash input merely because it is finalized. Test non-final coinbase sequence and zero-hash/final-sequence with a non-max index. |
| COMP-022 | Go Script ASM normalizes push encodings, returns empty text for malformed programs, and can silently ignore standalone push-opcode append errors. BRC-106, Go and @bsv/sdk 4.x give conflicting names to the Chronicle and high NOP bytes, so the same text can mean different bytes. | Treat ASM as a bounded semantic form in a named dialect. The default `.typeScript` dialect reads what @bsv/sdk 4.1.1 `fromASM` reads (its opcode names, `0`/`-1`, lowercase odd-length hex, `OP_PUSHDATA* <length> <hex>`) and writes its opcode names; where 4.1.1 `toASM` is not reversible (top-level OP_RETURN, zero-length pushes, empty input) it follows the two unmerged @bsv/sdk fixes (`OP_0` for empty pushes, a named OP_RETURN with a lenient, lossy tail, empty text as the empty script). BRC-106 names with compact BRC-14 SASM, and the Go map, remain selectable. Lowercase pushed-data hex, typed malformed/resource errors, and documented push normalization. | Raw bytes/hex remain the exact serialization. ASM written by Swift keeps its bytes in @bsv/sdk. Default ASM of a malformed OP_RETURN tail is lossy; `style: .canonical` is the strict form. Differential tests cover stable Go output; the TypeScript table is pinned against every `OP.ts` name and `Script.test.ts` vectors; Swift tests pin intentional safety differences. |
| COMP-023 | Go v1.3.3 exports `AnyOneCanPayForkID = 0xc0`, which combines two modifier bits but omits the required ALL/NONE/SINGLE base mode. | Swift signing accepts exactly `0x41`, `0x42`, `0x43`, `0xc1`, `0xc2`, and `0xc3`. The incomplete `0xc0` modifier constant is not a valid signature-hash type. | Prevents a default-to-ALL artifact from becoming an ambiguous public signing API. The oracle and Swift raw parser reject every undefined combination; all six valid combinations are differential-tested. |
| COMP-023 | Go v1.3.3 exports `AnyOneCanPayForkID = 0xc0`, which combines two modifier bits but omits the required ALL/NONE/SINGLE base mode. | Swift signing accepts exactly `0x41`, `0x42`, `0x43`, `0xc1`, `0xc2`, and `0xc3`. The incomplete `0xc0` modifier constant is not a valid signature-hash type. | Prevents a default-to-ALL artifact from becoming an ambiguous public signing API. The oracle and Swift raw parser reject every undefined combination; all six valid combinations are differential-tested. The interpreter validates Chronicle/OTDA signatures (COMP-064); signing stays ForkID-only. |
| COMP-024 | Go's fee model uses floating-point rounding, estimates compressed P2PKH unlocks at 106 bytes although non-low-R DER can require 107, can underflow paid fees, divides by zero without change, and exposes an unimplemented random mode. | Swift uses checked integer arithmetic and a safe 107-byte P2PKH maximum, reports overspending/overflow, treats no-change excess as intentional fee, and initially exposes only equal change distribution, giving the division remainder to the last change output as @bsv/sdk does. | Preserves valid Go results for identical explicit projections while preventing rare one-byte underfunding and making hostile/incomplete states typed and nontrapping. Differential tests cover actual and projected sizes; unit tests cover overflow, dust removal, no-change, underfunding, and atomic mutation. |
| COMP-025 | Go's BRC-74 parser truncates oversized block heights, accepts unknown/combined flag bits and trailing bytes, permits zero stored levels, and its implicit root selection uses the first hash rather than a marked transaction ID. | Swift requires a UInt32 block height, nonzero height of at most 64 (BRC-74; @bsv/sdk caps at 54 for JavaScript integers, which Swift does not copy), canonical CompactSize by default, full input consumption, and bounded counts. Flags are read as the bitmask Go and @bsv/sdk use: bit 0 is a duplicate, otherwise bit 1 marks a txid, and other bits are ignored. Like @bsv/sdk, nodes above level zero must be siblings of a level-zero hash's ancestors. `root()` prefers a level-zero `txid` marker, while `root(for:)` is the unambiguous verification API. Like pinned Go, single-level compound paths derive their effective height from the largest level-zero offset, and like @bsv/sdk a single-level path pairs the right-most node of each height with itself when it has no right neighbour. `verify` returns false for a coinbase (offset 0) less than 100 blocks below the tracker's current height, as @bsv/sdk does. | Canonical paths remain byte-compatible (a duplicate's txid bit is not kept: @bsv/sdk flags 3 is written back as 1) while malformed or ambiguous inputs fail predictably instead of truncating, ignoring data, or selecting the wrong proof target. Paths @bsv/sdk writes, including flags 3 and full-block single-level paths with an odd node count, parse and prove the same root. Unit tests cover every truncation, flag bits, limits, offset zero, duplicate markers, illegal upper-level offsets, explicit targets, coinbase maturity, the @bsv/sdk valid and invalid BUMP vectors, and pinned canonical Go differentials, including effective-height root computation. |
| COMP-026 | Go's BEEF readers accept noncanonical CompactSize values, treat any nonzero v1 BUMP-presence byte as true, can panic on an invalid BUMP index, do not require full input consumption, and the generic parser silently unwraps an Atomic BEEF prefix. Its map-backed representation also does not preserve transaction wire order as a public value contract. Pinned Go v1.3.3 does not propagate validity from an unproved txid-only parent to its raw child even when `allowTxidOnly` is true, and vacuously accepts an unproved zero-input raw transaction. | Swift preserves canonical BEEF v1/v2 and Atomic BEEF bytes, requires canonical CompactSize by default, accepts only defined format bytes, bounds every outer and nested count/size, rejects trailing data and invalid proof references, preserves parent-before-child wire order, and exposes `AtomicBEEF` separately so callers cannot accidentally discard the subject. Permissive CompactSize import is explicit. Per BRC-96, transaction-ID-only records become validation anchors only when the caller opts into that trust policy; unproved zero-input raw transactions do not. Atomic validation rejects unrelated transactions and wholly unrelated BUMPs, but permits combined BUMPs to carry additional same-block leaves when the proof supports at least one relevant ancestor. | Canonical SDK envelopes remain wire-compatible while malformed or ambiguous packages fail with typed errors rather than panicking or losing framing information. The BRC-96 validation semantics take precedence over the pinned Go propagation artifact. Combined BUMPs are normal Go output and must not make an otherwise atomic ancestry graph unreadable. Independently authored exact-byte tests cover both versions and Atomic framing; a pinned persistent Go oracle covers decoding, reverse-direction emission, proof-backed validation, transaction-ID-only policy, and the recorded dependent-child divergence. Script execution and chain-tracker root trust remain separate higher-layer verification steps. |
Expand Down Expand Up @@ -71,6 +71,7 @@ behind the general rule.
| COMP-061 | Pinned Go overlay HTTP and policy use unbounded response reads, unsafe binary counts and indexes, default trackers, unbounded fan-out, and scheduler-dependent result order. | Swift places bounded HTTPS facilitators in `BSVNetwork` and deterministic resolver and one-shot broadcaster policy in `BSVOverlay`. All hosts and limits are explicit, discovery verifies signed tokens, and failed submission has uncertain delivery. | Preserves canonical SHIP and SLAP requests and results without hidden network policy, unsafe retry, unbounded work, or nondeterministic aggregation. |
| COMP-062 | Pinned Go provides one concrete UHRP downloader with internal resolver, tracker, and HTTP policy. | Swift keeps UHRP values in `BSVStorage` and places the injected resolver and bounded HTTPS downloader in `BSVNetwork`. It authenticates the signed six-field TypeScript advertisement, binds it to the requested hash, sorts hosts, makes one GET per host, and verifies the SHA-256 result. | Preserves the TypeScript `ls_uhrp` query and advertisement layout without hidden trackers, cleartext hosts, unbounded bodies, automatic retry, or mutable network policy. |
| COMP-063 | BRC-157 composes BIP-39, BIP-32, and BRC-140 without storage, transport, or a concrete wallet implementation. Go and TypeScript expose the constituent behavior from their SDK packages. | Swift places the composed entropy-backup and hardened-profile API in opt-in `BSVCompat`, which already owns BIP-39 and BIP-32 and depends on `BSVKeys` for BRC-140. It remains outside the modern `BSV` umbrella. | Keeps the reusable backup primitive in the SDK while preserving the explicit compatibility boundary required by BIP-39 and BIP-32. Toolbox wallets may consume it without owning or duplicating the primitive. |
| COMP-064 | The interpreter was pinned to Go v1.3.3. TypeScript `@bsv/sdk` 4.1.1 and Go disagree with it on Chronicle splice operands, numeric shifts, the Chronicle number limit (32,000,000 bytes, not 32 MiB), `SIGHASH_CHRONICLE`, malleability relaxation for transaction version above 1, alt-stack clearing, signature and public-key checks, structural-only DER, and the bound on arithmetic results. | Swift follows SV Node v1.2.3 for all of them. It adds `ScriptVerificationFlags.chronicle`, implied by the `.afterChronicle` era, and the consensus failures `illegalChronicle` and `scriptNumberOverflow`. | Script validity is consensus, so the node decides. With `.enableForkID` a signature without the ForkID bit is rejected, and callers must pass `.chronicle` themselves for older outputs spent after Chronicle activation. Where Go differs, Swift no longer matches Go. `NodeConformanceRegressionTests` runs all 21 TypeScript node vectors and a test per rule. See [COMP-064](Rulings/COMP-064-Interpreter-Node-Chronicle-Rules.md). |

## Scope decisions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ for all six valid combinations are compared with the pinned Go SDK, and the
compressed P2PKH unlocking script is compared byte-for-byte. Unsupported future
digest flags require a new explicit API/ruling rather than being silently
accepted by this ForkID type.

Verification is separate. Under the Chronicle flag the interpreter accepts
and checks `SIGHASH_CHRONICLE` signatures with the original digest, as SV
Node does (COMP-064). This type still does not create them.
Loading
Loading