diff --git a/101.md b/101.md index 31ebc747..2f6dcaa2 100644 --- a/101.md +++ b/101.md @@ -2,7 +2,7 @@ `draft` `optional` `author:abhay-raizada` -The nip provides a way for users to create form templates on nostr, and for other users to be able to fill them. +The nip provides a way to implement a feedback mechanism(forms) on nostr. ## Form Template - Public @@ -107,7 +107,7 @@ for option fields, the response is the id of the option selected. In case of mul } ``` -## Editable Responses +## Response Editability if the form setting allows for editable responses. The latest timestamp event should be used to render the response. @@ -154,6 +154,14 @@ The kind `1059` event also works similar to as described in [[59.md]] except tha **formId** - d-tag of the event **userPub** - pubkey to recepient being given the access. +code for alias generation +```ts +import {bytesToHex } from "@noble/hashes/utils" +import { sha256 } from "@noble/hashes/sha256" + +let aliasPubKey = bytesToHex(sha256(`${30168}:${formAuthor}:${formId}:${userPub}`)); +``` + ### Keys The "key" tag in the `kind:18` rumor is represented as: @@ -165,13 +173,17 @@ The "key" tag in the `kind:18` rumor is represented as: - **Voter Key** - A key used to submit a response to the form in a poll-like scenario. +### Submit Access. + +p-tags of the selected participants must be added to the form tags, and only query the responses from the p-tags mentioned in the form. + ### Encrypted Responses. Response tags are added to the `.content` field of the event and encrypted as per the spec in [nip-44](./44.md) by the responders private key and the form authors public key. ### Private Forms only viewable by a group. -Form fields and settings should be ommitted from the tags array and placed in the `.content` key, nip-44 encrypted by the corresponding public key of the view-key, and the signing key. The selected responders can decrypt the form using the view key. The `tags` array is used to keep track of the allowed-responders identities. +Form fields and settings should be ommitted from the tags array and placed in the `.content` key, nip-44 encrypted by the corresponding public key of the view-key, and the signing key as private key. The selected responders can decrypt the form using the view key. The `tags` array is used to keep track of the allowed-responders identities. ```js let encryptionKey = nip44.v2.utils.getConversationKey( @@ -189,13 +201,15 @@ There are some important parts for a form(general feedback mechanism) to become 1. Only elligeble candidates must be allowed to vote. 2. Participants shouldn't be able to associate a response to another participant. -3. Participants should be a ble to verify their response is counted. +3. Participants should be able to verify that their response is counted. All of these conditions can be met by establishing a "Voter Key". The Voter Key is a private key generated by someone with edit access to the form (Issuer). -The Issuer must then add a "v" tag to the form event, followed by a pubkey corresponding to the voterId. +The Issuer must then add a "p" tag to the form event, followed by a pubkey corresponding to the voterId. -The v tag is used to query eligible votes. +The voter must sign their responses with the issued voter key. + +The p tag is used to query eligible votes. Example form with a voter id. @@ -212,8 +226,8 @@ Example form with a voter id. ["name", "This is the title of your form! Tap to edit."], ["field", "egtD6v", "option", "What is the best breakfast?", "[[\"2KJ6h4\",\"Omelette\"],[\"1m3a5q\",\"Pancakes\"]]", "{\"renderElement\":\"radioButton\"}" ] - ["v", "fb740690af9329e25b0a3c1f6ce6a24c4ff98dcba56d3579381ee340ea0350d4"], - ["v", "6b557be286b13d7a85b3823c630050db043c9a28bf606aa49c65b3db0c3208b6"] + ["p", "fb740690af9329e25b0a3c1f6ce6a24c4ff98dcba56d3579381ee340ea0350d4"], + ["p", "6b557be286b13d7a85b3823c630050db043c9a28bf606aa49c65b3db0c3208b6"] ] } ``` @@ -240,4 +254,14 @@ const filter: Filter = { if (allowedPubkeys) filter.authors = allowedPubkeys; ``` -Polls responses need to be queried by authors mentioned in the forms v-tag +## Requesting Acces + + + +## Tradeoffs + +- Alias pubkey on gift wrap means that there is no notification mechanism for the user, unless the user is expecting access to an event. + +- Alias pubkey also means that it can be checked that a particular user received a gift wrap for a form event, but it cannot be directly determined who all received the gift wraps, it also makes it easier in disambiguating between event kinds. + +- Voter Key might make it anoymous to other participants, but the issuer can still know who a particular user voted for. In this implementation, the issuer is to be "trusted", but there may be out of band ways of having a "trustless" issuer. For example distrubiting voter Id chits in a physical meetup.