Repository navigation
feat(runtime): memos declare their format in the shielded pool, enforced from an admin-scheduled block (spec 23, v0.9.0) - #193
Merged
Conversation
…ced from an admin-scheduled block (spec 23, v0.9.0)
… unmaintained 0543, no fix upstream
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
Memos in the shielded pool can now be required to declare how their owner finds them, so wallets can stop trial-decrypting notes that cannot be theirs. Nonce byte 1 of a memo is its format:
0x01TAGGED (found by lookup of a tag the owner knows in advance) or0x02HANDSHAKE (found by trial ECDH, as every memo before). An admin schedules the block the rule starts at; from then on a memo without a declared format is refused. Nothing changes until the rule is scheduled.Runtime spec 23 (tx 8 unchanged), v0.9.0,
pallet-shielded-pool0.28.0. No storage migration: the new values start empty.Added
schedule_tagged_memos(from)(call index 21,AdminOrigin): setsTaggedMemosFromand emitsTaggedMemosScheduled.frommust be a future block (TaggedMemosStartInPast).TaggedMemosAlreadyActive), even before the leaf is recorded.SCHEDULE_READS).TaggedMemosFromLeaf: recorded once, in theon_initializeof the first block at or pastTaggedMemosFrom, as the next leaf index; never changed after. Every leaf from it on was inserted under the rule. EmitsTaggedMemosActivated.MemoFormatandEncryptedMemo::format(): the format a full 180-byte memo declares,Nonefor any other byte or a memo that is not full size.MEMO_FORMAT_OUTDATED(Custom(15)): an unsigned spend carrying an undeclared memo is refused at admission. The check runs after fee, root and nullifiers and before the proof.Changed
shield_batchincluded), private transfer, unshield change and bound-spend change go throughoperations::memo_format::ensure_storable. It checks sizes first (InvalidMemoSize), then the format while the rule is in force (MemoFormatOutdated), before the proof is verified.on_initializereads one or two more storage values per block (three reads and two writes in the block that records the leaf), charged on top of the prune batch.Not in this PR
The benchmarked weights of shield,
shield_batch, private transfer, unshield and bound spend do not count the 1–2 extra reads of the format check. That is small next to proof verification, and the next benchmark run will pick it up; adding it by hand would count it twice.Testing
cargo test -p pallet-shielded-pool: 434 passed, 0 failed;cargo clippy -p pallet-shielded-pool --all-targets: no warnings.on_initializebefore any extrinsic, so no call straddles it.pre_dispatchin the start block; one undeclared memo refuses a wholeshield_batch; unshield change; the format checked after nullifiers.0x01; transfer payment is0x02and change0x01; full scans find the same notes with tagged leaves skipped.ed25519_text_vectors.json, mirrored in ts-protocol).