Verify Litecoin Scrypt shares in conformance gate
main-release-gate / verify-and-release (push) Failing after 3m22s

This commit is contained in:
2026-10-15 21:04:52 -06:00
parent 31caf922b8
commit f6889940c3
3 changed files with 33 additions and 7 deletions
+6 -2
View File
@@ -18,7 +18,8 @@ The report references files under `ci/evidence/` with objects containing
`simulator_model`, `control_capture`, `chip_capture`,
`alkane_share_accept_capture`, and `bench_validation`.
The checker opens and hashes each file. It loads the trace and capture JSON,
checks the current run/image/cell identities, verifies SHA-256d nonces against
checks the current run/image/cell identities, verifies SHA-256d or Litecoin
Scrypt nonces against
a pool target at difficulty 1 or higher, and requires a matching
`mining.submit` and pool ACCEPT response ID. A SHA-256 capture must include
the matching `subscription` (`extranonce1`, `extranonce2_size`), full
@@ -29,7 +30,10 @@ The checker reconstructs
the coinbase, merkle root, and complete submitted header; its 80 bytes and
calculated difficulty target must match the capture. The trace binds
the capture digests.
Scrypt and Equihash share verifiers are pending, so those cells fail closed.
The Scrypt verifier uses [Litecoin's 80-byte, N=1024, r=1, p=1 proof hash](https://github.com/litecoin-project/litecoin/blob/master/src/crypto/scrypt.cpp).
Equihash proof verification remains pending, so its cells fail closed.
Scrypt cells also remain pending until real silicon reports, stock behavior,
and pool acceptance are captured for those chips.
Bench calibration names the physical control-board and chip devices, their
capture digests, and the simulator model digest. It can be reused across OS
commits until the model or a physical capture changes.
+10 -2
View File
@@ -149,8 +149,16 @@ def reconstructed_header(capture: dict, params: list[str]) -> tuple[bytes, int]:
return bytes(header), submitted_nonce
def proof_digest(header: bytes, algorithm: str) -> bytes:
if algorithm == "Sha256":
return hashlib.sha256(hashlib.sha256(header).digest()).digest()
if algorithm == "Scrypt":
return hashlib.scrypt(header, salt=header, n=1024, r=1, p=1, dklen=32)
raise ValueError(f"{algorithm} share verifier is not implemented")
def verify_accept(capture: dict, algorithm: str) -> None:
if algorithm != "Sha256":
if algorithm not in ("Sha256", "Scrypt"):
raise ValueError(f"{algorithm} share verifier is not implemented")
if capture.get("nonce_source") != "real_silicon_capture":
raise ValueError("share was not sourced from captured silicon")
@@ -204,7 +212,7 @@ def verify_accept(capture: dict, algorithm: str) -> None:
rebuilt, submitted_nonce = reconstructed_header(capture, params)
if submitted_nonce != nonce or rebuilt != header:
raise ValueError("submitted Stratum job differs from captured header")
hash_bytes = hashlib.sha256(hashlib.sha256(header).digest()).digest()
hash_bytes = proof_digest(header, algorithm)
if int.from_bytes(hash_bytes, "little") > target:
raise ValueError("captured nonce misses the pool target")
+17 -3
View File
@@ -64,9 +64,23 @@ class ConformanceGateTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError, "submitted nonce"):
gate.verify_accept(capture, "Sha256")
def test_non_sha256_cells_need_algorithm_specific_verifiers(self):
with self.assertRaisesRegex(ValueError, "Scrypt share verifier"):
gate.verify_accept({}, "Scrypt")
def test_scrypt_proof_matches_litecoin_and_independent_vectors(self):
header = bytes.fromhex(
"01000000f615f7ce3b4fc6b8f61e8f89aedb1d0852507650533a9e3b10b9bbcc30639f27"
"9fcaa86746e1ef52d3edb3c4ad8259920d509bd073605c9bf1d59983752a6b06b817bb4"
"ea78e011d012d59d4"
)
self.assertEqual(len(header), 80)
self.assertEqual(
gate.proof_digest(header, "Scrypt")[::-1].hex(),
"0000000110c8357966576df46f3b802ca897deb7ad18b12f1c24ecff6386ebd9",
)
self.assertEqual(
gate.proof_digest(bytes(range(80)), "Scrypt").hex(),
"bc540a1a801df96e493005c71e010e2d387607fbf0fec416fd3c2645aa1ba9d2",
)
def test_equihash_cells_still_need_an_algorithm_specific_verifier(self):
with self.assertRaisesRegex(ValueError, "Equihash share verifier"):
gate.verify_accept({}, "Equihash")