Repository navigation
feat(sha256): add BIP340 tagged hash fragment - #68
Conversation
|
Review: hold pending the changes below. Integrate this with the SHA256 midstate work in #67/#82. The tag is known at generation time, so precompute the midstate after the constant 64-byte tag block instead of paying for that compression again in Script. Reproduce the tagged-hash vectors and measure the final whole fragment after this change. Historical local validation (September 11, at this unchanged PR head): Rebase on current main, address the specific gaps above, and run the affected correctness and active metric checks. Broad/full-repository runs are not requested. Reviewed commit: |
df12eb7 to
b579a2c
Compare
|
Updated and rebased on #67 as commit b579a2c.\n\n- Reuses the midstate continuation machinery without changing the public 80-byte/640-bit contract.\n- Precomputes the chaining state after the 64-byte BIP340 tag block with the production bitcoin SHA-256 engine; the Script fragment now consumes only the 32-byte message and uses the correct 768-bit final length.\n- Adds independent tagged-hash vectors for multiple tags and messages containing 0x00, 0x7f, 0x80, and 0xff, plus strict wrong-message-count rejection. The API is BIP340-style tagged hashing of a payload, not the complete nonce-and-pubkey BIP340 challenge.\n- Re-measures the final whole fragment: 530,755 locking-script bytes, 65-byte fixture witness / 97-byte canonical maximum, 856-item strict composition peak, zero hints. The fragment is reported unoptimized and deployment remains unclassified.\n- Updates the README, knowledge page, comparison, catalog, and active metric coverage.\n\nValidation: 16 affected SHA-256 library tests passed; cargo test --locked --test primitive_metrics passed (107 passed, 1 ignored); python3 tools/kb.py validate passed; cargo fmt --all -- --check passed; git diff --cached --check passed.\n\nThis branch is stacked on #67 and should be reviewed after #67's consolidated midstate changes. |
…PIs, resolve NR-064 collision Rebases the RIPEMD-160/SHA-1/SHA-256 output-prefix adapters over the SHA256 midstate-continuation and BIP340 tagged-hash APIs merged into main via solving-bitcoin#67/solving-bitcoin#68 (and the further 27-PR integration in solving-bitcoin#244). Resolves conflicts in knowledge/catalog.json, knowledge/comparisons/hashes.md, knowledge/negative-results/index.md, knowledge/primitives/sha256-u32.md, src/arithmetic/u4/mod.rs, src/hashes/ripemd160/mod.rs, src/hashes/sha1/mod.rs, src/hashes/sha256/README.md, src/hashes/sha256/sha2_u4.rs, and tests/primitive_metrics.rs by keeping both API families: main's sha256_80bytes_from_midstate/sha256_tagged_hash_32bytes plus this PR's sha256_prefix/ripemd160_prefix/sha1_prefix adapters, with matching catalog records, README rows, and primitive_metrics entries on both sides. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Summary
SHA256(tag_hash || tag_hash || message)over a 32-byte messageValidation
cargo test --locked --lib hashes::sha256::sha2_u32::testscargo test --locked --test primitive_metricspython3 tools/kb.py validatecargo fmt --checkgit diff --checkThe full repository test suite was not run; this PR is scoped to the SHA-256 primitive and its metric/documentation surface.