tor: add OnionAddress::from_origin_pubkey (pubkey -> address)#13
Merged
Conversation
…0.9.0 The crate could decode and strictly verify a Tor v3 onion address but had no public way to derive an address from an origin public key. A publisher building a manifest origin needs that direction. Add OnionAddress::from_origin_pubkey, the exact inverse of verify_strict: it computes the SHA3-256 checksum, encodes pubkey||checksum||version as lowercase base32 per rend-spec-v3, and appends .onion. Tests cover the encode/verify_strict round trip and the canonical corpus origin fixture (Gp8y4JM7... -> dkptfyeth...onion), confirming the output matches an independent encoder byte for byte. Additive public API; bump the crate 0.8.0 -> 0.9.0. Spec revision is unchanged (rc.48).
CI builds with --locked, which rejects a Cargo.lock that disagrees with Cargo.toml. The 0.8.0 -> 0.9.0 bump updated the manifest but not the lock, so every --locked job failed. Sync the lock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The crate could decode and strictly verify a Tor v3 onion address (
OnionAddress::decode/verify_strict) but had no public way to derive an address from an origin public key. A publisher building a manifest origin needs that direction; without it, callers must reimplement the Tor v3 base32+checksum encoding themselves.Add
OnionAddress::from_origin_pubkey, the exact inverse ofverify_strict: it computes theSHA3-256(".onion checksum" || pubkey || version)[:2]checksum, encodespubkey || checksum || versionas lowercase base32 per rend-spec-v3, and appends.onion.Tests:
verify_strictreturns the same pubkey, a valid checksum, and version 0x03.Gp8y4JM7...derives todkptfyeth...onion, matching the corpus generator's independent encoder byte for byte.Additive public API; crate version 0.8.0 -> 0.9.0. Spec revision unchanged (rc.48). fmt, clippy -D warnings, doc -D warnings, and the full test suite are green.