BP BitPads Protocol

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.

Layer 1
Session Header
8 bytes
Sender ID · permissions · CRC-15 · session defaults. Once per session.
Layer 2
Batch Header
6 bytes
Currency · scaling · precision · rounding balance. Once per batch.
Layer 3
Transaction Record
5 bytes
Value block (25 bits) · flag bits (7) · accounting block (8). Per transaction.
Control
Control Record
1 byte
ACK · batch close · band change · session events. On demand.
100 transactions. Layer 1 (64 bits) + Layer 2 (48 bits) + 100 × Layer 3 (40 bits) = 4,112 bits — 514 bytes. A comparable JSON representation: 50,000–200,000 bytes. The reduction is structural, not compressive. No decompression step.

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.

BITS 1–25 (VALUE BLOCK)  ·  BITS 26–32 (FLAGS)  ·  BITS 33–40 (ACCOUNTING)
Bits 1–25 — Value Block (25 bits)
1AMult-
icand
···AA
cont.
17AA
end
18rRemain-
der
···rr
cont.
25rr
end
Bits 26–32 — Flag Bits (7 bits)
26RndRound
Flag
27DirRound
Dir.
28SplSplit
Order
29+/-Direction
30P/FStatus
P/F
31D/CDebit/
Credit
32QtyQty
Present
Bits 33–40 — Accounting Block (8 bits)
Value block Flag bits Accounting block bit29 = bit37  ·  bit30 = bit38  ·  cross-layer validation

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.

N = A × 2S + r  ·  A = ⌊N / 2S⌋  ·  r = N mod 2S

Combined with Layer 2 Scaling Factor and Decimal Position:

Real Value = (N × Scaling Factor) / 10Decimal Position

Worked Examples

── EXAMPLE 1 ─ $4.53 exact flat value ─────────────────────
Layer 2 SF=×1, DP=2 (step $0.01)
Target $4.53 → V = 453 (integer)
Encode A = ⌊453/256⌋ = 1   r = 453 mod 256 = 197
Bits 1-1700000000000000001 (A=1)
Bits18-2511000101 (r=197)
Bit 26 0 = exact (no rounding)
Decode N = 1×256+197 = 453 → $4.53
─────────────────────────────────────────────────────────────
── EXAMPLE 2 ─ $98,765.43 large value ──────────────────────
Layer 2 SF=×1, DP=2
Target $98,765.43 → V = 9,876,543
Check 9,876,543 ≤ 33,554,431 ✓
Encode A = ⌊9,876,543/256⌋ = 38,580   r = 63
Decode N = 38,580×256+63 = 9,876,543 → $98,765.43
─────────────────────────────────────────────────────────────
── EXAMPLE 3 ─ 24 units at $2.49 each (quantity split) ─────
Layer 2 SF=×1, DP=2, Optimal Split S=8
Bit 32 1 = Quantity Present
Encode A = 249 (price in cents)   r = 24 (quantity)
Decode N = 249×24 = 5,976 → $59.76
─────────────────────────────────────────────────────────────
── EXAMPLE 4 ─ $2,450,000.00 large corporate ───────────────
Layer 2 SF=×100, DP=2 (step=$1.00, max=$33,554,431)
Encode N = 2,450,000 / 100 = 24,500
A = ⌊24,500/256⌋ = 95   r = 180
Decode N = 95×256+180 = 24,500 → 24,500×100/100 = $2,450,000.00
─────────────────────────────────────────────────────────────
── EXAMPLE 5 ─ $1,847,293,651.37 via compound continuation ─
Strategy Split across 2 records — compound mode
Record 1: billions component
Layer 2 SF=×100,000, DP=2 (step=$1,000)
Encode $1,847,293,000 / 1,000 = 1,847,293
Bit 39 1 = partial, continuation follows
Record 2: sub-thousand component (1111 continuation)
Layer 2 SF=×1, DP=2
Encode $651.37 → N = 65,137
Bit 39 0 = complete, compound closed
Sum $1,847,293,000.00 + $651.37 = $1,847,293,651.37 exact
─────────────────────────────────────────────────────────────
Value Encoder — N = A × 2S + r

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.

Bit
Field
Description
26
Rounding Flag
0 = exact value, no precision loss. 1 = value is rounded — bit 27 carries direction. Encoder must set this whenever rounding occurs.
27
Rounding Direction
Only valid when bit 26=1. 0 = rounded down (floor). 1 = rounded up (ceiling). State 01 (bit26=0, bit27=1) is a protocol error — immediately detectable.
28
Split Order
0 = follow session default (Layer 1 bit 9). 1 = reverse session default for this record only. No separate setup byte required.
29
Direction ±
0 = Plus / In — value received. 1 = Minus / Out — value disbursed. MUST = bit 37 Cross-layer validation rule 1. Mismatch → record rejected.
30
Status P/F
0 = Past / Paid — settled, cash basis. 1 = Future / Debt — accrued, not yet settled. MUST = bit 38 Cross-layer validation rule 2.
31
Debit / Credit
0 = Credit side primary. 1 = Debit side primary. Resolves which account in the pair takes the debit.
32
Quantity Present
0 = all 25 bits are a flat total. 1 = Optimal Split active — upper bits = price/unit, lower bits = quantity. When 1, split always taken from Layer 2.
Cross-layer validation: bit 29 must equal bit 37, and bit 30 must equal bit 38. A single-bit corruption in either location is immediately detectable. Three independent error surfaces operate on every 40-bit record with no dedicated checksum field.

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.

BitsFieldValuesDescription
1–2Transmission Type01–1101=Pre-converted. 10=Copy from sender. 11=Represented entity. 00=protocol error.
3–9Scaling Factor0–127Denomination multiplier. Index into powers of 10: 0=×1, 1=×10, 2=×100, 3=×1,000…
10–13Optimal Split (S)0–15Bits allocated to Multiplier field. Default 8: 17-bit value + 8-bit quantity. Governs the N = A × 2^S + r formula.
14–16Decimal Position000–111000=integer, 001=1dp, 010=2dp (standard), 011=3dp, 100=4dp (forex), 101=5dp, 110=6dp (crypto), 111=extension byte.
17Enquiry Bell0/11 = sender requests ACK of this batch before proceeding.
18Acknowledge Bell0/11 = receiver confirms receipt of previous batch.
19–22Group Separator4 bits15 group identifiers — accounting periods, quarters, organisational divisions.
23–27Record Separator5 bits31 record-group identifiers. In compound mode: current value is the implicit compound group ID.
28–30File Separator3 bits7 file identifiers — associates batches with logical file structures.
31–35Entity ID00000–11111Sub-entity attribution. Matches Layer 1 Sub-Entity ID in standard mode; differs in represented-entity mode.
36–41Currency Code000000–11111164 codes. 000000=session default. 000001–011111=standard currencies. 100000–111110=user-defined. 111111=multi-currency.
42–45Rounding Balance4-bit signedNet rounding adjustment for batch (sign-magnitude). 0000=balanced. 1000=escape (see batch-close control record).
46–47Compound Prefix00–1100=no compound records. 01=up to 3 groups. 10=up to 7. 11=unlimited. Prepares receiver before first record.
48Reserved1Always 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.

BitsFieldDescription
1SOH MarkerAlways 1. Self-framing — the leading 1 triggers protocol state in the receiver. No preamble or sync byte required.
2–4Protocol Version000–111. Receivers reject sessions with unsupported version codes.
5–8Core PermissionsBit 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–12Session DefaultsBit 9: Split order default. Bit 10: Opposing account convention. Bit 11: Compound mode active. Bit 12: BitLedger block optional.
13–44Sender ID32-bit unique sender identifier. Supports 4,294,967,295 distinct senders. Reducible to 16 bits on closed networks.
45–49Sub-Entity ID31 sub-divisions per sender. In represented-entity mode, Layer 2 Entity ID intentionally differs from this field.
50–64CRC-15 ChecksumComputed over bits 1–49. Polynomial x^15 + x + 1 (0x8003). Zero remainder = session accepted. Non-zero = session rejected, NACK sent.

CRC-15 Algorithm

── CRC-15 ENCODER ────────────────────────────────────────
Polynomial G = x^15 + x + 1 = 0x8003
Input P = bits 1–49 of Layer 1 (49-bit payload)
Step 1 Append 15 zero bits: W = P[1..49] + 000000000000000
Step 2 For each bit i from 1 to 49:
if leading bit of W == 1: W = W XOR (G << align)
shift W left by 1
Step 3 Remainder R = final 15 bits of W
Step 4 Transmit bits 1–49 followed by R (total 64 bits)
── CRC-15 DECODER ────────────────────────────────────────
Step 1 Run CRC-15 over all 64 received bits
Step 2 Result == 0x0000 → session accepted
Result != 0x0000 → send NACK, reject session
Coverage 100% single-bit · 100% burst ≤15 bits · 99.997% other
─────────────────────────────────────────────────────────

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.

CONSERVATION INVARIANT
batch_balance = 0
for each record in batch:
if bit29 == 0 (Plus/In): batch_balance += signed_value
if bit29 == 1 (Minus/Out): batch_balance -= signed_value
if batch_balance != 0:
BATCH INVALID → reject, NACK, request retransmission

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.

Kirchhoff's current law: the sum of currents at any node equals zero. Structurally identical to double-entry balance. The same algebra governs financial accounting, electrical current distribution, mass balance in chemical reactors, and propellant conservation in spacecraft. BitLedger's Universal Domain recognises this — switching the domain bits changes the semantic interpretation, not the invariant.

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.

TypeNamePurpose
000Session OpenOpens 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.
001Session CloseTerminates the current session. Receiver finalises conservation check.
Triggers final batch balance validation. Any open compound groups are marked incomplete. Session state cleared.
010Batch OpenOpens 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.
011Batch CloseCloses 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.
100ACKPositive 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.
101NAK / Parameter UpdateNegative 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).
110StatusTransmits 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.
111Custom / 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.

Format100 TransactionsRelative SizeNotes
BitLedger v3514 bytesLayer 1 + Layer 2 + 100 × 5B. No decompression.
Fixed binary (ISO 8583-style)~3,000 bytes5.8×No session CRC, no conservation invariant, no double-entry semantics.
CSV fixed-width (ACH-style)~15,000 bytes29×Text encoding, no per-record integrity, batch settlement only.
JSON~80,000 bytes155×Schema-dependent, string parsing required, no integrity mechanism.
ISO 20022 XML~200,000 bytes389×Standards-compliant but requires full XML parser. Designed for nightly settlement, not real-time low-bandwidth links.
40
bits per transaction
3
independent error surfaces
4.29B
max sender IDs
$33.5Q
max value per record