diff options
| author | Ben Hayward <benhayward93@hotmail.com> | 2023-02-01 12:05:25 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-01 09:05:25 -0300 |
| commit | 38074f664301b0bcb65f0b77da533ffba8df46e4 (patch) | |
| tree | a8311efa99fcf7d9b9b0b321e0a2f9a7c13b34fc | |
| parent | 57d758b07fbe7d3bf95558c93abdbd9eef6a9b42 (diff) | |
NIP-26: Advice on using after operators in conditions query string (#199)
Co-authored-by: Ben Hayward <ben@minds.com>
| -rw-r--r-- | 26.md | 26 |
1 files changed, 14 insertions, 12 deletions
| @@ -19,7 +19,7 @@ This NIP introduces a new tag: `delegation` which is formatted as follows: | |||
| 19 | "delegation", | 19 | "delegation", |
| 20 | <pubkey of the delegator>, | 20 | <pubkey of the delegator>, |
| 21 | <conditions query string>, | 21 | <conditions query string>, |
| 22 | <64-bytes schnorr signature of the sha256 hash of the delegation token> | 22 | <64-byte Schnorr signature of the sha256 hash of the delegation token> |
| 23 | ] | 23 | ] |
| 24 | ``` | 24 | ``` |
| 25 | 25 | ||
| @@ -52,6 +52,8 @@ For example, the following condition strings are valid: | |||
| 52 | - `kind=0&kind=1&created_at>1675721813` | 52 | - `kind=0&kind=1&created_at>1675721813` |
| 53 | - `kind=1&created_at>1674777689&created_at<1675721813` | 53 | - `kind=1&created_at>1674777689&created_at<1675721813` |
| 54 | 54 | ||
| 55 | For the vast majority of use-cases, it is advisable that query strings should include a `created_at` ***after*** condition reflecting the current time, to prevent the delegatee from publishing historic notes on the delegator's behalf. | ||
| 56 | |||
| 55 | #### Example | 57 | #### Example |
| 56 | 58 | ||
| 57 | ``` | 59 | ``` |
| @@ -64,41 +66,41 @@ privkey: 777e4f60b4aa87937e13acc84f7abcc3c93cc035cb4c1e9f7a9086dd78fffce1 | |||
| 64 | pubkey: 477318cfb5427b9cfc66a9fa376150c1ddbc62115ae27cef72417eb959691396 | 66 | pubkey: 477318cfb5427b9cfc66a9fa376150c1ddbc62115ae27cef72417eb959691396 |
| 65 | ``` | 67 | ``` |
| 66 | 68 | ||
| 67 | Delegation string to grant note publishing authorization to the delegatee (477318cf) for the next 30 days. | 69 | Delegation string to grant note publishing authorization to the delegatee (477318cf) from now, for the next 30 days, given the current timestamp is `1674834236`. |
| 68 | ```json | 70 | ```json |
| 69 | nostr:delegation:477318cfb5427b9cfc66a9fa376150c1ddbc62115ae27cef72417eb959691396:kind=1&created_at<1675721885 | 71 | nostr:delegation:477318cfb5427b9cfc66a9fa376150c1ddbc62115ae27cef72417eb959691396:kind=1&created_at>1674834236&created_at<1677426236 |
| 70 | ``` | 72 | ``` |
| 71 | 73 | ||
| 72 | The delegator (8e0d3d3e) then signs the above delegation string, the result of which is the delegation token: | 74 | The delegator (8e0d3d3e) then signs a SHA256 hash of the above delegation string, the result of which is the delegation token: |
| 73 | ``` | 75 | ``` |
| 74 | cbc49c65fe04a3181d72fb5a9f1c627e329d5f45d300a2dfed1c3e788b7834dad48a6d27d8e244af39c77381334ede97d4fd15abe80f35fda695fd9bd732aa1e | 76 | 6f44d7fe4f1c09f3954640fb58bd12bae8bb8ff4120853c4693106c82e920e2b898f1f9ba9bd65449a987c39c0423426ab7b53910c0c6abfb41b30bc16e5f524 |
| 75 | ``` | 77 | ``` |
| 76 | 78 | ||
| 77 | The delegatee (477318cf) can now construct an event on behalf of the delegator (8e0d3d3e). The delegatee then signs the event with its own private key and publishes. | 79 | The delegatee (477318cf) can now construct an event on behalf of the delegator (8e0d3d3e). The delegatee then signs the event with its own private key and publishes. |
| 78 | ```json | 80 | ```json |
| 79 | { | 81 | { |
| 80 | "id": "ac4c71e69c39b1bd605de812543ebfaf81d5af365354f061d48981fb61e00b8a", | 82 | "id": "e93c6095c3db1c31d15ac771f8fc5fb672f6e52cd25505099f62cd055523224f", |
| 81 | "pubkey": "477318cfb5427b9cfc66a9fa376150c1ddbc62115ae27cef72417eb959691396", | 83 | "pubkey": "477318cfb5427b9cfc66a9fa376150c1ddbc62115ae27cef72417eb959691396", |
| 82 | "created_at": 1673129661, | 84 | "created_at": 1677426298, |
| 83 | "kind": 1, | 85 | "kind": 1, |
| 84 | "tags": [ | 86 | "tags": [ |
| 85 | [ | 87 | [ |
| 86 | "delegation", | 88 | "delegation", |
| 87 | "8e0d3d3eb2881ec137a11debe736a9086715a8c8beeeda615780064d68bc25dd", | 89 | "8e0d3d3eb2881ec137a11debe736a9086715a8c8beeeda615780064d68bc25dd", |
| 88 | "kind=1&created_at<1675721813", | 90 | "kind=1&created_at>1674834236&created_at<1677426236", |
| 89 | "cbc49c65fe04a3181d72fb5a9f1c627e329d5f45d300a2dfed1c3e788b7834dad48a6d27d8e244af39c77381334ede97d4fd15abe80f35fda695fd9bd732aa1e" | 91 | "6f44d7fe4f1c09f3954640fb58bd12bae8bb8ff4120853c4693106c82e920e2b898f1f9ba9bd65449a987c39c0423426ab7b53910c0c6abfb41b30bc16e5f524" |
| 90 | ] | 92 | ] |
| 91 | ], | 93 | ], |
| 92 | "content": "Hello, world!", | 94 | "content": "Hello, world!", |
| 93 | "sig": "55ed9a78d6449b8c189b6dbc34bc4bcd34dcc79e6da6c9078268fe3d7c0cbe62b1b907ffb76ba591e83895b1329bf2e6e16f3b0cd5827272e420d419c6f0f0b5" | 95 | "sig": "633db60e2e7082c13a47a6b19d663d45b2a2ebdeaf0b4c35ef83be2738030c54fc7fd56d139652937cdca875ee61b51904a1d0d0588a6acd6168d7be2909d693" |
| 94 | } | 96 | } |
| 95 | ``` | 97 | ``` |
| 96 | 98 | ||
| 97 | The event should be considered a valid delegation if the conditions are satisfied (`kind=1` and `created_at<1675721813` in this example) and, upon validation of the delegation token, are found to be unchanged from the conditions in the original delegation string. | 99 | The event should be considered a valid delegation if the conditions are satisfied (`kind=1`, `created_at>1674834236` and `created_at<1677426236` in this example) and, upon validation of the delegation token, are found to be unchanged from the conditions in the original delegation string. |
| 98 | 100 | ||
| 99 | Clients should display the delegated note as if it was published directly by the delegator (8e0d3d3e). | 101 | Clients should display the delegated note as if it was published directly by the delegator (8e0d3d3e). |
| 100 | 102 | ||
| 101 | 103 | ||
| 102 | #### Relay & Client Querying Support | 104 | #### Relay & Client Querying Support |
| 103 | 105 | ||
| 104 | Relays should answer requests such as `["REQ", "", {"authors": ["A"]}]` by querying both the `pubkey` and delegation tags `[1]` value. | 106 | Relays should answer requests such as `["REQ", "", {"authors": ["A"]}]` by querying both the `pubkey` and delegation tags `[1]` value. \ No newline at end of file |