Skip to content

feat(sinsemilla): accept a pre-decoded first word - #231

Open
ValarDragon wants to merge 2 commits into
mainfrom
agent/sinsemilla-first-word-20260827
Open

feat(sinsemilla): accept a pre-decoded first word#231
ValarDragon wants to merge 2 commits into
mainfrom
agent/sinsemilla-first-word-20260827

Conversation

@ValarDragon

@ValarDragon ValarDragon commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add UncheckedFixedLengthHashDomain::hash_with_first_word
  • accept an already-decoded first Sinsemilla word and decode only the remaining bit suffix
  • cover full 52-word parity and suffix zero-padding

Motivation

Orchard Merkle hashing already has its 10-bit level word as an integer, while its two 255-bit child encodings remain a bit string. The existing weighted API forces downstream users either to re-encode the level as bits or to duplicate the complete fixed-word decoder. This hybrid entry point keeps the layer word intact and leaves generic Sinsemilla word chunking inside zakura-sinsemilla, without adding Orchard-specific semantics to the crate.

Performance boundary

A release-mode comparison of 10,000 weighted evaluations was flat when the suffix bits were already available (103.4 ms through hash_words, 102.6 ms through hash_with_first_word). Replacing Orchard’s specialized byte decoder with a field-bit iterator was 2.1% slower in the existing orchard-merkle-combine benchmark (8.15 µs versus 7.98 µs), so this PR deliberately adds the missing API without changing Orchard’s optimized scalar or batch implementation.

Tests

  • cargo fmt --all -- --check
  • cargo test -p zakura-sinsemilla
  • cargo check -p zakura-sinsemilla --no-default-features

@ValarDragon
ValarDragon marked this pull request as ready for review August 27, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant