{
  "component": "candidate-check",
  "objectiveStatus": "INCOMPLETE",
  "baseCommit": "aebd9183af6a4b1643ddd1e71277f0e8166f3eda",
  "summary": "Added candidate-check/: an independent, offline, standard-library-only verifier that reads exactly 32 big-endian candidate bytes from --candidate-fd and reports only booleans and public hashes for the fixed Puzzle #140 manifest (interval [2^139, 2^140-1], compressed public key 031f6a33...0d6640, P2PKH address 1QKBaU6WAeycb3DbKbLBkX7vJiaS8r42Xo). No key was searched for, recovered or verified; no payment was made. A passing synthetic test is not a recovered #140 key.",
  "files": [
    {"path": "candidate-check/candidate_check.py", "sha256": "75d291e72c0ce369114613e12e394e493d6cdc6a3e92102baa965542c90d2926", "role": "production command and in-process API; fixed manifest, no overrides"},
    {"path": "candidate-check/cc_core.py", "sha256": "ec1927f1a3c0f8236246c0d71aa34449fa314a02905500363ceb38c7183aec64", "role": "evaluation, descriptor reading, report building, fixed error codes, exit discipline"},
    {"path": "candidate-check/cc_primitives.py", "sha256": "6e881b9fd6d328104b85ae95df57ad1bedaa4d3fc8f8e532a05077d4be4730fe", "role": "separately written secp256k1 (Jacobian double-and-add plus affine Montgomery ladder with a different inverse), SEC1 encode/decode, pure-Python RIPEMD-160, Base58Check"},
    {"path": "candidate-check/synthetic_api.py", "sha256": "dc6a6f2cf45c07c10ec2c606eaaa593c0aa256625cbb5f9fc91f11ef4bc7b80c", "role": "separate synthetic-test API and command; refuses the production key/address"},
    {"path": "candidate-check/tests/test_candidate_check.py", "sha256": "d1947be3196f8f90e86dca3be697d04e79ab4b7a1b8ba7103333661619f7cead", "role": "40 offline unittest cases"},
    {"path": "candidate-check/README.md", "sha256": "5aca929c0e56821aff6f5c59454c16bfe969d65d2b3b03af049edcd06a6073d3", "role": "commands, output contract, claim-integration interface, limits"},
    {"path": "candidate-check/SHA256SUMS", "role": "sha256 of the six files above"}
  ],
  "publicHashes": {
    "manifest_sha256": "15cad4c3c92f31e8a60e6a85b11dd6044201209e0060d48248e260a920e6f048",
    "source_bundle_sha256": "1fce4ebb6478341b1c16a50de49c6dc803bfa1ed2d90ca43b760d3a17783a091",
    "note": "manifest_sha256 is the SHA-256 of the canonical JSON of the fixed public manifest; source_bundle_sha256 covers the four source files. Both are printed by every report and pinned in README.md."
  },
  "interface": {
    "command": "python3 -I -B candidate-check/candidate_check.py --candidate-fd N   (N = 0 or >= 3; exactly 32 raw big-endian bytes then EOF; terminals and descriptors 1/2 refused)",
    "otherOptions": ["--manifest (public manifest and hashes, no candidate)", "--help"],
    "exitStatus": {"0": "all checks true", "1": "at least one check false, including a descriptor that did not deliver exactly 32 bytes", "2": "usage or descriptor error, fixed usage text on stderr", "3": "internal error or failed known-answer self-test, stderr empty"},
    "stdout": "one line of canonical JSON: component, schema, mode, manifest_sha256, source_sha256, source_bundle_sha256, scope, candidate_verified, production_candidate_verified, checks{descriptor_exact_32_bytes, scalar_valid, scalar_in_interval, public_key_match, p2pkh_address_match}; errors carry a code from a fixed list instead of checks",
    "inProcess": "candidate_check.verify_production_candidate(candidate: bytes|bytearray) -> report dict; candidate_check.verify_production_candidate_fd(fd) -> report dict. Neither takes a target.",
    "claimGate": "proceed only when exit status is 0 and production_candidate_verified is true and mode is PRODUCTION and manifest_sha256 and source_bundle_sha256 equal the pinned values",
    "syntheticApi": "synthetic_api.make_challenge(label, scalar, lower, upper), parse_challenge(descriptor), check_synthetic_candidate(candidate, descriptor), check_synthetic_candidate_fd(fd, descriptor); command: python3 -I -B candidate-check/synthetic_api.py --challenge-file PATH --candidate-fd N. Reports always say mode SYNTHETIC and production_candidate_verified false."
  },
  "commands": [
    {"purpose": "offline integrity check", "command": "(cd candidate-check && sha256sum -c SHA256SUMS)", "ran": true, "result": "6 files OK, exit 0"},
    {"purpose": "offline tests", "command": "python3 -B -m unittest discover -s candidate-check/tests -p 'test_*.py' -v", "ran": true, "result": "Ran 40 tests in 8.517s, OK, exit 0"},
    {"purpose": "public manifest and hashes", "command": "python3 -I -B candidate-check/candidate_check.py --manifest", "ran": true, "result": "exit 0; manifest_sha256 and source_bundle_sha256 as in publicHashes"},
    {"purpose": "entrant-private verification (private machine only; CANDIDATE_FILE is an entrant-chosen path to 32 raw bytes)", "command": "cd candidate-check && sha256sum -c SHA256SUMS && python3 -I -B candidate_check.py --manifest && python3 -I -B candidate_check.py --candidate-fd 3 3< \"$CANDIDATE_FILE\"; echo \"exit=$?\"", "ran": "only with a labelled synthetic non-matching 32-byte file in the task temp directory", "result": "exit 1, public_key_match false, stderr empty"},
    {"purpose": "entrant-private verification from a private producer", "command": "\"$PRIVATE_PRODUCER\" | python3 -I -B candidate-check/candidate_check.py --candidate-fd 0; echo \"exit=$?\"", "ran": "only as cat of the same synthetic file", "result": "exit 1, identical output"}
  ],
  "tests": {
    "implemented": [
      "fixed-manifest production command and in-process API with no target argument, option, environment variable or file override",
      "two independent scalar multipliers that must agree, SEC1 compressed encode/decode, pure-Python RIPEMD-160, Base58Check, P2PKH derivation",
      "known-answer self-test before any candidate is read; failure exits 3",
      "separate synthetic-test API and command that refuse the production public key (either parity) and address",
      "fixed-code errors, silent exception hooks, os._exit termination, best-effort buffer wipe and core-dump disable"
    ],
    "tested": [
      "published curve vectors k=1,2,3,7,112233445566778899,n-2,n-1 by both multipliers; the values were also read from the published list at chuckbatson.wordpress.com/2014/11/26/secp256k1-test-vectors during this task",
      "RIPEMD-160 specification vectors, plus agreement with hashlib ripemd160 at block-boundary lengths",
      "known compressed P2PKH addresses for the long-public puzzle keys 1,3,7,8,21",
      "production interval boundaries 2^139-1, 2^139, 2^139+1, 2^140-2, 2^140-1, 2^140 (in-process and by command) with public_key_match false",
      "synthetic challenges whose key sits at lower-1, lower, upper, upper+1, including keys exactly 2^139 and 2^140-1 with the production interval: all-true path, mode SYNTHETIC, production_candidate_verified false",
      "invalid scalars 0, n, n+1, 2^256-1; invalid points (x with no root, x>=p, prefixes 00/04/05, wrong lengths); Base58Check corruption",
      "endianness: little-endian and byte-reversed encodings fail",
      "descriptor truncation: 0, 1, 31, 33, 64 bytes, trailing newline, hex text, chunked pipe delivery, regular file descriptor; truncated, empty, oversized, wrong-type and missing-field challenge descriptors and files",
      "leak tests over stdout, stderr and exit status for a synthetic secret sentinel: match, mismatch, truncated, overlong, secret pasted into argv or as the fd value, 11 injected exceptions (including KeyboardInterrupt, SystemExit, MemoryError) whose text contains the sentinel, and an unwritable stdout (/dev/full). Forbidden forms: raw bytes, hex in both cases and byte orders, decimal, base64, WIF compressed/uncompressed, repr forms, derived x/y/address/hash160, and 16-hex/12-digit windows; a control test shows the detector flags each form",
      "output for two different candidates with equal booleans is byte-identical; noisy environment gives identical output; in-process failure raises a fixed-text refusal with no chained exception",
      "sources import only the standard library and each other; SHA256SUMS and the README pins match the files"
    ],
    "independentCrossChecks": "In test/scratch (not delivered): x,y for 17 scalars (the published ones, the four interval-edge values and 6 labelled synthetic 256-bit values) matched `cast wallet public-key` and `openssl ec`: 17 of 17 each.",
    "mutationChecks": "On scratch copies: printing exception text in the top-level handler, an off-by-one interval, little-endian decoding and accepting short candidates each made the behaviour tests fail (test_injected_exceptions_carry_nothing_out; boundary tests; endianness tests; truncation tests). Removing the inner fixed-refusal wrapper alone was not caught by the earlier suite because the outer handler still printed nothing; test_in_process_failure_is_a_fixed_refusal_without_chained_exception was added for it.",
    "failures": [],
    "defectFoundAndFixed": "The first self-test run failed: the 2G known-answer constant I had typed contained one wrong hex digit (...8e4a8c... for ...8e4b8c...). Corrected against the published list, cast and openssl.",
    "untested": [
      "the production command's all-true path with the real key (the key is unknown; the all-true path is exercised only through the synthetic API, which shares evaluate/build_report/emit code)",
      "Python versions other than 3.12.3 (code targets 3.8+)",
      "non-Linux platforms (the /dev/full test is skipped where absent)",
      "terminal refusal for --candidate-fd on a tty (no tty in this run)"
    ],
    "unavailable": ["real Puzzle #140 key", "entrant-controlled private machine", "GPU or search compute (not needed by this component)"]
  },
  "measurements": [
    {"name": "production command wall time, synthetic non-matching in-range candidate, self-test included", "median": 83.5, "min": 70.8, "max": 104.4, "unit": "ms", "runs": 20},
    {"name": "peak resident set size of the command process", "value": 16896, "unit": "KiB"},
    {"name": "multiply_checked (both multipliers) per call", "value": 9.95, "unit": "ms", "runs": 50},
    {"name": "evaluate per candidate, in-process", "value": 11.47, "unit": "ms", "runs": 50},
    {"name": "test suite", "value": 8.517, "unit": "s", "tests": 40},
    {"name": "environment", "device": "unknown (no task-supplied device label)", "runtime": "CPython 3.12.3, x86_64, single process"}
  ],
  "limits": [
    "Not constant time; Python cannot erase int/bytes copies of the scalar. Run secret-bearing checks only on an entrant-controlled private machine.",
    "Checks the candidate only: no UTXO lookup, transaction building, signing, broadcast or payment confirmation.",
    "An in-process caller that logs traceback locals could expose its own candidate buffer; the subprocess interface avoids this."
  ],
  "notDone": [
    "No real-target search or verification was run on this worker.",
    "No machine credentials, home, environment or configuration were read; private-state paths are entrant-supplied through shell redirection only.",
    "No file outside candidate-check/ was changed; no dependency, submodule or root configuration was added.",
    "The seven files are staged in the checkout but not committed: git commit was refused because the checkout has no author identity, and no configuration was changed to supply one."
  ],
  "blockers": [
    "Objective remains INCOMPLETE: no Puzzle #140 private key has been recovered, so there is nothing real to verify or claim."
  ],
  "restartCommand": "python3 -B -m unittest discover -s candidate-check/tests -p 'test_*.py' -v"
}
