Repository navigation
Conversation
…t later Commits to the facts of one invocation (target, function, arguments, result, ledger) with a domain-separated SHA-256 preimage, stores the receipt under the caller's address behind require_auth, and recomputes the same 32 bytes in a pure function so a verifier does not have to trust a call to the contract. Nine tests: the happy path, a tamper case per committed field, the content-addressed property across two callers, per-caller indexing, and one test that anchors without mocking authorization. Refs stellar#433
run fmt/clippy here the way the Rust workflow does. That reformatted several call sites in test.rs, and clippy was right that result is Copy so the clone in anchor was redundant. Also adds the one-line entry to the example list.
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.
Draft, because #433 is still open and one naming question in it is unanswered. The code itself is finished and tested; the draft is about the name and the interface, not about whether it works.
What it is
One contract, five entry points.
anchorcommits to the facts of a single invocation and stores the receipt under the caller's address;commitmentrecomputes the same 32 bytes in a pure function, so a verifier never has to trust a call to the contract.The domain prefix means a commitment made here cannot be confused with a hash of the same data computed for another purpose, and the two component hashes are fixed-width, so no two different tuples can collide by shifting a boundary in the preimage.
anchor(caller, target, fn_name, args, result, ledger)caller.require_auth(), compute, store, return the commitmentcommitment(target, fn_name, args, result, ledger)verify(receipt, args, result)falseon any mismatchreceipt(caller, index)/count(caller)It moves no funds and grants no authority. It records what an invocation did, not whether it should have happened.
Verification
Run in this branch's tree, Rust 1.100.0,
stellar-cli30.0.1:The nine: the happy path, one tamper case per committed field (args incl. order and length, result, ledger, target, function name), the content-addressed property across two different callers, per-caller indexing, and one test that calls
anchorwithout mocking authorization and expects it to fail.Note: soroban-sdk 28 no longer builds for
wasm32-unknown-unknown; the Makefile usesstellar contract build, which targetswasm32v1-nonelike the rest of the examples.Cargo.lockis not in this commit —cargowrites it on first build.Open question from #433
receipt-anchororcommitment-anchor, and shouldargs/resultstayVal(works for any invocation, canonical XDR) or beBytes-only (narrower, easier to verify outside Rust)? Happy to rename or narrow before this leaves draft.Refs #433