refactor(types)!: 1.0 naming and conversion conventions - #247
Merged
Merged
Conversation
`from_bytes` meant three different things across the digest types, and `Sha512Hash` lacked most of what `Sha256Hash` offered (#193 review). - Generate `Sha256Hash` and `Sha512Hash` from one macro so they share an API: `new([u8; N])`, `TryFrom<&[u8]>`, hex and base64 parsing and encoding, serde, `Display`/`FromStr` (hex), conversions to and from `DigestBytes`, and comparisons with byte slices, arrays and vectors. - Replace `try_from_slice` on `Sha256Hash`, `Sha512Hash` and `KeyHint` with `TryFrom<&[u8]>`. - `DigestBytes::from_bytes(Vec<u8>)` becomes `DigestBytes::new`, and gains `into_bytes`, `len`, `is_empty`, `to_hex`, `From<Vec<u8>>` and `Display`. - `KeyHint` implements `Display` (hex). BREAKING CHANGE: `Sha256Hash::from_bytes`, `Sha512Hash::from_bytes` and `DigestBytes::from_bytes` are renamed to `new`; `try_from_slice` is replaced by `TryFrom<&[u8]>`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Wolf Vollprecht <w.vollprecht@gmail.com>
- `HashAlgorithm` implements `FromStr` (accepting the protobuf-specs, Rekor and hyphenated spellings) instead of `from_str_flexible -> Option`, and derives `Hash`. `as_lowercase` is renamed `as_rekor_str`. The stringly-typed `oid()` is removed. - `MediaType` implements `AsRef<str>` instead of `Deref<Target = str>`. - `Bundle::version()` is renamed `media_type()`, which is what it returns. - Remove the unused `BundleVersion` enum, `DsseEnvelope::decode_payload` (it only cloned the payload) and the "backwards compatibility" `hash::base64_bytes` re-export. - `DsseEnvelope::new` takes `impl Into<String>` for the payload type. BREAKING CHANGE: `HashAlgorithm::from_str_flexible` and `oid` are removed (use `str::parse`); `as_lowercase` is `as_rekor_str`; `MediaType` no longer derefs to `str`; `Bundle::version` is `Bundle::media_type`; `BundleVersion`, `DsseEnvelope::decode_payload` and `sigstore_types::hash::base64_bytes` are removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Wolf Vollprecht <w.vollprecht@gmail.com>
`LogIndex::value()` is renamed `get()`, and `LogIndex` gains `From<LogIndex> for u64`, `TryFrom<i64>` (rejecting negative indices) and `FromStr`, so callers need not convert through raw integers. BREAKING CHANGE: `LogIndex::value` is renamed `LogIndex::get`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Wolf Vollprecht <w.vollprecht@gmail.com>
The public `base64_bytes`, `base64_bytes_option`, `hex_bytes`, `string_u64`, `string_timestamp_opt` and `hash::hash_algorithm_lowercase` modules were implementation details, but as public items they were part of the API. - `string_u64` and `string_timestamp_opt` are crate-private. - `base64_bytes`, `base64_bytes_option` and `hex_bytes` are removed. The only external user, the Rekor v2 `digest` fields, now use `DigestBytes`, which serializes as base64 itself. - `hash_algorithm_lowercase` moves into sigstore-rekor, its only user. BREAKING CHANGE: the serde helper modules are no longer exported from sigstore-types; Rekor v2 body `digest` fields are `DigestBytes` instead of `Vec<u8>`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Wolf Vollprecht <w.vollprecht@gmail.com>
`HexLogId` and `HexHash` model the Rekor v1 API's hex strings and are
only used by sigstore-rekor, so they don't belong in the shared types
crate. Move them to `sigstore_rekor::hex_encoded` (re-exported at the
crate root).
- `from_bytes` (which hex-encoded) is renamed `encode`.
- `HexLogId::to_base64() -> Result<String>` becomes
`to_log_key_id() -> Result<LogKeyId>`, the bundle's typed
representation.
- `new` takes `impl Into<String>`.
BREAKING CHANGE: `sigstore_types::{HexLogId, HexHash}` moved to
`sigstore_rekor::{HexLogId, HexHash}`; `from_bytes` is `encode`, and
`HexLogId::to_base64` is replaced by `to_log_key_id`.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Wolf Vollprecht <w.vollprecht@gmail.com>
Neither is validated: Rekor has used several UUID formats, and DSSE leaves key IDs to the signer. Say so, and take impl Into<String> in their constructors. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Wolf Vollprecht <w.vollprecht@gmail.com>
jku
approved these changes
Sep 25, 2026
jku
left a comment
Member
There was a problem hiding this comment.
Looks great, thanks!
1.0 API work: T-b and T-c from the plan folded into one PR,
these are a bit annoying in PRs when I don't think I've seen the plan.
Merged
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.
Summary
1.0 API work: T-b and T-c from the plan folded into one PR, one commit per theme. It's best reviewed commit by commit.
Digests (
c6f8786):Sha256HashandSha512Hashare generated from one macro, so they share an API (Jussi's refactor(types)!: deserialize semantic bundle values eagerly #193 comment aboutSha512Hashparity):new,TryFrom<&[u8]>Display/FromStr(hex)DigestBytesconversions and comparisonstry_from_slicebecomesTryFrom<&[u8]>(also onKeyHint), andDigestBytes::from_bytesbecomesnew, gaininginto_bytes,len,to_hexandDisplayEnums (
4820781):HashAlgorithm: FromStr + Hashreplacesfrom_str_flexible,as_lowercasebecomesas_rekor_str, and the stringlyoid()is removedMediaType: AsRef<str>replacesDeref<Target = str>, andBundle::version()becomesmedia_type()BundleVersionandDsseEnvelope::decode_payloadLogIndex (
98e0ea5):value()becomesget(), plusFrom<LogIndex> for u64,TryFrom<i64>andFromStrSerde helpers (
9471cc4): the helper modules are no longer public API. The unused ones are removed, the Rekor v2digestfields becomeDigestBytes, and the Rekor-only hash-algorithm helper moves to rekorRekor v1 encodings (
07d2492, T-c):HexLogId/HexHashmove tosigstore_rekor.from_bytesbecomesencode, andHexLogId::to_base64() -> Stringbecomesto_log_key_id() -> LogKeyIdDocs:
EntryUuidandKeyIdare documented as opaque, unvalidated identifiers. That leaves room to add a validating parser later without breakingnewValidation
cargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace --all-features --no-fail-fast(new tests:Sha512Hashparity,LogIndexconversions,HexLogId::to_log_key_id)cargo check --no-default-featuresfor types and rekorSigned-off-by: Wolf Vollprecht w.vollprecht@gmail.com
🤖 Generated with Claude Code