{"slug": "bitcoin-i-m-retarded-asm-client-server-project-in-the-works", "title": "Bitcoin: I'm retarded. ASM client/server project in the works", "summary": "A Bitcoin node for Linux built entirely from AI-generated x86-64 assembly code is under active development, with all security-critical crypto (SHA-256, secp256k1, ECDSA) hand-written in assembly by an AI. The project has passed internal AI-driven security review and multiple test vectors, but has not been audited by any independent human reviewer, and the developers warn it is untrusted and dangerous, not to be run with real funds or on production machines.", "body_md": "This is actively developed, highly experimental software.It implements Bitcoin node functionality as hand-rolled x86-64 assembly produced by an AI. It has NOT been audited by any independent human reviewer. The project has gone through multiple rounds of AI-driven security review (see`validation/SECURITY_AUDIT.md`\n\n), and issues found that way get fixed as they come up — but that internal process is not a substitute for independent human sign-off, and no such review has happened yet.You should treat this code as untrusted and dangerous.A bug in consensus, cryptographic, or networking logic can cause loss of funds, chain divergence, resource exhaustion, or exposure of your machine to the network. Donotrun it with real funds, on a production machine, or on an internet-exposed host, and do not rely on it for any security-sensitive purpose — until it has undergone an independent human security audit. Use at your own risk.\n\nA Bitcoin node for Linux built as **100% AI-generated machine code** — every line of\nassembly is authored by an AI assistant, none by a human. The security-critical\ncrypto (SHA-256, secp256k1 field/point/scalar/ECDSA) is written directly in x86-64\nassembly.\n\n**Delivered and verified:**\n\n**SHA-256 core**(`asm/sha256.asm`\n\n) — passes the canonical FIPS-180-4 vectors plus the multi-block and extra-length-block padding cases Bitcoin requires.**secp256k1 field arithmetic**(`asm/secp256k1_fe.asm`\n\n) —`fe_add`\n\n,`fe_sub`\n\n,`fe_mul`\n\n(256-bit multiply + secp256k1-prime reduction), verified against 24 fixed vectors and 50,000+ random cases vs Python's big-int oracle.**secp256k1 point / scalar / ECDSA**(`asm/secp256k1_point.asm`\n\n,`asm/secp256k1_scalar.asm`\n\n,`asm/secp256k1_ecdsa.asm`\n\n) — Jacobian point ops, scalar arithmetic mod n, and low-S ECDSA signature verification, all verified against a Python big-int oracle.**Node-layer hashing**(`asm/bitcoin_hash.asm`\n\n) —`sha256d`\n\n,`block_hash`\n\n,`diff_target`\n\n,`pow_check`\n\n, and`merkle_root`\n\n, verified against the genesis block, fixed vectors, and a Python oracle (10/10 assertions in`test_block`\n\n).**Node-layer tx parser**(`asm/bitcoin_tx.asm`\n\n) —`tx_parse`\n\ndeserializes a transaction (version, varint counts, inputs, outputs, locktime) and ALSO skips the SegWit (BIP141) witness stack, so it walks both legacy and modern on-wire txs and returns the full serialized length.`tx_txid(out32, tx, txlen, buf, buflen)`\n\nrebuilds the unwitnessed form and returns the BIP141 txid. Verified against the serialized genesis coinbase (18/18 in`test_tx`\n\n), cross-checked against a clean Python walker, and validated on REAL mainnet blocks: the community`cons_verify`\n\naccepts both pre-SegWit block 400000 and SegWit-era block 962043.**P2P networking core**(`asm/bitcoin_net.asm`\n\n) — raw-syscall POSIX sockets plus the Bitcoin message framer (magic + command + length + SHA-256d checksum). Verified offline (19/19 assertions in`test_net`\n\n) and against a**live Bitcoin peer**(version/verack handshake succeeded,`live_handshake.c`\n\n).**P2P message codecs**(`asm/bitcoin_p2p.asm`\n\n) — getheaders / getdata / ping builders and a headers parser, byte-exact vs`validation/p2p_oracle.py`\n\n; the whole IBD header-download path is proven end-to-end as machine code (`test_p2p`\n\noffline +`fakepeer_headers`\n\nloopback IBD test).**Block consensus**(`asm/bitcoin_cons.asm`\n\n) —`cons_verify`\n\nvalidates a full block in machine code: PoW + per-tx parsing + coinbase-first + merkle-root recheck over the txids. Verified against a Python-built 2-tx block (`test_cons`\n\n, 6/6): valid accepted (root matches the oracle), and bad merkle / trailing garbage / truncation / non-coinbase / over-cap all rejected.**Persistent header chain**(`asm/bitcoin_headers.asm`\n\n) — a restart-safe, positional append-only store of`(80-byte header, block_hash)`\n\npairs (`headers.dat`\n\n, 112 B/entry).`hst_init/reload/append/get_at/count`\n\nverified by`test_headers`\n\n(on-disk layout, reload resume, chain continuity).**Paged headers-first IBD**(`asm/bitcoind.asm`\n\n`node_ibd_headers`\n\n) — the persistent download loop: repeatedly fetch a 2000-header`headers`\n\npage at the running locator, verify chain continuity for every header, compute each block_hash, persist it, and advance the locator to the new tip; stops on a short/empty page. Verified by`test_ibd_headers`\n\nover a real loopback socket: a 2500-header chain (full page + short page), locator advance to tip, restart-resume, tip detection, and rejection of a tampered chain.**Block-body download off the persisted header chain**(`asm/bitcoind.asm`\n\n`node_ibd_blocks`\n\n) — the second half of full IBD: walks every stored header in the header store, requests its block via getdata, validates it (PoW + merkle + tx walk via`cons_verify`\n\n), re-derives the block hash and requires it to equal the stored header hash (wrong-block guard), and persists it. Verified by`test_ibd_blocks`\n\nover loopback (4-block chain stored byte-exact, plus a negative case rejecting a peer that serves the wrong body).**Full initial-block-download as one assembly pass**(`asm/bitcoind.asm`\n\n`node_ibd`\n\n) — chains`node_ibd_headers`\n\n(persist the whole header chain from genesis in 2000-header pages) then`node_ibd_blocks`\n\n(walk every stored header -> getdata ->`cons_verify`\n\n+ re-derived-hash guard -> store) over a single peer connection. Verified by`test_ibd_full`\n\nover a real loopback socket: a 1200-block chain downloaded, validated and stored byte-exact in one call — the entire headers-first IBD tail as machine code.**Node CLI**(`asm/bitcoin_cli.asm`\n\n) —`cli_main`\n\nanswers queries in pure machine code over the persistent store:`getblockcount`\n\n,`getbestblockhash`\n\n,`getblockhash <h>`\n\n,`getblock <h|hash64>`\n\n,`gettx <txid64>`\n\n,`getbalance`\n\n,`stop`\n\n,`help`\n\n(hashes in Bitcoin display order). Thin driver`daemon/cli.c`\n\n; verified by`test_cli`\n\n(all commands against expected values from the proven asm hashes). The assembly hashing/tx stack also reproduces the real genesis block hash + coinbase txid (test_block/test_tx) and a live-downloaded real mainnet block-1 hash (manual`test/live_blocks.c`\n\n).**Optional CUDA batch-acceleration tier**(`asm/cuda/`\n\n) — an explicit, runtime-gated accelerator for batched SHA-256 / SHA-256d (Bitcoin's double hash), matching the CPUID/SHA-NI design philosophy but with a*device probe*. A single dispatcher (`bmc_sha256d_batch`\n\n) auto-detects a usable GPU at runtime and uses CUDA only when a device is present AND the batch is large enough to amortize launch/copy (>=512) AND not disabled (`BMC_CUDA=0`\n\n); on any CUDA error, no device, or a small batch it falls back bit-exact to the proven assembly`sha256d`\n\n. Correctness is the priority: the CUDA digest must equal the asm oracle byte-for-byte. Verified against the asm oracle over the FIPS vectors, all Bitcoin padding edges, and 10,000 random messages (0 failures); routing/digests verified in every mode (default->CUDA, disabled/small/no-GPU ->CPU fallback). Measured ~17-18x GPU/CPU wall-clock at N=1,000,000 on an RTX 5090 (CPU wins below ~100). Building the kernels needs nvcc + CUDA GPU; the dispatcher itself links and runs with zero CUDA installed (falls back to CPU). Not yet wired into bitcoind/bitcoin_cli — see WORKING.md for the roadmap.\n\nAll assembly is authored by AI; C/Python harnesses exist only to prove the\nmachine code is correct against trusted references. Real-mainnet validation\nstatus: the full asm consensus stack accepts the REAL genesis block (285 byte\nheader + tx-count + coinbase, real nBits 0x1d00ffff, real merkle root) via\ntest_block_genesis (offline, in make test); pow_check/diff_target implement the\nreal Bitcoin difficulty algorithm and are proven against real mainnet nBits;\nand the node reproduces a live-downloaded real block-1 hash. **The block-body\ndownload + store tail is now exercised end to end against a REAL node: real\nmainnet block bodies are downloaded, cons_verify-validated as VALID, and\nstored** — block bodies come from a large pool of verified **internet** peers\nvia distinct-peer selection, discovered entirely through the node's own DNS-seed\nbootstrap (no cooperative/local test peer involved). The\nlong-standing \"seeds drop block-body getdata\" wall was root-caused to our own\nmalformed getdata: `p2p_getdata_block`\n\nemitted a 34-byte message (type as a 1-byte varint) that real nodes silently\nignore. The canonical Bitcoin getdata/inv inventory is `[count varint][type int32 LE][hash32]`\n\n= 37 bytes with the hash at +5 (the p2p_oracle always encoded this;\na prior stage wrongly \"fixed\" it -- corrected and confirmed live). Public seeds\nstill serve the real header chain reliably; with the corrected getdata they also\nserve block bodies to a cooperative/unchained peer. The inbound (server) role is\nnow real too: a new asm `node_accept_handshake`\n\nanswers a genuine inbound node's\n`version`\n\nand serves stored blocks (verified end to end), where the old serve\npath reused the outbound handshake and hung on an inbound peer.\n\n**ASM inbound server serves the REAL chain over TCP — getdata AND getheaders**\n(from commit `32279a0`\n\n): `bitcoind serve <dir> <port>`\n\nanswers a peer entirely\nin assembly (`node_accept_handshake`\n\n-> `node_serve_loop`\n\n) against the on-disk\narchive. Verified LIVE over loopback against real mainnet data:\n\n**getdata**— a real block by hash served verbatim (height-1 215 B, height-2 215 B, height-50000 647 B, plus multi-KB blocks at h=100k/200k),`requested-hash-match=YES`\n\n.**getheaders**— a*canonical*`headers`\n\nmessage whose CompactSize count equals the payload length, whose headers form a contiguous chain (each header's prev is the double-SHA256 of the previous header), starting from the requested locator (verified for locators at h=1, h=200000, h=293300, 2000 headers each). The server stays alive after serving.\n\n**BIP152 compact blocks** (`asm/bitcoin_cmpct.asm`\n\n, serve integration in\n`asm/bitcoin_serve.asm`\n\n): SipHash-2-4 short-tx-ids and the compact-block wire\ncodecs (`sendcmpct`\n\nnegotiation incl. high-bandwidth, `cmpctblock`\n\nbuild/serve,\n`getblocktxn`\n\n/`blocktxn`\n\n). Verified byte-exact against REAL Bitcoin Core v31.99:\nshort-ids captured from Core's actual wire `cmpctblock`\n\nmessages over loopback\n(`validation/bip152_vectors.h`\n\n, 12 vectors; `tests/test_bip152`\n\n35 checks) and a\nloopback e2e over the asm server (`tests/test_bip152_loop`\n\n, 16 checks).\n\nThe live work exposed and fixed five real bugs that fake-block unit tests could\nnot catch: (1) the daemon had no Makefile target (ad-hoc stale command);\n(2) `server-test`\n\nnever built the hash index, so getdata couldn't resolve a\nhash; (3) `build_hash_index`\n\nkeyed on display (BE) order while the wire hash is\nLE, so getdata missed; (4) the getheaders dispatch checked `cmd[4]/[8]`\n\nfor\n`\"head\"/\"ers\"`\n\nbut getheaders is `g e t h e a d e r s`\n\n(\"head\" is at cmd[3..6])\nso it never fired; (5) `open_file`\n\nleaked an fd per serve (`EMFILE`\n\nat ~1024\nserves truncated the chain) — fixed with close-before-open, so serving spans\nheights 0..309998. **The crash** was the getheaders header copy passing the\nlength in `r8`\n\nwhile `memcpy_len`\n\nreads its length from `RDX`\n\n(verified by\ndisassembly): it copied `[s_p]`\n\nbytes instead of 80, sweeping through `.bss`\n\ninto the relocated `stdout`\n\n/`stderr`\n\ncopies (0x143e6a0) and segfaulting `main`\n\n's\nprintf. Found with a hardware write watchpoint on the stdout slot; fixed by\nloading the length into `RDX`\n\n. The test suite stays 33/33 green throughout.\n\n**Built-in multi-peer catch-up ( bitcoind serve, no external tooling needed):**\nthe daemon now self-heals on its own —\n\n`main.c`\n\n's `dl_catchup`\n\nruns\nsynchronously at boot, before the node ever opens for service: it discovers\npeers via the existing DNS-seed bootstrap (`dl_bootstrap`\n\n/`dl_pool_from_book`\n\n,\nthe same discovery `serve_download_worker`\n\nalready used), extends\n`headers.dat`\n\nincrementally to the real chain tip, computes the current archive\ngap directly from `index.dat`\n\n(any hole below the stored tip, plus everything\nmissing up to the real tip, as ONE combined span), and forks `>=8`\n\nchunk-claiming\nworker processes to fill it. Workers pull 200-block chunks from a shared\n`mmap`\n\n'd atomic counter (work-stealing — a worker that lands fast peers just\nkeeps claiming more chunks instead of idling on a static pre-split share),\nskip any chunk that's already fully archived (so the same span safely covers\nboth real gaps and already-filled heights in one pass), and reuse a persistent\npeer connection across chunks instead of reconnecting per chunk. Peer liveness\nis checked via a bounded non-blocking-connect probe (several rounds, never a\nblind blocking connect to an unconfirmed host — that has no connect-phase\ntimeout and can hang for minutes on a black-holed peer). Self-throttling: a\nnode that's already caught up returns from `dl_catchup`\n\nalmost instantly (pure\ndisk reads, no network), so it's safe to run unconditionally on every boot.**Standalone bulk-download tool ( daemon/unified_ibd.c):** the same\nchunk-claiming/work-stealing engine as a manual ops tool, useful for a very\nlarge initial catch-up or offline reindexing outside the daemon's own\nboot path. Every block is written\n\n**directly into the single archive** in\n\n`data/`\n\nvia the concurrent-safe asm `store_append_shared`\n\n: each append is\nflock-serialized on `append.lock`\n\n(each worker opens its own fd — `flock()`\n\nlocks belong to the open file description, so a fork-inherited fd would not\nactually exclude sibling workers from each other), the block lands at the true\nfile end of the rolling `blkNNNNN.dat`\n\n, and the index record goes positionally\nat `height*48`\n\n(index.dat pre-sized, grow-only). No per-worker block\ndirectories exist — the archive is one directory holding only\n`blk00000.dat`\n\n..`blkNNNNN.dat`\n\n, `index.dat`\n\n, `headers.dat`\n\n. Peer distinctness\nis guaranteed via a flock-locked `peerclaims`\n\ntable, with a deep peer pool\n(all of `good_internet_peers.txt`\n\n, not just a small prefix) and a live-retry\nfallback for peers that looked down at the one-time startup probe. Driver\nscripts: `hole_ranges.py`\n\n(finds gaps in `index.dat`\n\n), `backfill_holes.sh`\n\n(one combined-span `unified_ibd`\n\ncall over them), `sync_chain.sh`\n\n(chains\nhole-fill into extending to the real tip). Real-mainnet header-continuity bug\nfound and fixed (see LOG #12).**Wallet / validation bridge (complete)** — the node now validates and signs real\ntransactions in machine code, on top of the verified asm crypto. All of this was\nbuilt as part of the same AI-authored assembly / C-verified work as the node:\n\n**secp256k1 pubkey parse**(`asm/bitcoin_pubkey.asm`\n\n) —`fe_pow`\n\n+`pubkey_parse`\n\n: recover affine curve coords (Qx,Qy) from a compressed (02/03) or uncompressed (04) secp256k1 public key. Verified on G, non-residue rejection, bad length, off-curve.**Legacy SIGHASH_ALL preimage builder**(`asm/bitcoin_sighash.asm`\n\n) — builds the unsigned-tx preimage for a target input, verified byte-exact vs Python on 1-in/1-out and 2-in/1-out txs.**DER ECDSA sig parsing**(`asm/bitcoin_script.asm`\n\n) —`der_parse_sig`\n\n(canonical DER sig -> r,s LE limbs via`be_to_limbs`\n\n+ trailing SIGHASH type byte), verified against a real`cryptography`\n\n-generated DER sig.**End-to-end P2PKH spend validation**(`bitcoin_script.asm`\n\n`verify_p2pkh`\n\n) — validates one P2PKH input in assembly: build SIGHASH_ALL, walk the scriptSig, DER-parse the sig, parse the pubkey,`ecdsa_verify`\n\n. Valid spend -> 1, tampered sig -> 0 (the`validation CAPSTONE`\n\n).**UTXO set**(`asm/bitcoin_utxo.asm`\n\n) — in-memory Unspent-Transaction-Output store: txid(32)+index(u32) -> (value, scriptPubKey) open-addressing table + value/script blob.`utxo_init/put/get/del/count`\n\n. Verified: put/get round-trip, dedup, distinct outpoints, spend/delete -> miss and double-spend -> miss, and a 300-entry probing/collision-wrap bulk round-trip.**Whole-transaction validator**(`tests/test_txval.c`\n\n) — validates a full serialized tx against the UTXO set: every input outpoint present+unspent (double-spend guard), every input's P2PKH signature verifies via asm`verify_p2pkh`\n\n, and sum(in) >= sum(out) (valid fee). Signed vectors are genuine ECDSA spends (gen_txval_vectors.py). 6 cases: 2 valid multi-input txs + double-spend / fee / sig(empty) / sig(wrong-key) negatives. Suite 40/40.**Policy + RBF / fee handling**(`asm/bitcoin_mempool_policy.c`\n\n) — policy layer over the structural mempool + UTXO set: fee computation + min-relay-fee floor, double-spend rejection, BIP125 RBF (replacement fee math + eviction), ancestor/ descendant limits, and an EMA fee estimator. Verified against an independent pure-Python oracle (4 scenarios / 21 steps). Full offline suite 35/35 green.**Wallet CLI**(`asm/wallet_core.c`\n\n+`asm/daemon/wallet_cli.c`\n\n) —`wallet_cli gen`\n\n(random keypair + P2PKH mainnet address),`addr <keyhex>`\n\n(compressed pubkey + address), and`sign <tx><key><i>`\n\n(legacy SIGHASH_ALL P2PKH sign, deterministic nonce k=sha256d(z||priv), low-S DER).`test_wallet`\n\n9/9, plus an independent Python verification of the signature.**createrawtransaction + send**(`asm/wallet_core.c`\n\n,`tests/test_send.c`\n\n) — the wallet now*builds and sends*a real tx, not just signs a supplied one.`wallet_createrawtx`\n\nselects our prevouts, pays a destination P2PKH output and returns change (`sum(inputs) − amount − fee`\n\n; rejects underfunded / zero-fee, omits the change output when change is 0);`wallet_sign_all_inputs`\n\nsigns EVERY input (legacy SIGHASH_ALL over the pure-unsigned form, low-S DER);`wallet_send_tx`\n\nis the one-call send;`wallet_get_balance`\n\nsums the wallet's unspent prevouts. CLI:`wallet_cli send <priv> <dest_h160> <amount> <fee> <txid:idx:value>...`\n\nprints the signed tx,`wallet_cli balance <v> [v...]`\n\nprints the wallet UTXO sum.`test_send`\n\n(48th harness) feeds the signed tx through the SAME whole-tx validator as test_txval (UTXO presence/double-spend- per-input verify_p2pkh + fee): multi-input send VALID with correct outpoint/amount/change/fee, exact-balance send (no change output), underfunded and zero-fee REJECTED, send-vs-empty-UTXO rejected, and balance math — 6 cases / 18 checks ALL PASS.\n\n**Wallet-core + CLI/RPC surface (bitcoin-cli parity, batch complete)**— five cards (`t_wrpc_getaddr`\n\n..`t_wrpc_send`\n\n) delivered a coherent Core-aligned command layer on top of the verified asm crypto (in`asm/wallet_core.c`\n\n+`asm/daemon/wallet_cli.c`\n\n+ harnesses`test_wrpc_addr/utxo/decoderaw/sign/send`\n\n):`getnewaddress`\n\n/`getrawchangeaddress`\n\n— BIP84`m/84'/0'/0'/i/0`\n\nand`.../1`\n\nP2WPKH bech32 receive/change addresses from a seed.`getaddressinfo`\n\n/`validateaddress`\n\n— parse + classify base58check (P2PKH/P2SH) and bech32 (P2WPKH/P2WSH) addresses, report version + hash.`listunspent`\n\n/`gettxout`\n\n— enumerate a wallet's unspent outputs and query an outpoint, each with value + scriptPubKey + address.`decoderawtransaction`\n\n— full human-readable decode of a raw tx (version, every input outpoint/scriptSig/sequence, outputs value/scriptPubKey/address, locktime).`signrawtransactionwithkey`\n\n— sign selected inputs with provided private keys (legacy SIGHASH_ALL, low-S), per-input key-ownership matching, already-signed inputs left untouched, signed-input masking.`sendtoaddress`\n\n+`getbalance`\n\n— greedy input selection over the wallet's own UTXOs, build + sign a send, report change/fee/new-balance; getbalance sums the wallet UTXOs. All five harnesses ALL PASS (known-vector addresses/base58 decode round-trip, corrupt-checksum rejection, gettxout found/absent, full tx decode, two-key sign ACCEPT/wrong-key REJECT/partial REJECT, greedy send + insufficient-funds + exact-balance). This is the in-scope wallet-core + bitcoin-cli/RPC surface (behavioral parity target); the full RPC transport and the remaining address/UTXO-resolver commands remain for a later RPC/bitcoin-cli layer.\n\n**bitcoin-cli network layer / JSON-RPC transport**(`t_8e5be37f`\n\n) — wired the command layer onto a REAL JSON-RPC 2.0 transport. New shared RPC layer:`asm/rpc_json.c`\n\n— Core-bit-exact UniValue serializer (`write(pretty=2)`\n\n, 2-space indent, Core field order + escape set) and strict parser;`asm/rpc_net.c`\n\n— JSON-RPC 2.0 request/reply framing + HTTP POST over a local socket with HTTP Basic auth (rpcuser/rpcpassword), a minimal HTTP/1.1 request parser, and the reply-envelope parser;`asm/rpc_commands.c`\n\n— the shared dispatch/render path that maps a parsed request (method+params) to the wallet-core command layer and emits Core-shaped result JSON (`rpc_amounts`\n\nreproduces Core`ValueFromAmount`\n\nexactly). Client binary`asm/daemon/bitcoin_cli`\n\nbehaves like bitcoin-cli: string results print raw, objects/arrays via`write(2)`\n\n, RPC errors print`error code:`\n\n/`error message:`\n\nand exit non-zero. Verified end-to-end over a real loopback HTTP socket by`asm/tests/test_rpc_transport`\n\n(execs the actual`daemon/bitcoin_cli`\n\nbinary against a thread-spawned HTTP JSON-RPC responder that dispatches through the same`rpc_dispatch`\n\n) — 19 checks byte-exact (wire framing, getnewaddress / getrawchangeaddress / getbalance / validateaddress / listunspent / gettxout / decoderawtransaction rendering, method-not-found + transport-error paths);`asm/tests/test_rpc_json`\n\n(28 checks) pins the renderer +`rpc_amounts`\n\nbyte-exact.**HTTP JSON-RPC server endpoint**(child card`t_0ca5d72e`\n\n) added the production server side:`asm/rpc_server.c`\n\n(loopback listen socket + accept thread, Core-bit-exact HTTP + JSON-RPC: 405 on non-POST, 401 +`WWW-Authenticate`\n\nauth,`-32700`\n\nparse error, V2/V1 envelopes with id echo, V2-notification 204) and`asm/daemon/bitcoin_rpcd`\n\n(loads rpcport/rpcuser/ rpcpassword from`config/bitcoin.conf`\n\n, serves until SIGINT/SIGTERM), both dispatching through the same`rpc_dispatch()`\n\n.`asm/tests/test_rpc_server`\n\nproves the production path end-to-end — forks+execs the REAL`bitcoin_rpcd`\n\nand drives it with the REAL`bitcoin_cli`\n\nplus raw sockets — 23 checks byte-exact. Together the client and server close the RPC-transport OPEN item.**Live-wire end-to-end sighash spend**(`tests/test_e2e_sighash.c`\n\n) — the full wallet->validator path exercised as ONE integrated test across a real process boundary, not isolated pre-generated vectors: it builds a genuine unsigned P2PKH tx in memory, hands it to the ACTUAL`daemon/wallet_cli sign`\n\nbinary (legacy SIGHASH_ALL, low-S, deterministic nonce) and captures its real`signed-tx:`\n\nstdout, then feeds that CLI-signed tx through the whole-tx validator (UTXO presence/double-spend +`verify_p2pkh`\n\nper input + fee) and requires it to pass. The CLI signature is additionally cross-checked as a genuine spend through the repo's independently-verified`ecdsa_verify`\n\n. Live negative cases round it out: the CLI signs a negative-fee tx (valid sig) that the validator rejects on`[fee]`\n\n; an output-value tamper invalidates the SIGHASH_ALL digest -> rejected; a corrupted DER byte -> rejected; and the same signed tx against an empty UTXO set -> double-spend rejected. 9/9.**BIP32 full-path derivation + extended keys (xprv/xpub)**(`asm/bitcoin_bip32.asm`\n\n) — three new functions on top of the verified`bip32_master`\n\n/`bip32_ckd_priv`\n\n:`bip32_derive_path`\n\n(derive a full path`m/44'/0'/0'/0/0`\n\nfrom a seed in one call),`bip32_fingerprint`\n\n(HASH160(pub)[0..4], the BIP32 parent fingerprint), and`bip32_extkey_serialize`\n\n(build the 78-byte xprv/xpub payload). Combined with the verified base58check encoder this yields real`xprv`\n\n/`xpub`\n\nstrings, tying key -> address -> extended key together.`test_bip32_extkey`\n\nverifies the BIP32 vector-1 chain end, a BIP44 and a BIP84 path, and the master extended keys byte-exact against an independent`bip32`\n\nPython oracle. (The base58 encoder's digit-work buffers were enlarged to hold 78-byte payloads; the 25-byte address path is unchanged and still green.)**BIP39 mnemonic <-> seed**(`asm/bitcoin_bip39.asm`\n\n) — full mnemonic generation/validation + PBKDF2 seed derivation, pairing with BIP32 for recoverable wallets. Embedded 2048-word English wordlist (`asm/wordlist.inc`\n\n, 9-byte fixed-width records, official order abandon..zoo); entropy (128..256 bits, 12..24 words) -> 11-bit groups with the trailing SHA-256 checksum (CS = ENT/32); validation re-derives the checksum and rejects bad word count, unknown words, and checksum mismatches; and seed derivation is PBKDF2-HMAC-SHA512(P=mnemonic, S=\"mnemonic\"||pass, c=2048, dkLen=64) built on the verified asm`hmac_sha512`\n\n.`test_bip39`\n\n(24 vectors) verifies generate/validate/mnemonic->entropy and both empty- and \"TREZOR\"-passphrase seeds byte-exact against the official bip-0039 vectors via the independent Python oracle (`asm/validation/gen_bip39_vectors.py`\n\n, cross-checked with`hashlib.pbkdf2_hmac`\n\n). The wallet CLI now reports a recoverable seed end to end:`wallet_cli mnemonic`\n\n`->`\n\n`wallet_cli seed \"<words>\" [pass]`\n\nyields the mnemonic, 64-byte seed, master`xprv`\n\n, and`m/44'/0'/0'/0/0`\n\naddress.**Persistent UTXO store**(`asm/bitcoin_utxo_store.asm`\n\n) — a crash-safe, reloadable on-disk layer over the in-memory UTXO set, mirroring the proven append-only store/index pattern of the block archive: a write-ahead operation log`utxo.dat`\n\n(framed PUSH/DEL records; the durable source of truth) plus a checkpoint index`utxo.idx`\n\n(a snapshot of the live set + the log offset it covers).`utxo_store_put/del`\n\nappend the op to the WAL first, then apply it in memory;`utxo_store_sync`\n\nwrites a checkpoint and fsyncs both files;`utxo_store_reload`\n\nrestores the checkpoint O(n) and replays the WAL tail past it (restart-resume), recovering a crash between checkpoints exactly like the block store's resume.`test_utxo_store`\n\nverifies put/spend/dedup, full-WAL reload, checkpoint + crash-tail restart-resume, and on-disk framing.**bech32 / bech32m codec**(`asm/bech32.asm`\n\n) — BIP173/350 address codec (`bech32_polymod`\n\n30-bit CRC, create/verify checksum with the XOR-1 vs 0x2bc830a3 switch, 8<->5 bit regroup, encode/decode), verified against every authoritative BIP173/BIP350 vector plus exact real mainnet segwit addresses (P2WPKH bc1qw508..., P2WSH bc1qrp33..., P2TR bech32m bc1p...).**P2SH / multisig**(`asm/bitcoin_multisig.asm`\n\n) —`p2sh_hash`\n\n(RIPEMD160(SHA256(redeemScript))) and`multisig_verify`\n\n(OP_CHECKMULTISIG evaluation: walk the scriptSig pushes, take the push before the target pubkey as that signer's DER sig, and ECDSA-verify it against the legacy SIGHASH_ALL preimage with the redeem script as the signing script).`test_multisig`\n\n(8/8) is cross-checked by the independent pure-Python`ecdsa`\n\noracle (`asm/validation/p2sh_oracle.py`\n\n): known p2sh hashes, a self-consistent spend that verifies, and tampered-sig / wrong-pubkey negatives.**Full script interpreter**(`asm/bitcoin_interp.asm`\n\nbuilt on the verified support layer`asm/bitcoin_scriptcodec.asm`\n\n) — a complete Bitcoin Script EvalScript engine covering the full opcode set with Bitcoin Core semantics: flow control (`OP_IF/ELSE/ENDIF/VERIFY/RETURN`\n\n,`vfExec`\n\ncondition stack), stack/splice (`DUP/DROP/SWAP/ROT/PICK/ROLL/2DUP/2OVER/2ROT/...`\n\n), bitwise (`SIZE/EQUAL[VERIFY]`\n\n), arithmetic (monadic`1ADD/1SUB/NEGATE/ABS/ NOT/0NOTEQUAL`\n\n+ binary`ADD/SUB/BOOLAND/BOOLOR/NUMEQUAL[VERIFY]/ NUMNOTEQUAL/LESSTHAN/GREATERTHAN/.../MIN/MAX/WITHIN`\n\nover clamped 32-bit and 64-bit ScriptNum), crypto (`OP_SHA256/OP_HASH160/OP_HASH256/OP_RIPEMD160`\n\n,`OP_CODESEPARATOR`\n\n, and the`OP_CHECKSIG`\n\nfamily host via a callback), disabled opcodes returning**false**, reserved->bad-opcode,`OP_CLTV/OP_CSV`\n\nhandling, and**tapscript/BIP342** semantics:`OP_SUCCESSx`\n\npre-scan (short-circuit success /`DISCOURAGE_OP_SUCCESS`\n\n), cleanstack + empty-stack treatment (`CLEANSTACK`\n\n/`EVAL_FALSE`\n\n), tapscript-minimal-IF as an unconditional consensus rule,`OP_CHECKSIGVERIFY`\n\nforbidden,`OP_CHECKMULTISIG`\n\n->`TAPSCRIPT_CHECKMULTISIG`\n\n, and`OP_CHECKSIGADD`\n\ngating (valid only under tapscript). Verified differentially against Bitcoin Core's`script_tests.json`\n\n(`tests/script_tests_diff.py`\n\n: 67/67 BASE opcode vectors byte-for-byte, exit 0) plus a dedicated 24-check tapscript harness (`tests/test_tapscript_interp.c`\n\n) and`tests/smoke_interp`\n\n/`test_interp`\n\n. The taproot/schnorr signature callback layer is wired downstream (t_93b2695f, taproot/segwit v1).**Taproot / segwit v1 validation (BIP341/340/342)**— BIP340 Schnorr signature verify + signing (`asm/secp256k1_schnorr.asm`\n\n, verified against all 19 official`bip-0340`\n\ntest vectors), BIP341 taproot helpers (`asm/secp256k1_taproot.asm`\n\n: x-only tweak with parity, tagged-hash tapleaf/ branch/merkle-root, control-block parsing), bech32m P2TR address<->scriptPubKey (BIP341/350), and end-to-end spend validation in`asm/bitcoin_taproot_sighash.c`\n\n: BIP341 SigMsg serialization + TapSighash for key-path and script-path (BIP342 ext) with every hash type, key-path schnorr verify against the output key (including witness-annex commitment), script-path`OP_CHECKSIG`\n\n/`OP_CHECKSIGADD`\n\nverify, and the`checksig_fn`\n\ncallback that drives live tapscript`OP_CHECKSIG`\n\n/`CHECKSIGADD`\n\nspends through the ASM script interpreter. Verified byte-for-byte against the official Bitcoin Core`wallet-test-vectors`\n\n(keyPathSpending) + Core-validated reference preimages, cross-checked by the independent pure-Python oracle (`asm/validation/gen_taproot_vectors.py`\n\n).`test_taproot_sighash`\n\n48 checks green;`make test`\n\nsuite green.**Witness-v0 + taproot full mempool acceptance parity vs Core**— modern-output transactions (P2WPKH / P2WSH / P2TR) through the entire mempool-acceptance pipeline. BIP143 segwit-v0 sighash (`asm/bitcoin_segwit.c`\n\n, mirroring Core`SignatureHash WITNESS_V0`\n\n) verified byte-exact against the official BIP-0143 test vector via the independent Python oracle (`asm/validation/gen_modern_vectors.py`\n\n); a unified whole-tx validator (`asm/bitcoin_txval_modern.c`\n\n) dispatches by prevout type and runs each genuine spend through strip-witness + per-input ECDSA (P2WPKH, P2WSH`OP_CHECKSIG`\n\n+ 2-of-2`OP_CHECKMULTISIG`\n\n) / Schnorr (P2TR key-path) verify on top of the verified ASM secp256k1; driven end-to-end with the mempool policy layer (`mpool_policy_add`\n\n: fee, double-spend, RBF, ancestor limits) in`test_mempool_accept_modern`\n\n. Every genuine modern tx is accepted by BOTH policy and whole-tx validation; every negative (corrupted sig, wrong pubkey, absent prevout, double-spend, negative fee) rejected in agreement with Core.`test_segwit_sighash`\n\n17 +`test_mempool_accept_modern`\n\n23 checks green;`make test`\n\nsuite green. Closes the modern-output validation gap.**Differential consensus harness vs Bitcoin Core (compliance gate)**—`validation/consensus_diff.py`\n\n+`asm/tests/consensus_shim`\n\nfeed the SAME real mainnet block/tx bytes to (a) the ASM consensus stack (`cons_verify`\n\n/`block_hash`\n\n/`pow_check`\n\n/`diff_target`\n\n/`tx_txid`\n\nvia the shim) and (b) a real Bitcoin Core node's RPC, and compare every verdict byte-for-byte. Two differential passes: an**ACCEPT path**(every real mainnet block the active chain accepted must be`cons_verify`\n\n-valid AND its ASM block_hash must equal Core's height->hash — a rejection/`hash mismatch is a false-negative consensus bug), and a **REJECT path** (deterministic mutations of real blocks — flipped merkle/tx/nonce/prev bytes, txcount corruption, truncation — are fed as identical bytes to`\n\ncons_verify`and Core`\n\nsubmitblock`; both must reject together). A per-tx **txid differential** verifies the ASM BIP141 txid against Core's canonical txid for up to 120 real txs per sampled block. Verified clean (zero divergences) across the consensus-critical epochs: genesis, BIP16 activation (173805), BIP34 (227931), SegWit (481824), Taproot (709632), recent mainnet (918000).`\n\ntests/consensus_shim`builds via`\n\nmake`; drive with`\n\npython3 validation/consensus_diff.py --start H --count N`.\n\n**Peer discovery layer (self-contained, full-client):** `asm/bitcoin_addrmgr.asm`\n\nis a persisted peer address book (`peers.dat`\n\n) plus byte-exact `addr`\n\nv1 codecs\n(verified by `test_addrmgr`\n\n). `daemon/crawler.c`\n\n/ `daemon/addrgather.c`\n\nharvest\npeers via getaddr->addr/addrv2 and fold them into the book; `daemon/peertest.c`\n\nverifies which peers actually serve block bodies. Combined with the distinct-peer\nselection this is the basis for self-directed discovery.\n\n**The durable archive** is a single unified store (`data/blk00000.dat`\n\n.. + `index.dat`\n\n+\n`headers.dat`\n\n— one directory, no worker shards) that is queryable via the asm CLI\nand **served entirely in assembly**. Serving was rebuilt around an **O(1) in-memory\nhash→height index** built in assembly (`asm/bitcoin_idx.asm`\n\n: `idx_init/put/get`\n\n,\nopen-addressing, full 32-byte keys) — a linear per-height scan never finished on a\nlarge archive and a single hole aborted it. `asm/bitcoin_serve.asm`\n\n(`node_serve_loop`\n\n) is the per-connection server message loop in pure machine\ncode: ping→pong, getaddr→addr (address book), getdata→block (O(1) lookup +\n`node_serve_block`\n\n), getheaders (2000x81B pages), inv. The serve daemon\n(`./bitcoind serve`\n\n) calls it after `node_accept_handshake`\n\n, so both halves of the\nnode's core run in assembly (outbound download `node_ibd_*`\n\n+ inbound server\n`node_serve_loop`\n\n). Verified live against the daemon: 8 real mainnet blocks served\nbyte-exact on one connection, each hashing back to the requested hash. The buffer\nsizing is hardened for modern (up to 4 MB) blocks. One-shot health:\n`daemon/nodecheck.sh`\n\n(audit + progress + serve round-trip) and\n`daemon/chainprogress.sh`\n\n(coverage toward a complete 0..tip archive). As the\nforward pass and the early-height backfill converge, the archive reaches **block 0\n(the 2009 genesis block)** upward — `verify`\n\non contiguous runs reports 100%\nhash-match / chain-link / PoW / consensus (`CHAIN VERIFIED`\n\n).\n\n**Wallet message signing / verification**(`asm/wallet_msgsign.c`\n\n,`asm/daemon/wallet_cli.c`\n\n) —`signmessage <priv_hex> <message>`\n\nand`verifymessage <pub_hex|address> <message> <sig>`\n\nusing only the verified asm crypto. Two encodings, both over the byte-exact BIP137 digest (double-SHA256 of`\"\\x18Bitcoin Signed Message:\\n\" || varint || msg`\n\n): a plain`r||s`\n\nhex form (verify against a pubkey), and a**Core-compatible recoverable** form (`msg_sign_core`\n\n/`msg_verify_core`\n\n) that emits the 65-byte base64 compact signature`[27+4+recid(+low-s bit)]||r||s`\n\nvia hand-rolled ECDSA**public-key recovery**(recid search over the asm`fe`\n\n/`point`\n\n/`scalar`\n\nprimitives) and verifies from an**address alone**— the exact Core`verifymessage`\n\nflow. Pinned by`tests/test_msg_sign.c`\n\n: 120-message recoverable round-trip + tamper reject + wrong-message reject (all recovery-ids and both low-s states).**Persistent transaction history journal**(`asm/wallet_txlog.c`\n\n) —`wallet_cli history`\n\n/`listtransactions`\n\nrender an append-only, versioned, own-format journal (BMCTX v1, 0600 perms, one record per sent tx: ts, txid, amount, fee, dest-h160, inputs, rawlen).`cmd_send`\n\n/`cmd_sendtoaddress`\n\nrecord each sent tx;`test_wallet_txlog`\n\n(11 checks) covers path derivation, perms, versioned header, list round-trip and append-only behavior.**Fast block store read path**(`asm/bitcoin_store_fast.asm`\n\n,`asm/bench_store_read.c`\n\n) — cuts the per-block serve cost from six syscalls to two (positioned`pread`\n\nof index + body via a direct-mapped 8-slot read-only fd cache), and to zero-copy via a guarded`mmap`\n\npath (`store_map_*`\n\n) with remap-on-growth and SIGBUS-past-EOF protection. Verified byte-exact vs the old path on 4000 blocks incl. random-access, mmap, append-while-mapped remap; ~1.1x (pread) and ~2.1x (mmap) at page-cache speeds. Removes the shared-index-fd race making concurrent reads safe;`store_prune_safe`\n\ninvalidates both caches before unlink.**Security audit status**(`validation/SECURITY_AUDIT.md`\n\n) — two completed audit passes, 2026-08-15 (PASS 1) and 2026-08-16 (PASS 2), of the assembly crypto + consensus + wallet core, following an internal line-by-line review method and backed by regression harnesses committed to the suite.- PASS 1 findings all\n**FIXED**: the CRITICAL non-constant-time signing path (FINDING 1 — fixed via a constant-time`point_scalar_mul_ct`\n\nrepointed onto the two secret-scalar call sites; field arithmetic made branch-free per FINDING 3), and the legacy-sighash out-of-bounds read / write-cap defects (FINDING 2 / 2b, both with`test_sighash_oob.c`\n\nregression). - PASS 2 (2026-08-16, post-delta review) found\n**no new CRITICAL or HIGH** issue across the newest crypto/networking surfaces; two hardening items are recorded as open (INFO/LOW — journal durability, recovery-scan efficiency / Core-header extension bit). - With FINDING 1 fully landed the\n**signing path is constant-time end-to-end**. The README warning above remains because the code has not undergone an*independent third-party*audit; the internal audit is complete, tracked in-repo, and green.\n\n- PASS 1 findings all\n\n```\nbitcoinmachinecode/\n+-- asm/\n|   +-- sha256.asm            # SHA-256: init, block compression, one-shot (x86-64 NASM)\n|   +-- secp256k1_fe.asm      # field add/sub/mul/sqr/inv mod secp256k1 prime p\n|   +-- secp256k1_point.asm   # Jacobian point double/add/scalar-mul over secp256k1\n|   +-- secp256k1_scalar.asm  # scalar add/sub/mul/sqr/inv mod curve order n\n|   +-- secp256k1_ecdsa.asm   # low-S ECDSA signature verification\n|   +-- bitcoin_hash.asm      # sha256d / block_hash / merkle_root / pow_check\n|   +-- bitcoin_tx.asm        # transaction deserializer (tx_parse)\n|   +-- bitcoin_net.asm       # POSIX sockets + P2P framing (raw syscalls)\n|   +-- bitcoin_p2p.asm       # getheaders/getdata/ping builders + headers parser\n|   +-- bitcoin_store.asm      # persistent blk file + positional block index\n|   +-- bitcoin_headers.asm    # persistent header chain (hdr, block_hash) store\n|   +-- bitcoin_cons.asm       # full-block consensus check (cons_verify)\n|   +-- bitcoin_cli.asm        # S6 CLI: query the store (cli_main)\n|   +-- bitcoin_addrmgr.asm    # persisted peer address book + addr v1 codecs\n|   +-- bitcoin_idx.asm        # O(1) block hash->height index for serving (idx_*)\n|   +-- bitcoin_serve.asm      # inbound server message loop (node_serve_loop)\n|   +-- bitcoin_pubkey.asm     # fe_pow + pubkey_parse: secp256k1 pubkey de/compress\n|   +-- bitcoin_sighash.asm    # legacy SIGHASH_ALL preimage builder\n|   +-- bitcoin_script.asm     # der_parse_sig + verify_p2pkh (end-to-end P2PKH validate)\n|   +-- bitcoin_utxo.asm       # in-memory UTXO set (prevout value/script)\n|   +-- bitcoin_utxo_store.asm # PERSISTENT UTXO: WAL utxo.dat + idx checkpoint\n|   +-- bech32.asm             # BIP173/350 bech32/bech32m address codec\n|   +-- bitcoin_bip32.asm      # BIP32 master/CKD/derive_path + xprv/xpub\n|   +-- bitcoin_bip39.asm      # BIP39 mnemonic<->seed (PBKDF2-HMAC-SHA512)\n|   +-- wordlist.inc           # 2048-word BIP39 English wordlist (9-byte records)\n|   +-- bitcoin_multisig.asm   # p2sh_hash + multisig_verify (OP_CHECKMULTISIG)\n|   +-- wallet_core.c          # wallet primitives glue over asm crypto\n|   +-- bitcoin_mempool_policy.c # policy/RBF/fee layer over mempool + UTXO\n|   +-- build.sh              # assemble + build + run every verification harness\n|   +-- Makefile              # make asm | test | clean\n|   +-- cuda/                 # optional CUDA batch-acceleration tier (crypto)\n|   |   +-- cuda_sha256.cu    #   batch SHA-256 / SHA-256d kernel + host ABI\n|   |   +-- cuda_sha256.h     #   opaque batch ABI header\n|   |   +-- cuda_autodetect.c #   runtime auto-detect + CPU-fallback dispatcher\n|   |   +-- cuda_verify.cu    #   correctness gate vs the asm oracle (PASSES)\n|   |   +-- cuda_bench.cu     #   GPU/CPU throughput comparison\n|   |   +-- cuda_autodetect_test.c # routing/digest matrix (all modes)\n|   |   +-- Makefile          #   make verify | bench | detect | all\n|   |   +-- WORKING.md        #   feasibility analysis + roadmap\n|   +-- tests/                # C harnesses proving the machine code correct\n|   +-- validation/           # Python big-int oracles (trusted reference)\n|   +-- daemon/               # C orchestration + peer discovery/serving tools\n|       +-- wallet_cli.c      # wallet CLI: addr/sign/send/sendtoaddress/balance/getnewaddress/getrawchangeaddress/getaddressinfo/validateaddress/gettxout/listunspent/decoderawtransaction/signrawtransactionwithkey + mnemonic/seed\n|       +-- unified_ibd.c     # standalone bulk-download tool: chunk-claiming/work-stealing engine (same design bitcoind's own built-in dl_catchup uses)\n|       +-- hole_ranges.py    # find gaps in index.dat (unified_ibd's driver)\n|       +-- backfill_holes.sh # one combined-span unified_ibd call over current holes\n|       +-- sync_chain.sh     # chains hole-fill into extending to the real tip\n|       +-- chainctl.c        # chunked full-chain orchestrator (resume/audit/ETA)\n|       +-- check_chain.c     # integrity audit (dups/holes/corruption, chain-breaks)\n|       +-- verify.c          # full chain validation (hash/chain/PoW/consensus)\n|       +-- dumpblock.c       # inspect a stored block (raw bytes / header summary)\n|       +-- nodecheck.sh      # one-shot health: audit + progress + serve round-trip\n|       +-- chainprogress.sh  # coverage toward a complete 0..tip archive\n|       +-- crawler.c         # parallel getaddr peer harvester\n|       +-- addrgather.c      # getaddr -> addr/addrv2 -> peers.dat address book\n|       +-- peertest.c        # verify which peers serve block bodies\n|       +-- main.c            # daemon: sync / ibd / follow / serve (self-healing built-in catch-up) / server-test\n|       +-- cli.c             # thin driver for the asm cli_main\n+-- data/                    # durable chain storage: ONE unified archive\n|                           # (blk00000.dat..blkNNNNN.dat + index.dat + headers.dat)\n+-- README.md\n```\n\nBlocks persist to the current working directory as `blk00000.dat`\n\n(append-only\nframed blocks) + `index.dat`\n\n(positional height index) + `bitcoind.log`\n\n. The\ndurable home is ** data/** under the project root, on the\n\n`/storage`\n\nNVMe\nmount (ext4, ~2.6 TB free — room for a full archive node; pruned mode fits in\njust a few GB). Point the daemon/CLI there:\n\n```\ncd /storage/bitcoinmachinecode/asm/daemon\n./bitcoind sync /storage/bitcoinmachinecode/data     # download + validate + store\n./bitcoind ibd /storage/bitcoinmachinecode/data      # FULL IBD as one asm pass\n                                                     # (headers-first persist +\n                                                     # getdata block bodies +\n                                                     # validate + store)\n# self-healing: discovers peers, fills any archive gap AND catches up to the\n# real chain tip on its own (dl_catchup, >=8 chunk-claiming workers), THEN\n# opens for inbound service -- no external tooling needed for normal operation:\n./bitcoind serve /storage/bitcoinmachinecode/data 8333\n\n# standalone bulk-download tool (same chunk-claiming engine as dl_catchup),\n# for a very large initial catch-up or offline reindexing:\n./unified_ibd /storage/bitcoinmachinecode/data 8 <start_h> <end_h>\n./backfill_holes.sh /storage/bitcoinmachinecode/data 8   # fill every current gap\n./sync_chain.sh /storage/bitcoinmachinecode/data 8       # gaps, then extend to real tip\n# chunked full-chain orchestrator (forward to tip, resuming + auditing each chunk):\n./chainctl /storage/bitcoinmachinecode/data 8 16000 20\n# health / progress / audit / serve round-trip:\n./nodecheck.sh /storage/bitcoinmachinecode/data        # audit + progress + serve\n./chainprogress.sh /storage/bitcoinmachinecode/data    # coverage toward 0..tip\n./check_chain /storage/bitcoinmachinecode/data         # dups/holes/corruption audit\n./verify /storage/bitcoinmachinecode/data <lo> <hi>    # hash/chain/PoW/consensus\n./cli /storage/bitcoinmachinecode/data getblockcount   # query the stored chain\n./asm/build.sh\n# or\ncd asm && make test\n```\n\nRequires `nasm`\n\nand `gcc`\n\n. Exit code 0 means the assembly hash is correct.\n\n```\n// sha256.asm\nvoid sha256_init (u32 state[8]);                                    // hash init\nvoid sha256_block(u32 state[8], const u8 block[64]);                // one block\nvoid sha256_full (u8 out[32], const void *msg, unsigned long len);  // one-shot\n\n// bitcoin_hash.asm (node-layer hashing, built on sha256)\nvoid sha256d      (u8 out[32], const void *msg, long len);          // double SHA-256\nvoid block_hash   (u8 out[32], const u8 hdr[80]);                   // sha256d(hdr,80)\nvoid diff_target  (u8 target[32], u32 bits);                        // compact nBits->target\nint  pow_check    (const u8 hdr[80]);                               // PoW holds?\nvoid merkle_root  (u8 out[32], u8 hashes[], unsigned long n);       // tx merkle (in place)\n\n// bitcoin_tx.asm (transaction deserializer)\nint tx_parse(u64 info[8], const void *tx, unsigned long txlen);    // 1 if fully parsed (legacy + SegWit)\nint tx_txid (u8 out[32], const void *tx, long txlen, void* buf, long buflen); // BIP141 txid\n\n// bitcoin_net.asm (POSIX sockets + P2P framing)\nlong fd_write_all(int fd, const void* buf, size_t n);            // n or -1\nlong fd_read_full (int fd, void* buf, size_t n);                 // n / <n on eof / -1\nint  tcp_connect_ip(u32 ip_le, u16 port_be);                     // fd or -errno\nlong p2p_write(int fd, const char* cmd, const void* pl, u32 plen);  // total or -1\nint  p2p_read(int fd, char cmd_out[12], void* pl, u32 cap, u32* len_out);\n                                                            // 1 ok / 0 eof / -1 err / -2 trunc\n\n// bitcoin_p2p.asm (message payload codecs)\nlong p2p_getheaders(u8* out, const u8 locator[32], long count, const u8 stop[32]);  // 69\nlong p2p_getdata_block(u8* out, const u8 hash[32]);         // 37 (MSG_BLOCK)\nlong p2p_ping(u8* out, u64 nonce);                          // 8\nlong p2p_headers_count(const u8* payload, long plen);       // #header entries or -1\n\n// bitcoin_cons.asm (full-block consensus validation)\nint cons_verify(const u8* block, u64 len, u8* txid_scratch, u64 cap); // 1 valid / 0 invalid\n\n// bitcoin_headers.asm (persistent header-chain store)\nint  hst_init(void* hst);                                  // open headers.dat\nint  hst_reload(void* hst);                                // count from file size\nlong hst_append(void* hst, const u8 hdr[80], const u8 hash[32]);  // new count / -1\nint  hst_get_at(void* hst, u64 height, u8 out[112]);       // 1 / 0 / -1\nlong hst_count(void* hst);\n\n// bitcoind.asm node_ibd_headers (paged persistent headers-first IBD)\nlong node_ibd_headers(int fd, void* hst, void* locator32, void* page_buf, u64 buflen);\n                                             // total headers appended, or -1\n\n// bitcoind.asm node_ibd_blocks (block bodies off the persisted header chain)\nlong node_ibd_blocks(int fd, void* st, void* hst, long start_h, void* buf, u64 buflen);\n                                             // # blocks stored this call, or -1\n\n// bitcoind.asm node_ibd (FULL IBD as one assembly pass: chain node_ibd_headers\n// then node_ibd_blocks over a single peer connection)\nlong node_ibd(int fd, void* st, void* hst, void* buf, u64 buflen);\n                                             // # blocks stored, or -1\n\n// bitcoind.asm node_accept_handshake (INBOUND/server-role handshake)\nint node_accept_handshake(int fd);         // 1 ok / 0 (answers an inbound peer's\n                                           // version, replies ours + verack)\n\n// bitcoin_cli.asm (S6 CLI -- query the persistent store, all-asm rendering)\nlong cli_main(void* store, long argc, void** argv, u8* out, long cap); // bytes written / -1\nlong cli_atoi(const char* s);                              // decimal string -> long\nint  cli_hex_to_bin(u8* out32, const char* hex64);          // 64-hex -> 32 bytes, 1/0\n(void cli_hex / cli_rev32 are internal helpers; cli_main is the entry point)\n// secp256k1_fe.asm / _point.asm / _scalar.asm / _ecdsa.asm\n// see asm/source headers for the field/point/scalar/ECDSA APIs\n```\n\nNo human-written code. The compiler/assembler performs only the mechanical translation of AI-authored instructions into machine code; the algorithm, the register allocation, the padding logic, and every comment are produced by an AI.", "url": "https://wpnews.pro/news/bitcoin-i-m-retarded-asm-client-server-project-in-the-works", "canonical_source": "https://github.com/BobClawblaw/bitcoinmachinecode", "published_at": "2026-08-17 05:53:59+00:00", "updated_at": "2026-08-17 06:10:52.894293+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-safety", "ai-research"], "entities": ["Bitcoin", "SHA-256", "secp256k1", "ECDSA", "BIP141", "SegWit", "FIPS-180-4"], "alternates": {"html": "https://wpnews.pro/news/bitcoin-i-m-retarded-asm-client-server-project-in-the-works", "markdown": "https://wpnews.pro/news/bitcoin-i-m-retarded-asm-client-server-project-in-the-works.md", "text": "https://wpnews.pro/news/bitcoin-i-m-retarded-asm-client-server-project-in-the-works.txt", "jsonld": "https://wpnews.pro/news/bitcoin-i-m-retarded-asm-client-server-project-in-the-works.jsonld"}}