feat(rfid): add fdxb_encode — FDX-B (ISO 11784/11785) animal-microchip LF block generator#77
Merged
Conversation
…p LF block generator
The inverse of fdxb_decode (v0.464), extending the LF clone-generation set
(em4100_encode, ioprox_encode, noralsy_encode, viking_encode, jablotron_encode,
presco_encode) to the 134.2 kHz FDX-B animal/pet-microchip format. The decode
side shipped long ago but the synth side was the open half noted in the
gap-analysis LF-synth row; fdxb_encode produces the de-stuffed 10-byte ID+CRC
block an authorized operator would feed a transponder writer to clone a tag.
internal/fdxb.Encode is the exact inverse of Decode: the same LSB-first field
layout (38-bit national code at bit 0, 10-bit country at bit 38, the
data-block-status and animal-application flag bits at 48/49, reserved bits 50-63
zero) packed MSB-first into the 8-byte ID block, then the same Proxmark3 FDX-B
CRC-16 (CCITT poly 0x1021, init 0, output-reflected) appended LSB-first. The
on-air framing (11-bit preamble + the control '1' after every 8 bits) and the
24-bit vendor-specific extended block are out of scope, exactly as on the decode
side. Generation only — produces a block, transmits nothing and writes to no
device, so it is Low risk like the decoder.
Verification (the project's inverse-generator pattern): decode-of-encode
round-trips across six value sets — both of the decoder's real-tag anchors
(country 528 / national 140000795552 and country 999 / national 1500030037),
the 0/0 minimum, the 38-bit/10-bit maxima with both flags, and mid-range
values — each reproducing the national / country / flags with a valid CRC (the
shipped decoder is the independent oracle). Plus a published-vector anchor: the
identity bytes of the 528/140000795552 tag (national + country + flags, bytes
0..6) reproduce that real tag's ID block byte-for-byte as 05D94D19042100; the
real tag additionally carries a set reserved bit in byte 7 (bit 63, RFU range),
which the canonical encoder zeroes — asserted and documented. Out-of-range
national (>38 bits) and country (>10 bits, negative) are rejected.
Wired: internal/fdxb/{encode.go,encode_test.go}, internal/tools/fdxb_encode.go,
risk.go classification (Low, consistency test green), registry_size_test.go
680 -> 681 (count + comment), and the gap-analysis LF-synth row. gofmt /
go vet / golangci-lint (0 issues) / go test -race (fdxb, risk, tools) green.
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.
What
Adds
fdxb_encode, the inverse offdxb_decode(v0.464), extending the LF clone-generation set (em4100_encode,ioprox_encode,noralsy_encode,viking_encode,jablotron_encode,presco_encode) to the 134.2 kHz FDX-B animal/pet-microchip format. The decode side shipped long ago; the synth side was the open half noted in the gap-analysis LF-synth row. It produces the de-stuffed 10-byte ID+CRC block an authorized operator would feed a transponder writer to clone a tag.How
internal/fdxb.Encodeis the exact inverse ofDecode: the same LSB-first field layout (38-bit national @ bit 0, 10-bit country @ bit 38, data-block + animal flag bits @ 48/49, reserved 50-63 zero) packed MSB-first into the 8-byte ID block, then the same Proxmark3 FDX-B CRC-16 (CCITT0x1021, init 0, output-reflected) appended LSB-first. On-air framing and the 24-bit vendor extended block are out of scope, exactly as on decode. Generation only → Low risk.Verification (inverse-generator pattern)
decode∘encode round-trip across six value sets — both of the decoder's real-tag anchors (528/140000795552, 999/1500030037), the 0/0 minimum, the 38-bit/10-bit maxima + both flags, and mid-range — each reproducing national/country/flags with a valid CRC (the shipped decoder is the independent oracle).
published-vector anchor: the identity bytes of the 528/140000795552 tag (bytes 0..6) reproduce that real tag's ID block byte-for-byte as
05D94D19042100. The real tag also carries a set reserved bit in byte 7 (bit 63, RFU range), which the canonical encoder zeroes — asserted and documented.out-of-range national (>38 bits) / country (>10 bits, negative) rejected.
gofmt/go vetclean ·golangci-lint run ./...→ 0 issues ·go test -race ./internal/fdxb/ ./internal/risk/ ./internal/tools/→okregistry 680→681, risk-consistency + gated-set tests green; multi-param panic guard auto-covers it.
Wired
internal/fdxb/{encode.go,encode_test.go},internal/tools/fdxb_encode.go,risk.go(Low),registry_size_test.go(count + comment), gap-analysis LF-synth row.