Implements gmser_asn1_rlp:encode/1 that accepts terms shaped according
to the GajumaruSerialization.asn model (e.g. GajumaruData with
templateFields or concrete CHOICEs like signedTx) and emits exactly
the same RLP bytes as the legacy gmserialization + gmser_rlp stack.
Purpose:
- Use ASN.1 as a formal, multi-language friendly schema and type model.
- Provide a thin, portable "production layer" that other languages can
implement (ASN.1-generated types + equivalent RLP emitter).
- Preserve the existing compact RLP wire format and on-the-wire
equivalence (no DER bloat for the legacy path).
The implementation walks the ASN.1-shaped value and applies the same
encoding rules as gmserialization:encode_field/2 (minimal unsigned
integers, positional values for static maps, etc.) followed by
gmser_rlp:encode/1.
Includes EUnit equivalence tests covering:
- Simple fields, zero/empty values
- Lists and tuples
- List-of-tuples (e.g. type_info)
- Concrete signedTx
- ContractV3 (including bool in structured data)
All tests assert byte-for-byte identity with legacy serialization and
that the resulting bytes are still accepted by legacy decoders.
This continues the proof-of-concept on the uw-asn1 branch.
This branch contains a proof-of-concept exploration of representing
the RLP (gmser_rlp) and gmserialization layers using ASN.1 with
DER encoding.
Goals of the experiment:
- Model the static serialization templates and dynamic types in ASN.1.
- Demonstrate reliable detection of legacy RLP data vs. new DER data
(first byte >= 0xC0 for RLP lists vs. 0x30 for DER SEQUENCE).
- Evaluate wire-size overhead of standard DER TLV encoding compared
to the extremely compact RLP prefix encoding.
- Verify that the DER path produces deterministic output suitable
for hashing (idempotent serialization).
Key files:
- GajumaruSerialization.asn -- the ASN.1 schema
- GajumaruSerialization.{erl,hrl} -- generated encoder/decoder
- detect_demo.erl, size_comparison.erl -- supporting test code
Findings (high level):
- Detection via first byte works cleanly.
- DER is fully deterministic for hashing when the same value is given.
- Small objects pay a significant size overhead (often 3-6x) due to
TLV tags/lengths and field names in the generic path.
- Concrete SEQUENCE definitions are much more compact than the
generic templateFields representation.
- Large payloads have acceptable relative overhead.
This is NOT production code. It was created to answer feasibility
questions around ASN.1 modeling, format detection, determinism,
and size characteristics.
Branch created from uw-new-acs for isolated experimentation.
Extended-auth account ids use an {account, Subtype} tag. These helpers
let callers test account membership and extract the 32-byte pubkey
without pattern-matching on specialize/1 results.