Skip to content

Commit e153c13

Browse files
committed
docs: add missing account_based and key_request pattern entries
1 parent efbabf4 commit e153c13

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

docs/content/ExamplePatterns.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ This section covers access control, not link generation. You can generate and di
5151

5252
[Move source](https://github.com/MystenLabs/seal/blob/main/move/patterns/sources/voting.move)
5353

54-
Use this pattern to run a vote where ballots stay encrypted until completion. You define eligible voters and each submits an encrypted choice. When all votes are in, anyone can fetch the required threshold keys from Seal and use the [on-chain decryption](https://seal-docs.wal.app/UsingSeal/#on-chain-decryption) to produce a verifiable tally. Invalid or tampered ballots are ignored. This pattern is useful for governance, sealed-bid auctions, or time-locked voting.
54+
Use this pattern to run a vote where ballots stay encrypted until completion. You define eligible voters and each submits an encrypted choice. When all votes are in, anyone can fetch the required threshold keys from Seal and use the [on-chain decryption](https://seal-docs.wal.app/UsingSeal/#on-chain-decryption) to produce a verifiable tally. Invalid or tampered ballots are ignored. This pattern is useful for governance, sealed-bid auctions, or time-locked voting.
55+
56+
## Account-based encryption
57+
58+
[Move source](https://github.com/MystenLabs/seal/blob/main/move/patterns/sources/account_based.move)
59+
60+
Use this pattern when you want to encrypt data to a specific Sui address. The key ID is derived directly from the recipient's address, so anyone can encrypt a message for address B, but only the owner of that address can decrypt it. There is no on-chain state to manage — access is determined entirely by address ownership. This pattern is a natural fit for end-to-end encrypted messaging, private notifications, or any scenario where you need to send encrypted data to a known recipient without setting up shared state first.
61+
62+
## Key request
63+
64+
[Move source](https://github.com/MystenLabs/seal/blob/main/move/patterns/sources/key_request.move)
65+
66+
Use this pattern to separate access policy evaluation from the `seal_approve` step. Instead of checking the full policy inside `seal_approve`, your contract performs whatever authorization logic it needs (payment, role check, rate limit, etc.) and issues a `KeyRequest` object. The `seal_approve` function then only verifies that the `KeyRequest` is valid and unexpired, keeping policy evaluation outside of the Seal dry-run path. This is useful when your access policy is complex, when you need to guarantee safety during dry-run evaluation, or when you want to charge per key request. The pattern uses a witness type to bind each `KeyRequest` to the issuing package, preventing cross-contract forgery.

0 commit comments

Comments
 (0)