#!/usr/bin/env python3
"""Static, stdlib-only verification of v0.1.0's unfinished marketplace.
Reads the preserved .tgz without executing or extracting it. Optionally checks
its companion .rar hash. Writes deterministic JSON evidence.
"""
import argparse
import hashlib
import json
import re
import tarfile
from pathlib import Path
ROOT = Path(__file__).resolve().parent
DEFAULT_ARCHIVE = ROOT.parent / "sources" / "v0.1" / "bitcoin-0.1.0.tgz"
DEFAULT_RAR = ROOT.parent / "sources" / "v0.1" / "bitcoin-0.1.0.rar"
EXPECTED_TGZ = (2_935_983, "ce9da46516e3042741224a7f9061e3181a5a4d17abba72b6e82922af3753d756")
EXPECTED_RAR = (2_132_686, "8b17eb9a5707f2519defda4cdf8d14fa1b8dee630e11e6ef85ff9f5547555b56")
EXPECTED_MEMBERS = {
"bitcoin/bitcoin.exe": "fbcac071d92e26d82ec917214e334bd43850c0691f113bab1d4741c9bdd30d2d",
"bitcoin/src/market.cpp": "81c15691f9ca4c0a0d66b4a4a95e631caf3f31af26575e5ab49f8db838fa6e39",
"bitcoin/src/market.h": "85aa4b054d749e094e641d41233384c1e7b58c84696b7be145ab53e6c0fbdbc4",
"bitcoin/src/ui.cpp": "bec80418526c9fe45f3b83c99c0a708363942df271d3f048c18fec6ebff8fa63",
"bitcoin/src/uibase.cpp": "a6270e7d73012541cd086a5ca1d9b06ad8ec3422e2e3ce1c9ce0a064f0c350da",
"bitcoin/src/ui.h": "33db8e6b87a6a5427661acf894f006dd112f2c339daaedc454c9aaf4de67cf8a",
"bitcoin/src/uibase.h": "945c2abf4280518a6d1ede7319e835fb3df82674e8a907ec4a2d1e8c74674eab",
"bitcoin/src/main.cpp": "c89f44185df7ff5d68342e5f533ae1282d5cf1259306d14c1c79315e973e0e1c",
"bitcoin/src/net.cpp": "fbaf9b912f7fedd87c8a1f1e232cb04dd567e41007abe900772579cf1e29dcbe",
"bitcoin/src/net.h": "500a513e1bf5503241a800fbd501646886d68334ab5cc29669b3496ea7b49442",
"bitcoin/src/db.cpp": "2b83d2432aa19ba3faceca58c0b610a715747089ec2d6ed580cd915b53c1a5ac",
"bitcoin/src/db.h": "6f0abeb8ae108f9823783a71ef214824e9f6ab72e93990bc70838cd55a433eda",
"bitcoin/src/makefile": "fa2f6c3031eb8625e24aa012fa7c0d6e17c7f61e7b9604d45cde5b7bfdade161",
"bitcoin/src/makefile.vc": "c00a4413d656f958120265590701e0fe2159020e474470726f826f1178d790ed",
}
SNIPPETS = [
("build-market-object", "bitcoin/src/makefile", 54, 58, ["obj/market.o", "obj/ui.o"]),
("build-linked-into-exe", "bitcoin/src/makefile", 74, 79, ["obj/market.o", "bitcoin.exe"]),
("vc-build-market-object", "bitcoin/src/makefile.vc", 47, 51, ["obj\\market.obj", "obj\\ui.obj"]),
("vc-build-linked-into-exe", "bitcoin/src/makefile.vc", 67, 72, ["obj\\market.obj", "bitcoin.exe"]),
("review-and-product-model", "bitcoin/src/market.h", 72, 171, ["class CReview", "class CProduct", "vOrderForm", "vchSig"]),
("user-atom-model", "bitcoin/src/market.h", 25, 64, ["vAtomsIn", "vLinksOut", "GetAtomCount"]),
("signed-review-and-link-propagation", "bitcoin/src/market.cpp", 197, 230, ["CKey::Verify", "WriteReviews", "vLinksOut", "AddAtomsAndPropagate"]),
("signed-product-and-ranking", "bitcoin/src/market.cpp", 237, 256, ["CheckSignature", "mapDetails.empty", "nAtoms"]),
("product-search-and-display", "bitcoin/src/ui.cpp", 2084, 2120, ["OnButtonSearch", '"price"', '"seller"', "nAtoms"]),
("sign-and-publish-product", "bitcoin/src/ui.cpp", 2287, 2324, ["keyUser.Sign", "mapDetails.clear", "AdvertStartPublish"]),
("request-product-details", "bitcoin/src/ui.cpp", 2431, 2450, ["ConnectNode", '"getdetails"']),
("product-reviews-display", "bitcoin/src/ui.cpp", 2491, 2550, ["ReadReviews", "nAtoms", '"stars"']),
("order-form-to-payment", "bitcoin/src/ui.cpp", 2638, 2667, ["GetOrder", "CSendingDialog", "product.addr", '"price"']),
("sign-and-relay-review", "bitcoin/src/ui.cpp", 2763, 2807, ["keyUser.Sign", "AcceptReview", "MSG_REVIEW"]),
("inventory-types", "bitcoin/src/net.h", 301, 375, ["MSG_REVIEW", "MSG_PRODUCT", '"review"', '"product"']),
("publish-send-template", "bitcoin/src/net.h", 810, 855, ["AdvertStartPublish", '"publish"', '"pub-cancel"']),
("product-inventory-check", "bitcoin/src/main.cpp", 1592, 1603, ["MSG_REVIEW", "MSG_PRODUCT", "mapProducts"]),
("review-receive-handler", "bitcoin/src/main.cpp", 1921, 1936, ['strCommand == "review"', "AcceptReview", "RelayMessage"]),
("order-payment-handlers", "bitcoin/src/main.cpp", 1974, 2012, ['strCommand == "checkorder"', 'strCommand == "submitorder"']),
("review-and-market-databases", "bitcoin/src/db.h", 280, 313, ["CReviewDB", '"reviews.dat"', "CMarketDB", '"market.dat"']),
("hidden-order-and-product-panels", "bitcoin/src/uibase.cpp", 143, 202, ["m_panel8->Hide", "m_panel10->Hide", "m_panel11->Hide"]),
("commented-main-window-market-columns", "bitcoin/src/ui.cpp", 297, 324, ["//m_listCtrlProductsSent", "//m_listCtrlOrdersSent", "//m_listCtrlOrdersReceived"]),
("marketplace-and-order-dialog-titles", "bitcoin/src/uibase.h", 407, 407, ["Marketplace"]),
("order-dialog-title", "bitcoin/src/uibase.h", 561, 561, ["Order Form"]),
]
PE_STRING_SOURCES = {
"Marketplace": "bitcoin/src/uibase.h",
"Order Form": "bitcoin/src/uibase.h",
"getdetails": "bitcoin/src/ui.cpp",
"-- CAN'T CONNECT TO SELLER --": "bitcoin/src/ui.cpp",
"Reviews:
": "bitcoin/src/ui.cpp",
"Please select a rating ": "bitcoin/src/ui.cpp",
"publish": "bitcoin/src/net.h",
"pub-cancel": "bitcoin/src/net.h",
"subscribe": "bitcoin/src/net.cpp",
"sub-cancel": "bitcoin/src/net.cpp",
"review": "bitcoin/src/net.h",
"product": "bitcoin/src/net.h",
"reviews.dat": "bitcoin/src/db.h",
}
EXPECTED_COMMANDS = [
"version", "addr", "inv", "getdata", "getblocks", "tx", "review",
"block", "getaddr", "checkorder", "submitorder", "reply",
]
def sha256(data):
return hashlib.sha256(data).hexdigest()
def file_record(path, expected):
data = path.read_bytes()
assert len(data) == expected[0], (path, len(data))
assert sha256(data) == expected[1], (path, sha256(data))
return {"filename": path.name, "bytes": len(data), "sha256": sha256(data)}
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--archive", type=Path, default=DEFAULT_ARCHIVE)
parser.add_argument("--rar", type=Path, default=DEFAULT_RAR)
parser.add_argument("--output", type=Path, default=ROOT / "evidence.json")
args = parser.parse_args()
archive_record = file_record(args.archive, EXPECTED_TGZ)
archive_record["url"] = "https://www.zorinaq.com/pub/bitcoin-0.1.0.tgz"
rar_record = file_record(args.rar, EXPECTED_RAR)
rar_record["url"] = "https://www.zorinaq.com/pub/bitcoin-0.1.0.rar"
rar_record["role"] = "Hash-matched RAR companion; content relationship is established by the case's confirmed provenance work, not reparsed here."
files = {}
with tarfile.open(args.archive, "r:gz") as tf:
for member in tf.getmembers():
if member.isfile():
files[member.name] = tf.extractfile(member).read()
assert len(files) == 48, len(files)
assert sum(map(len, files.values())) == 9_291_155
for name, expected_hash in EXPECTED_MEMBERS.items():
assert name in files, name
assert sha256(files[name]) == expected_hash, name
manifest = [
{"member": name, "bytes": len(data), "sha256": sha256(data)}
for name, data in sorted(files.items())
]
def snippet(check_id, name, first, last, needles):
lines = files[name].splitlines(keepends=True)
raw = b"".join(lines[first - 1:last])
text = raw.decode("utf-8")
for needle in needles:
assert needle in text, (check_id, needle)
return {
"id": check_id, "member": name,
"line_start": first, "line_end": last,
"byte_start": sum(map(len, lines[:first - 1])),
"byte_end": sum(map(len, lines[:last])),
"bytes": len(raw), "sha256": sha256(raw), "text": text,
}
excerpts = [snippet(*row) for row in SNIPPETS]
source_names = sorted(n for n in files if n.startswith("bitcoin/src/") and n.endswith((".cpp", ".h")))
# Latin-1 gives a lossless one-byte-to-one-code-point view for ASCII scans;
# a few unrelated source comments contain non-UTF-8 bytes.
source_text = {n: files[n].decode("latin-1") for n in source_names}
combined = "\n".join(source_text.values())
main_cpp = source_text["bitcoin/src/main.cpp"]
commands = re.findall(r'\bstrCommand\s*==\s*"([^"]+)"', main_cpp)
assert commands == EXPECTED_COMMANDS, commands
assert main_cpp.count("bool ProcessMessage(") == 1
assert source_text["bitcoin/src/main.h"].count("bool ProcessMessage(") == 1
def refs(symbol):
pattern = re.compile(r"\b" + re.escape(symbol) + r"\b")
found = []
for name, text in source_text.items():
for number, line in enumerate(text.splitlines(), 1):
if pattern.search(line):
found.append({"member": name, "line": number, "text": line.strip()})
return found
product_dialog_refs = refs("CProductsDialog")
review_dialog_refs = refs("CEditReviewDialog")
assert {r["member"] for r in product_dialog_refs} == {"bitcoin/src/ui.cpp", "bitcoin/src/ui.h"}
assert {r["member"] for r in review_dialog_refs} == {"bitcoin/src/ui.cpp", "bitcoin/src/ui.h"}
absence_checks = {
"new CProductsDialog occurrences": combined.count("new CProductsDialog"),
"new CEditReviewDialog occurrences": combined.count("new CEditReviewDialog"),
"Subscribe(MSG_PRODUCT) calls": len(re.findall(r"\bSubscribe\s*\(\s*MSG_PRODUCT\b", combined)),
}
assert all(value == 0 for value in absence_checks.values()), absence_checks
missing_handlers = ["product", "publish", "pub-cancel", "subscribe", "sub-cancel", "getdetails"]
assert not (set(missing_handlers) & set(commands))
exe = files["bitcoin/bitcoin.exe"]
runs = [(m.start(), m.group()) for m in re.finditer(rb"[\x20-\x7e]{4,}", exe)]
pe_strings = []
for token, source_member in PE_STRING_SOURCES.items():
raw = token.encode("ascii")
assert raw in files[source_member], token
matches = [
{"byte_offset": offset, "bytes": len(raw), "sha256": sha256(raw)}
for offset, value in runs if value == raw
]
assert matches, token
pe_strings.append({"text": token, "source_member": source_member, "exe_occurrences": matches})
evidence = {
"format": "findsatoshi.version-zero-point-one.marketplace-static-evidence.v1",
"case_id": "version-zero-point-one",
"finding": "The surviving hash-matched Bitcoin v0.1.0 archive contains a compiled-in but hidden and incomplete marketplace/review subsystem, not just a cash client.",
"scope": "Static analysis of the surviving 2012-hosted 0.1.0 archive (VERSION 101). No claim is made about the January 8 launch-day bytes, actual marketplace use, or author intent.",
"sources": {"tgz": archive_record, "rar": rar_record},
"archive_integrity": {"regular_files": len(files), "total_regular_file_bytes": sum(map(len, files.values())), "manifest": manifest},
"component_findings": [
{"finding": "Both supported makefiles compile market.cpp and link its object into bitcoin.exe.", "evidence": ["build-market-object", "build-linked-into-exe", "vc-build-market-object", "vc-build-linked-into-exe"]},
{"finding": "Products have signatures, seller addresses, summary/detail maps and custom order forms; reviews have signatures and atom/link ranking machinery.", "evidence": ["review-and-product-model", "user-atom-model", "signed-review-and-link-propagation", "signed-product-and-ranking"]},
{"finding": "UI code covers catalog search, product publication, seller-detail requests, reviews, custom orders and a payment handoff using product.addr and price.", "evidence": ["product-search-and-display", "sign-and-publish-product", "request-product-details", "product-reviews-display", "order-form-to-payment", "sign-and-relay-review"]},
{"finding": "Review inventory/relay receive logic and order/payment handlers exist, alongside product inventory types and publish/send templates.", "evidence": ["inventory-types", "publish-send-template", "product-inventory-check", "review-receive-handler", "order-payment-handlers"]},
{"finding": "The marketplace is unfinished: main-window product/order panels are hidden and their columns are commented out; no CProductsDialog or CEditReviewDialog construction site or MSG_PRODUCT subscription call occurs in shipped C++ source.", "evidence": ["hidden-order-and-product-panels", "commented-main-window-market-columns"], "absence_checks": absence_checks, "CProductsDialog_references": product_dialog_refs, "CEditReviewDialog_references": review_dialog_refs},
{"finding": "The sole ProcessMessage dispatcher has no product, publish, pub-cancel, subscribe, sub-cancel or getdetails receive handler. Thus the source does not support calling this a working marketplace.", "commands_present": commands, "handlers_absent": missing_handlers},
],
"source_excerpts": excerpts,
"binary_corroboration": {"member": "bitcoin/bitcoin.exe", "bytes": len(exe), "sha256": sha256(exe), "method": "ASCII runs of four or more printable bytes, matched in full; offsets are zero-based in the PE file.", "strings": pe_strings},
"limits": [
"No executable or archived code was run; no network messages were sent.",
"PE strings corroborate compiled shipment; they are not used alone to infer functionality.",
"The missing receive paths and UI entry points delimit the finding to an incomplete subsystem.",
"This is new relative to the preserved case brief and confirmed-lead snapshots, not a claim of worldwide first discovery.",
],
}
encoded = (json.dumps(evidence, indent=2, ensure_ascii=False) + "\n").encode("utf-8")
args.output.write_bytes(encoded)
print("PASS: exact archives, 48-member manifest, source excerpts, absence checks and PE strings verified")
print("messages handled:", ", ".join(commands))
print("output:", args.output)
print("bytes:", len(encoded))
print("sha256:", sha256(encoded))
if __name__ == "__main__":
main()