examples: add signed tool receipts#3565
Conversation
Signed-off-by: tommylauren <tfarley@utexas.edu>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 430ace4398
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| def verify_receipt_chain(self) -> bool: | ||
| previous_hash: str | None = None | ||
| public_key: Ed25519PublicKey = self.verify_key |
There was a problem hiding this comment.
Bind the embedded public key to verification
When the printed receipt JSON is archived or transferred for later verification, signature.public_key is the receipt’s only signer identifier, but it is excluded from the signed payload/hash and this verifier never checks it against the trusted key. As a result, changing signature.public_key in any emitted receipt still leaves verify_receipt_chain() returning true, so the example can validate receipts that misidentify who signed them; either include the signer key ID in the signed payload or explicitly reject receipts whose embedded key differs from the verifier key.
Useful? React with 👍 / 👎.
|
Thanks for sharing this idea. While we won't add this example within this repo, please feel free to share it in your own repo or any other resources. |
Summary
RunHooks.on_tool_startandRunHooks.on_tool_endto emit signed receipts around local tool calls.previous_receipt_hash.This is examples-only and does not change SDK runtime behavior. The example uses the existing optional
cryptographydependency surface for Ed25519 signing.Verification
python3 -m ruff format examples/basic/signed_tool_receipts.pypython3 -m ruff check examples/basic/signed_tool_receipts.pypython3 -m py_compile examples/basic/signed_tool_receipts.py