Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 13 additions & 48 deletions docs/protocol/api/get_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,48 +69,33 @@ This request registers an identity and sets a future timestamp when the decrypti
}
```

#### **Option 2: Register an Identity with an Event Trigger (ETD)**
#### **Option 2: Register an Identity with an Event Trigger (WIP)**

Instead of a time trigger, you can register an **Event Trigger Definition (ETD)**. The identity will decrypt when Keypers observe a matching on-chain event from a specific contract.
Instead of using a time trigger, you can register an identity that decrypts when Keypers observe a corresponding on-chain event within a TTL window. Utilize the **`/register_event_identity`** endpoint with an encoded `eventDefinition`.

##### API Call: Register Identity with ETD
##### API Call: Register Event Identity

```bash
curl -X POST https://shutter-api.shutter.network/register_identity\
curl -X POST https://shutter-api.shutter.network/register_event_identity\
-H "Content-Type: application/json"\
-d '{
"trigger": {
"type": "event",
"etd": {
"contract": "0xA1b2c3D4e5F6a7B8c9D0E1f2A3b4C5d6E7f8A9B0",
"eventSignature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"indexedTopics": [null, null, "0x000000000000000000000000feed0000000000000000000000000000cafe"],
"conditions": [{"arg":"value","op":"gte","value":"10000000"}],
"ttl": 86400
}
},
"identityPrefix": "0x79bc8f6b4fcb02c651d6a702b7ad965c7fca19e94a9646d21ae90c8b54c030a0"
"eventDefinition": "0x808ba62b3fb085eae2e58888828d5aa5d0d8d3cc44dcb1750e3664468a1288c38501d8d9e5d89930656b6ce9aa13b6a311031b89963b83d95588e26e5e8a9aeef2b9c1b07740d24bbd7aef9935fde194e05aff41fe6e3529de9a4b81779ddf4bed488b753efabe29aa7407bf131a7f744f2cf0429b0a200b1d369791fae3c740d62edd422b649a41660a6f0bd4310ecad617fb8ba626970934bd473c4dcc7784fac7ed66c4576590c76e70af4f3d99ea1361669349beb8cbb3346e9cc821435d",
"identityPrefix": "0x32fdbd2ca52e171f77db2757ff6200cd8446350f927a3ad46c0565483dd8b41c"
}'
```

##### API Response

```json
{
"eon": 2,
"eon_key": "0x9ab65437a84ef50e5ed75772c18ae38b168bb07c50cadb65fc6136604e6622aa",
"identity": "0x5f77b7e72f3d2c5b1a0f1c2a33b6f4a1b9d8c7e6f5a4b3c29181716151413121",
"tx_hash": "0x6d54be9940b784b10c9a0c95c6ed1d6df8a8c1d2a78b7d9a0c7e6f5d4c3b2a19"
"eon": 1,
"eon_key": "0x9348cbe5372c1b467bfe60d6c678bbe1aed74a90b93f857b2db1b6a5dac5cd95",
"identity": "0xdfb9b97b2ff057a1fdff173e10e974ffb16c28105f0524b33e8a6906c6c81dc0",
"identityPrefix": "0x32fdbd2ca52e171f77db2757ff6200cd8446350f927a3ad46c0565483dd8b41c",
"tx_hash": "0xf7cb7ef13edee67735bba17d5ff84546a1ac7547b3d2a9f1d15e4d1b2e9f303c"
}
```

:::note **Notes**

- `eventSignature` is the Keccak-256 topic0 of the event.
- `indexedTopics` positions map to topic1 to topic3. Use `null` for wildcards.
- `conditions` apply to non-indexed arguments, for example numeric comparisons.
- `ttl` is the number of seconds to track the event after registration.
:::
* * * * *

### 2\. **Encrypt and Submit the Commitment**
Expand Down Expand Up @@ -163,29 +148,9 @@ const decryptedData = await decrypt(encryptedData, epochSecretKey);
console.log("Decryption successful:", decryptedData);
```

#### Alternative: **Decrypt After Event Trigger**

For ETD identities, the key is released when a matching on-chain event is observed within the TTL window.

##### Optionally check identity status

```bash
curl -X GET "https://shutter-api.shutter.network/get_identity_status?identity=0x5f77b7e72f3d2c5b1a0f1c2a33b6f4a1b9d8c7e6f5a4b3c29181716151413121"
```

Example response:

```json
{ "status": "satisfied", "triggerType": "event", "observedAt": 1735045061 }
```

##### Retrieve decryption key

```bash
curl -X GET "https://shutter-api.shutter.network/get_decryption_key?identity=0x5f77b7e72f3d2c5b1a0f1c2a33b6f4a1b9d8c7e6f5a4b3c29181716151413121"
```
#### Alternative: **Decrypt After Event Trigger (WIP)**

Use the same SDK `decrypt` call as above to reveal the plaintext.
For identities registered with **`/register_event_identity`**, the decryption key is released when a corresponding on-chain event is observed within the time-to-live (TTL) window.

* * * * *

Expand Down
2 changes: 1 addition & 1 deletion docs/protocol/api/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ A hardware-based solution that provides a secure enclave for running private com
#### **Event-Based Encryption Triggers**
The Shutter API enables encryption to be **triggered by predefined events**, such as **when all players submit their moves in a game**, instead of relying solely on time-based triggers. This approach ensures that decryption occurs only when all specified conditions are met.

Decryption is **released when a specific on-chain event is observed** by the Keypers. These events are compared against a registered **Event Trigger Definition (ETD)**, which details the emitter contract, the event signature, and includes optional indexed topic filters as well as conditions for non-indexed arguments. This functionality is useful for various applications, such as payment-gated content, enhancing DAO transparency after a proposal is executed, settling auctions once they are closed, or revealing game rounds upon completion.
The decryption key is **released when the Keypers observe a specific on-chain event**. These events are compared against a registered **Event Trigger Definition (ETD)** outlining the emitter contract and the event signature. It may also include optional indexed topic filters and conditions for non-indexed arguments. Each ETD has a **time-to-live (TTL)** window. Keys are **released only** if the condition has not been met previously and all constraints are satisfied.

---

Expand Down
29 changes: 8 additions & 21 deletions docs/protocol/api/how_it_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ The Shutter protocol provides a robust and secure commit-and-reveal workflow by
<Admonition type="note" title={null} icon={null}>
<p>
- **Register Identity with Timestamp**: Allows clients to register identities and decryption triggers seamlessly.
- **Register Identity with Event Trigger (ETD)**: This feature enables clients to register identities that decrypt upon the observation of a specific on-chain event.
- **Register Event Identity (event-based trigger)**: Register identities that are decrypted upon observing a specific on-chain event by submitting an encoded `eventDefinition` via `/register_event_identity`.
- **Retrieve Encryption Data**: Enables retrieval of encryption data for specific identities.
- **Retrieve Decryption Keys**: Provides access to decryption keys once trigger conditions are met.
- **Decrypt Commitments**: Facilitates direct decryption of commitments using stored decryption keys.
- **Get Identity Status**: Indicates if an identity is pending, satisfied, expired by TTL, or finalized.
</p>
</Admonition>

Expand Down Expand Up @@ -115,7 +114,7 @@ Before using Shutter's encryption, a dApp must **register an identity and specif
:::tip[How it works]

1. For time-based identities, the developer sends a request to the Shutter API to **register an identity with a decryption timestamp**.
2. For event-based identities, the developer sends a request to **register an identity with an Event Trigger Definition (ETD)**, which specifies which on-chain event will unlock decryption and how long it should be tracked.
2. For event-based identities, the developer sends a request to register an event identity via `/register_event_identity`, submitting an encoded `eventDefinition` that specifies the on-chain event to monitor and a TTL for tracking.
3. The API **submits this registration to the on-chain registry contract**.
4. The **Keypers monitor the registry** and initiate the **threshold key generation process**.
5. Once successful, the registry **stores the identity and its associated trigger**.
Expand All @@ -132,31 +131,19 @@ The Shutter API can optionally **cover the gas fees** for this transaction.
curl -X POST https://API_BASE_URL/register_identity \
-H "Content-Type: application/json" \
-d '{
"trigger": {
"type": "time",
"decryptionTimestamp": 1735044061
},
"decryptionTimestamp": 1735044061,
"identityPrefix": "0x79bc8f6b4fcb02c651d6a702b7ad965c7fca19e94a9646d21ae90c8b54c030a0"
}'
```

> ##### Event-based (inline ETD)
> ##### Event-based (register event identity)

```bash
curl -X POST https://API_BASE_URL/register_identity \
-H "Content-Type: application/json" \
curl -X POST https://API_BASE_URL/register_event_identity\
-H "Content-Type: application/json"\
-d '{
"trigger": {
"type": "event",
"etd": {
"contract": "0xA1b2c3D4e5F6a7B8c9D0E1f2A3b4C5d6E7f8A9B0",
"eventSignature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"indexedTopics": [null, "0x000000000000000000000000feed0000000000000000000000000000cafe", null],
"conditions": [{"arg":"value","op":"gte","value":"10000000"}],
"ttl": 86400
}
},
"identityPrefix": "0x79bc8f6b4fcb02c651d6a702b7ad965c7fca19e94a9646d21ae90c8b54c030a0"
"eventDefinition": "0x808ba62b3fb085eae2e58888828d5aa5d0d8d3cc44dcb1750e3664468a1288c38501d8d9e5d89930656b6ce9aa13b6a311031b89963b83d95588e26e5e8a9aeef2b9c1b07740d24bbd7aef9935fde194e05aff41fe6e3529de9a4b81779ddf4bed488b753efabe29aa7407bf131a7f744f2cf0429b0a200b1d369791fae3c740d62edd422b649a41660a6f0bd4310ecad617fb8ba626970934bd473c4dcc7784fac7ed66c4576590c76e70af4f3d99ea1361669349beb8cbb3346e9cc821435d",
"identityPrefix": "0x32fdbd2ca52e171f77db2757ff6200cd8446350f927a3ad46c0565483dd8b41c"
}'
```

Expand Down
6 changes: 5 additions & 1 deletion docs/protocol/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ The system operates using a commit-and-reveal process. In this process, a user e

Developers can integrate Shutter API into various applications, such as decentralized finance platforms that want to protect traders from MEV attacks, DAOs looking to implement private and tamper-proof voting, and gaming applications that require secrecy in game mechanics. The API also enables new use cases, such as parimutuel betting, sealed RFPs for corporate procurement, and fair auction mechanisms that eliminate the Free Option Problem, ensuring that bids remain confidential until the deadline.

**The Shutter API also introduces event-based decryption triggers**, which allow encrypted data to be automatically revealed when specific on-chain conditions are met. This feature enables programmable, state-dependent privacy. For example, it can reveal a document after a payment is made, unlock a game secret when a milestone is reached, or release encrypted content when a contract emits a particular event.
**The Shutter API introduces event-based decryption triggers**, allowing encrypted data to be automatically revealed when specific on-chain conditions are met. This feature enables programmable, state-dependent privacy. For instance, it can reveal a document after a payment is made, unlock a game secret when a milestone is achieved, or release encrypted content when a contract emits a particular event.

**Currently, event-based triggers can be accessed through a single API endpoint: `POST /register_event_identity`. This endpoint registers an identity linked to an encoded event definition (`eventDefinition`). Keys will be released only if the observed event matches the definition within its time-to-live (TTL) window and the condition has not been met before.**

Please note that event-based triggers are still a work in progress; at this time, there are no separate endpoints for "register event trigger" or "get trigger status."

Unlike solutions based on Trusted Execution Environments (TEEs), which introduce a single point of failure and rely on specialized hardware, Shutter API provides a fully decentralized approach that does not require trusting any central entity. It operates as a distributed threshold encryption network, where independent Keypers collaboratively generate and release encryption keys, making it a truly trust-minimized solution.

Expand Down
71 changes: 12 additions & 59 deletions docs/protocol/api/integrating_api_llm_friendly.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---
title: Integrating Shutter API and SDK for dApp Development
description: Integrating Shutter API and SDK for dApp Development
Expand Down Expand Up @@ -123,81 +122,37 @@ Note: Replace `API_BASE_URL` with the appropriate API base URL (Chiado or Mainne

### Registering an Identity with an Event-Based Trigger (ETD)

To release decryption when a specific on-chain event occurs, use an **Event Trigger Definition**. In this definition, you specify the contract that emits the event, the event signature, and any optional indexed topic filters. You can also set conditions on non-indexed arguments if needed. Additionally, you will establish a Time-To-Live (TTL) to limit how long the Keypers will monitor the trigger.
To release decryption when a specific on-chain event occurs, use an **Event Trigger Definition**. For alignment with the current API, submit the encoded **`eventDefinition`** using **`/register_event_identity`** (WIP). The encoding is a concatenation of the contract address, topic0, and the RLP-encoded matchers (use provided tooling when available). You also supply an `identityPrefix`.

```
Endpoint: /register_event_trigger
Endpoint: /register_event_identity
Method: POST
```

#### Example Request

```
curl -X POST https://`API_BASE_URL`/register_event_trigger\
curl -X POST https://`API_BASE_URL`/register_event_identity\
-H "Content-Type: application/json"\
-d '{
"identityPrefix": "0x79bc8f6b4fcb02c651d6a702b7ad965c7fca19e94a9646d21ae90c8b54c030a0",
"etd": {
"contract": "0x1234567890abcdef1234567890abcdef12345678",
"eventSignature": "0x4bb278f3a1a2c3f4d5e6a7b8c9d0e1f2a3b4c5d6e7f8090a1b2c3d4e5f607182",
"indexedTopics": [
"0x000000000000000000000000228DefCF37Da29475F0EE2B9E4dfAeDc3b0746bc",
null,
null
],
"conditions": [
{"argIndex": 2, "op": ">=", "value": "1000000000000000000"}
],
"ttl": 86400
}
"eventDefinition": "0x808ba62b3fb085eae2e58888828d5aa5d0d8d3cc44dcb1750e3664468a1288c38501d8d9e5d89930656b6ce9aa13b6a311031b89963b83d95588e26e5e8a9aeef2b9c1b07740d24bbd7aef9935fde194e05aff41fe6e3529de9a4b81779ddf4bed488b753efabe29aa7407bf131a7f744f2cf0429b0a200b1d369791fae3c740d62edd422b649a41660a6f0bd4310ecad617fb8ba626970934bd473c4dcc7784fac7ed66c4576590c76e70af4f3d99ea1361669349beb8cbb3346e9cc821435d",
"identityPrefix": "0x32fdbd2ca52e171f77db2757ff6200cd8446350f927a3ad46c0565483dd8b41c"
}'
```

#### Example Response

```
{
"identity": "0x8c232eae4f957259e9d6b68301d529e9851b8642874c8f59d2bd0fb84a570c75",

"eon": 1,

"eon_key": "0x57af5437a84ef50e5ed75772c18ae38b168bb07c50cadb65fc6136604e662255",

"epoch_id": "0x88f2495d1240f9c5523db589996a50a4984ee7a08a8a8f4b269e4345b383310a",

"tx_hash": "0xabcdad202ca611551377eef069fb6ed894eae65329ce73c56f300129694f1abc"

}
```

* * * * *

### Checking Trigger Status

Query the current status of a time-based or event-based identity. Useful for polling your UI.

```
Endpoint: /get_trigger_status
Method: GET
```

#### Example Request

```bash
curl -X GET "https://`API_BASE_URL`/get_trigger_status?identity=0x8c232eae4f957259e9d6b68301d529e9851b8642874c8f59d2bd0fb84a570c75"
```

#### Example Response
"eon_key": "0x9348cbe5372c1b467bfe60d6c678bbe1aed74a90b93f857b2db1b6a5dac5cd95",

```
{
"identity": "0x8c232eae4f957259e9d6b68301d529e9851b8642874c8f59d2bd0fb84a570c75",
"identity": "0xdfb9b97b2ff057a1fdff173e10e974ffb16c28105f0524b33e8a6906c6c81dc0",

"type": "event",
"identityPrefix": "0x32fdbd2ca52e171f77db2757ff6200cd8446350f927a3ad46c0565483dd8b41c",

"status": "Satisfied",

"observedAt": 1735045061
"tx_hash": "0xf7cb7ef13edee67735bba17d5ff84546a1ac7547b3d2a9f1d15e4d1b2e9f303c"
}
```

Expand Down Expand Up @@ -263,7 +218,6 @@ curl -X GET "https://`API_BASE_URL`/get_decryption_key?identity=0x8c232eae4f9
}
```


* * * * *

### Decrypting Commitments
Expand Down Expand Up @@ -301,7 +255,7 @@ The Shutter SDK is a TypeScript library that simplifies the encryption and decry

To install the Shutter SDK in your project, run:

`npm install @shutter-network/shutter-sdk`
`npm install @shutter-network/shutter-sdk`

* * * * *

Expand Down Expand Up @@ -346,7 +300,7 @@ console.log("Decrypted Message:", decryptedData);
```

:::note [Note]
For event-based triggers, first poll or subscribe to trigger status, then request the decryption key and run the same decrypt flow.
For event-based triggers, wait until the event condition is met, then request the decryption key and execute the same decryption flow.
:::

* * * * *
Expand All @@ -370,7 +324,6 @@ import (

"strings"


"github.com/shutter-network/shutter/shlib/shcrypto"

)
Expand Down Expand Up @@ -438,7 +391,7 @@ When building a new dApp with the Shutter API, follow these steps:

Tip: If you want full control over your address, consider registering directly with the registry contract.

*Event-based option*: You can also register an identity with an ETD using **/register_event_trigger** so that decryption keys are released when a matching on-chain event is observed.
*Event-based option*: You can register an identity with an ETD using **/register_event_identity** by submitting the encoded `eventDefinition` along with your `identityPrefix`.

3. **Retrieve Encryption Data**

Expand Down
Loading