BitLedger Protocol v3.0
40 Bits.
One Transaction.
A complete double-entry accounting record — both sides, full classification, direction, status, value, rounding metadata, and currency — in five bytes.
BitLedger is a binary-native financial record and transmission protocol designed from first principles at the binary representation of accounting states. Every bit position carries defined meaning. No layer ends with unused zero-padded bits. The rules of double-entry accounting are enforced at the encoding level — not as a rule the application must check, but as a structural property of the wire format.
The Core Record
Layer 3 — The 40-Bit Transaction
Five bytes. Every bit earns its position. The 25-bit value block carries any amount from zero to $33,554,431 at base precision — scaled arbitrarily via Layer 2. Seven flag bits qualify the value and provide three independent error-detection surfaces. Eight bits carry the complete double-entry accounting classification.
icand
cont.
end
der
cont.
end
Flag
Dir.
Order
↕
P/F
Credit
Present
Pair
cont.
end
=bit29
=bit30
-ness
Flag
25-Bit Value Block
Value Encoding — N = A × 2S + r
The 25-bit value block encodes any integer from 0 to 33,554,431 without gaps using the formula N = A × 2^S + r, where S is the Optimal Split from Layer 2 (default 8). At S=8: A occupies the upper 17 bits (0–131,071) and r occupies the lower 8 bits (0–255). The maximum N = 131,071 × 256 + 255 = 33,554,431.
Combined with Layer 2 Scaling Factor and Decimal Position:
Worked Examples
Bits 26–32
Flag Bits — Seven Qualifiers
Seven flag bits qualify the value block. Three pairs provide cross-layer error detection and accounting semantics. One invalid bit state (bit26=0, bit27=1) forms a third independent error detection layer.
Bits 33–36
Account Pair Table — All 16 Codes
A 4-bit field encoding both sides of the double-entry. Fourteen valid pairs cover all canonical accounting relationships. Code 1110 suspends inference for correction entries. Code 1111 is the compound continuation marker (only valid when compound mode is active in the session).
| Code | Account Pair | Direction In → Primary | Direction Out → Primary |
|---|---|---|---|
| 0000 | Op Expense / Asset | Expense receives goods or service | Expense reversal, return to supplier |
|
Typical use: Purchase of supplies, inventory receipt, service delivery.
── 0000 · Op Expense / Asset ─────────────────────
Account pair 0000
Bit 31 = 1 Debit: Op Expense
Bit 31 = 0 Credit: Asset (Cash or A/P)
Example Office supplies $240.00
Journal DR Office Supplies Exp 240.00 / CR Cash 240.00
─────────────────────────────────────────────────
|
|||
| 0001 | Op Expense / Liability | Expense incurred on credit | Liability reduces, expense reversed |
Typical use: Accrued expenses, payroll liabilities, taxes payable. ── 0001 · Op Expense / Liability ─────────────────
Example Payroll accrual $12,500.00
Journal DR Wages Expense 12,500 / CR Wages Payable 12,500
─────────────────────────────────────────────────
|
|||
| 0010 | Non-Op Expense / Asset | Non-core expense from asset | Non-core expense reversal |
Typical use: Interest expense paid from cash, one-time write-off.
|
|||
| 0011 | Non-Op Expense / Liability | Non-core expense on credit | Non-core liability reduces |
Typical use: Interest expense accrued but not yet paid.
|
|||
| 0100 | Op Income / Asset | Revenue received as asset | Revenue reversed, asset returned |
Typical use: Cash sale — revenue earned and cash received simultaneously. ── 0100 · Op Income / Asset ──────────────────────
Example Cash sale $850.00
Journal DR Cash 850.00 / CR Sales Revenue 850.00
─────────────────────────────────────────────────
|
|||
| 0101 | Op Income / Liability | Revenue earned, not yet received | Earned revenue reversed |
Typical use: Accounts receivable — service rendered, invoice issued, payment pending.
|
|||
| 0110 | Non-Op Income / Asset | One-time income received | One-time income reversed |
Typical use: Asset sale gain, investment return, insurance proceeds.
|
|||
| 0111 | Non-Op Income / Liability | One-time income earned on credit | Credit income reversed |
Typical use: Deferred income, subscription revenue not yet earned.
|
|||
| 1000 | Asset / Liability | Asset acquired on credit | Liability repaid from asset |
Typical use: Equipment purchase on credit, loan repayment. ── 1000 · Asset / Liability ──────────────────────
Example Equipment purchase $45,000 on credit
Journal DR Equipment 45,000 / CR Notes Payable 45,000
─────────────────────────────────────────────────
|
|||
| 1001 | Asset / Equity | Owner contributes asset | Asset distributed to owner |
Typical use: Owner capital contribution, dividend distribution.
|
|||
| 1010 | Liability / Equity | Equity converts to liability | Liability converts to equity |
Typical use: Convertible note conversion, debt-to-equity swap.
|
|||
| 1011 | Asset / Asset | Asset received — internal transfer | Asset disbursed — internal transfer |
Typical use: Cash-to-investment transfer, inter-account movement.
|
|||
| 1100 | Suspense / Clearing | Entry to suspense pending classification | Clearing suspense after classification |
Typical use: Unidentified receipts, in-transit items, pending reconciliation.
|
|||
| 1101 | Inter-Company | Inter-entity receivable | Inter-entity payable |
Typical use: Transactions between related entities, consolidation eliminations.
|
|||
| 1110 | Correction / Netting | Correction entry (inference suspended) | Netting entry |
Typical use: Error corrections, prior-period adjustments, netting arrangements. Account pair inference is suspended — the opposing account is explicit in an extension byte.
|
|||
| 1111 | Compound Continuation | Links this record to its predecessor as part of one logical multi-leg transaction. Only valid when compound mode is active in session (Layer 1 bit 11=1) and batch Compound Prefix ≠ 00. | |
See Compound Mode for full specification of continuation sub-types and completeness semantics.
|
|||
Batch Context
Layer 2 — Batch Header (48 bits / 6 bytes)
Transmitted once before each batch. Establishes the decoding context that every record in the batch inherits. No record repeats Layer 2 information. When all values match session defaults, a single control byte replaces the entire 48-bit header.
| Bits | Field | Values | Description |
|---|---|---|---|
| 1–2 | Transmission Type | 01–11 | 01=Pre-converted. 10=Copy from sender. 11=Represented entity. 00=protocol error. |
| 3–9 | Scaling Factor | 0–127 | Denomination multiplier. Index into powers of 10: 0=×1, 1=×10, 2=×100, 3=×1,000… |
| 10–13 | Optimal Split (S) | 0–15 | Bits allocated to Multiplier field. Default 8: 17-bit value + 8-bit quantity. Governs the N = A × 2^S + r formula. |
| 14–16 | Decimal Position | 000–111 | 000=integer, 001=1dp, 010=2dp (standard), 011=3dp, 100=4dp (forex), 101=5dp, 110=6dp (crypto), 111=extension byte. |
| 17 | Enquiry Bell | 0/1 | 1 = sender requests ACK of this batch before proceeding. |
| 18 | Acknowledge Bell | 0/1 | 1 = receiver confirms receipt of previous batch. |
| 19–22 | Group Separator | 4 bits | 15 group identifiers — accounting periods, quarters, organisational divisions. |
| 23–27 | Record Separator | 5 bits | 31 record-group identifiers. In compound mode: current value is the implicit compound group ID. |
| 28–30 | File Separator | 3 bits | 7 file identifiers — associates batches with logical file structures. |
| 31–35 | Entity ID | 00000–11111 | Sub-entity attribution. Matches Layer 1 Sub-Entity ID in standard mode; differs in represented-entity mode. |
| 36–41 | Currency Code | 000000–111111 | 64 codes. 000000=session default. 000001–011111=standard currencies. 100000–111110=user-defined. 111111=multi-currency. |
| 42–45 | Rounding Balance | 4-bit signed | Net rounding adjustment for batch (sign-magnitude). 0000=balanced. 1000=escape (see batch-close control record). |
| 46–47 | Compound Prefix | 00–11 | 00=no compound records. 01=up to 3 groups. 10=up to 7. 11=unlimited. Prepares receiver before first record. |
| 48 | Reserved | 1 | Always transmit as 1. Ensures final byte of Layer 2 is never all-zeros. |
Session Identity & Integrity
Layer 1 — Session Header (64 bits / 8 bytes)
Transmitted once at session open. Establishes sender identity, permissions, session-level defaults, and the CRC-15 checksum that protects all subsequent records. A corrupt session header would cause every record to be decoded against wrong identity or defaults — the CRC catches this at session open before any records are processed.
| Bits | Field | Description |
|---|---|---|
| 1 | SOH Marker | Always 1. Self-framing — the leading 1 triggers protocol state in the receiver. No preamble or sync byte required. |
| 2–4 | Protocol Version | 000–111. Receivers reject sessions with unsupported version codes. |
| 5–8 | Core Permissions | Bit 5: Read. Bit 6: Write. Bit 7: Correct/Amend. Bit 8: Represent third party. All four must be set appropriately before records are accepted. |
| 9–12 | Session Defaults | Bit 9: Split order default. Bit 10: Opposing account convention. Bit 11: Compound mode active. Bit 12: BitLedger block optional. |
| 13–44 | Sender ID | 32-bit unique sender identifier. Supports 4,294,967,295 distinct senders. Reducible to 16 bits on closed networks. |
| 45–49 | Sub-Entity ID | 31 sub-divisions per sender. In represented-entity mode, Layer 2 Entity ID intentionally differs from this field. |
| 50–64 | CRC-15 Checksum | Computed over bits 1–49. Polynomial x^15 + x + 1 (0x8003). Zero remainder = session accepted. Non-zero = session rejected, NACK sent. |
CRC-15 Algorithm
The Invariant
Conservation — The Batch Balance Check
For every batch, the signed sum of all flows must equal zero. This is the binary wire-level expression of double-entry accounting's fundamental rule — identical in algebra to Kirchhoff's current law applied to any node. The protocol checks this before the application sees the records.
A CRC-15 catches bit-level corruption. Cross-layer validation (bit29=bit37, bit30=bit38) catches field corruption. The conservation invariant catches something neither can: phantom flows, missing records, duplicated records — logical errors that leave every individual record intact but violate the double-entry balance. Three independent detection layers, zero overhead fields.
Session Management
Control Records (1 byte)
8-bit control records handle session events without inflating the record stream. Type codes 000–111 cover all standard session management events. A control record is always 1 byte.
| Type | Name | Purpose |
|---|---|---|
| 000 | Session Open | Opens a new session context. Triggers Layer 1 header transmission. |
Signals the receiver to prepare for a Layer 1 session header. Self-framing via the SOH marker in Layer 1 bit 1. | ||
| 001 | Session Close | Terminates the current session. Receiver finalises conservation check. |
Triggers final batch balance validation. Any open compound groups are marked incomplete. Session state cleared. | ||
| 010 | Batch Open | Opens a new batch. Layer 2 header follows. |
Receiver prepares to receive a 48-bit Layer 2 batch header. Rounding balance resets to zero for the new batch. | ||
| 011 | Batch Close | Closes the current batch. Conservation check runs. |
The batch balance sum is verified. If rounding balance exceeded the 4-bit escape (1000), the batch-close payload carries the full rounding value. | ||
| 100 | ACK | Positive acknowledgement of the previous batch or record. |
Response to an Enquiry Bell (Layer 2 bit 17). Sender may proceed with next batch. A two-byte verified handshake when combined with Echo. | ||
| 101 | NAK / Parameter Update | Negative acknowledgement or mid-batch parameter update. |
When used as NAK: requests retransmission of the rejected batch. When used as parameter update: the following byte specifies which parameter changes (e.g. Optimal Split for a record group). | ||
| 110 | Status | Transmits receiver status without a full record. |
Used for liveness, error reporting, and mode signalling. A 1-byte status control carrying the status code in the lower 5 bits. | ||
| 111 | Custom / Extension | User-defined or future-protocol control. Extension byte follows. |
Reserved for application-layer extensions and future protocol versions. The following byte declares the custom control type. | ||
Why It Matters
Efficiency — Structural, Not Compressive
The reduction in wire bytes is structural. No decompression. No schema lookup. The decoder reads fixed bit positions and the record is decoded. On a link measured in bits per second — a satellite uplink, an industrial serial bus, a narrowband IoT radio — this matters at a level verbose formats cannot match.
| Format | 100 Transactions | Relative Size | Notes |
|---|---|---|---|
| BitLedger v3 | 514 bytes | 1× | Layer 1 + Layer 2 + 100 × 5B. No decompression. |
| Fixed binary (ISO 8583-style) | ~3,000 bytes | 5.8× | No session CRC, no conservation invariant, no double-entry semantics. |
| CSV fixed-width (ACH-style) | ~15,000 bytes | 29× | Text encoding, no per-record integrity, batch settlement only. |
| JSON | ~80,000 bytes | 155× | Schema-dependent, string parsing required, no integrity mechanism. |
| ISO 20022 XML | ~200,000 bytes | 389× | Standards-compliant but requires full XML parser. Designed for nightly settlement, not real-time low-bandwidth links. |