Align Go and Python prekey publish operation IDs with payload semantics#55
Merged
Merged
Conversation
Go derives the publish operation ID from the complete payload: the stable bundle ID plus a digest of the sorted OPK sidecar key IDs, so exact retries reuse the ID while a replenished OPK sidecar produces a new one instead of tripping the server idempotency check. Python now requires an explicit operation_id in PrekeyManager.publish_prekey_bundle, mirroring the Rust helper change in #54; internal callers pass op-publish-<bundle_id>, which identifies the bundle-only payload.
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
Follow-up to #54, which made the Rust prekey-bundle publish helper require an explicit
operation_id. This PR applies the same protocol rule — a publishoperation_ididentifies the complete publish payload, not only the stablebundle_id— to the Go and Python SDKs.PrekeyManager.PublishPrekeyBundlenow derives theoperation_idfrom the complete payload it assembles:op-publish-{bundle_id}for a bundle-only body, orop-publish-{bundle_id}-opks-{digest}when an OPK sidecar is present (digest = first 4 bytes of SHA-256 over the sorted OPK key IDs). The OPK sidecar comes from the manager's store, so callers cannot supply a payload-identifying ID themselves; deriving it inside the manager keeps exact retries idempotent while a replenished OPK sidecar gets a fresh ID and no longer trips the server'sanp.idempotency_conflict(per the idempotency rules inmessage/05-direct-end-to-end-encryption.md).PrekeyManager.publish_prekey_bundlenow requires an explicitoperation_idparameter, mirroring the Rust change in Require explicit operation IDs for prekey bundle publication #54. Internal callers (ensure_fresh_prekey_bundle, client) passop-publish-{bundle_id}, which identifies the bundle-only payload (the Python publish body carries no OPK sidecar).Compatibility
operation_idvalue changes when an OPK sidecar is present.publish_prekey_bundle(bundle, operation_id)requires the new argument.Validation
go vet ./direct_e2ee/andgo test ./direct_e2ee/ -count=1— pass, including a new test covering bundle-only / retry-reuse / OPK-replenishment operation ID behavior.pytest anp/unittest/direct_e2ee/— 4 passed, including a new test that the explicitoperation_idflows through and thatensure_fresh_prekey_bundlederivesop-publish-{bundle_id}.Pre-existing issues observed (not caused by this change)
TestSkippedMessageKeySurvivesFailedAuthentication(Go) is flaky on master; it passes on rerun.go run ./examples/direct_e2eefails on master withmissing field: serviceduring client construction, before any publish call.