Add Zig reference implementation#32
Closed
vincenzopalazzo wants to merge 2 commits into
Closed
Conversation
Pure Zig implementation of the BOLT12 offer decoder with zero dependencies beyond the standard library. Ported from the TypeScript reference implementation (bolt12-utils). Modules: - bigsize: variable-length integer encoding per BOLT 1 - bech32: BOLT12 bech32 encoding/decoding (no checksum) - tlv: TLV stream parsing with ascending order validation - merkle: tagged hash merkle tree for offer_id computation - offer: semantic validation of offer TLV fields - bolt12: high-level decodeOffer API Includes 142 unit tests and integration tests against the official test vectors from offers-bolt-test.json. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Validate Zig implementation against all three official test suites: - offers-test.json: 53 vectors (20 valid + 33 invalid offers) - format-string-test.json: 12 vectors (bech32 format parsing, + continuation, case handling) - signature-test.json: 3 vectors (merkle tree leaf/branch/root hashes) Also fixes offer validation to perform full secp256k1 point-on-curve checks using std.crypto.ecc.Secp256k1, matching the TypeScript reference which uses @noble/curves. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
this need more work I open the PR in the wrong repo |
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.
Summary
std.crypto.hash.sha2)offers-bolt-test.jsontest vectorszig build run -- <bolt12-string>)Test plan
zig buildcompiles without errorszig build testpasses all 142 teststest-vectors/offers-bolt-test.jsonvalidated🤖 Generated with Claude Code