Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web of trust related DVMs #38

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
181 changes: 181 additions & 0 deletions kinds/5312.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
---
layout: default
title: Verify Reputation
description: Job that returns pubkey reputation information based on an algorithm
---

This service returns reputation information about a pubkey, including a list of pubkeys who follow it sorted by an algorithm.

# Input

None. The DVM `i` input tag SHOULD NOT be used and `content` SHOULD be empty.

# Params

| Parameter | Type | Description | Default Value |
|-----|-----|-----|-----|
| `source` | string | The source pubkeys used for personalized algorithms | The pubkey signing the DVM request |
| `target` | string | Pubkeys the requester is interested in | - |
| `context` | string | Additional context for the algorithm to compute | - |
| `distance` | int | Maximum (or minimum) number of hops in the graph to perform the calculation to (or from) | `0` |
| `sort` | string | Algorithm used to sort results | Implementation-specific |
| `limit` | int | Maximum number of results returned in a response | Implementation-specific |
| `proofs` | boolean | Whether to return applicable events (kinds 0, 3, etc.) on the websocket connection for clients to verify certain claims | `false` |

Pubkeys SHOULD be in hex format. Implementations MAY support automatic npub decoding.

Multiple `source` and/or `target` parameters MAY be supplied. Algorithms that work with single values SHOULD take the first value in these lists.

Parameters `limit` and `sort` SHOULD NOT be required and are implementation-specific.

## Sorting algorithms

Algorithms are used for sorting results and MAY be passed in the request. Each service will offer different ones, here is a non-exhaustive list:

- `globalPagerank`: Global Pagerank
- `personalizedPagerank`: Personalized Pagerank
- `graperank`: Graperank
- `verifiedFollowers`: Followers with a minimum rank (uses `personalizedPagerank` if source is provided or otherwise `globalPagerank`)
- `distance`: Number of hops in the graph between source and target

# Output

The response MUST be a standard DVM response including the corresponding `e` and `p` tags.

Its `content` field MUST return a JSON-stringified array of objects formatted as:

| Properties | Types | Description |
|-----|-----|-----|
| {`target`, `rank`} | {string, float} | Requested target along with its rank |
| {`follower`, `rank`} | {string, float} | Follower of target along with its rank |

Pubkeys SHOULD be in hex format.

Services MAY return objects in descending rank order for client convenience.

# How clients can use this

- Assessing trust for a new profile a user comes across, for example by showing which of their followers follow that new profile
- Obtaining verified followers of a new profile
- Detecting the probability that new profile is an impersonator

# Example

```json
{
"id": "1cd2c73f53e602ae6f081997962bd43c730a565053080ab27ef7efb7335f7f49",
"pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"created_at": 1732758297,
"kind": 5312,
"tags": [
[
"param",
"source",
"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
],
[
"param",
"target",
"5097f9b8bd3ebb3c240a6a0c95bdf24d22a10211181f90ba29c41c31c889ba0a"
],
[
"param",
"sort",
"personalizedPagerank"
],
[
"param",
"limit",
5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be strings ;)

Suggested change
5
"5"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @pablof7z, thanks for the review. Real question: why use strings? It doesn't matter and we can change it no problem, but I'm curious to know why.

Also, since you are a prolific client developer, what do you think about these DVMs more on a higher level? What would make you consider integrating them into Highligher or Olas?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pippellia-btc Pablo is right, these are nostr tags which should be strings

],
[
"param",
"proofs",
false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
false
"false"

]
],
"content": "",
"sig": "22f8aa10a0a3e9ef44f2b6a050868f46f19fcc1bbd9da3c3b291164405fb854a4b83524770d82d008a7415636554defcfb5ea52bf42e8a681a69ef10a81bc8e2"
}
```

```json
{
"id": "26594511e04ee1b20b94719616a2380b3dcaf0430e2fd6d4dcf59d24f9175fca",
"pubkey": "a9b008476119ea693cbd2f0b4de99fd346e2e30880b18d42234a1158bd323783",
"created_at": 1732758298,
"kind": 6312,
"tags": [
[
"e",
"1cd2c73f53e602ae6f081997962bd43c730a565053080ab27ef7efb7335f7f49"
],
[
"p",
"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
]
],
"content": "[{\"target\":\"f7c905827bc83e1330bee2c3a6a5b8e076976efd1b46b3e6d1ec2447a34785e2\",\"rank\":0.00266},
{\"follower\":\"bd0c0615960ff21214aee7f5b06fa0a104585938c8eb4b5cd4e2b109041fdf62\",\"rank\":0.0025},{\"follower\":\"d05ab982e1105476ab68e4c6728d148f8e6222154e60cc359ef6b8599c820bea\",\"rank\":0.00163},{\"follower\":\"6efd1b46b3e6d1ec2447af7c905827bc83e1330bee2c3a6a5b8e0769734785e2\",\"rank\":0.00154},{\"follower\":\"bb17f1e4e516e75e82a5b5e81c0120ffeb24e9e92866962440b9888ae82e42a1\",\"rank\":0.00111},{\"follower\":\"5097f9b8bd3ebb3c240a6a0c95bdf24d22a10211181f90ba29c41c31c889ba0a\",\"rank\":0.000107}]",
"sig": "3c25ff7f8d6d847775a9aafb8b1f28d2f2e9b53f78de7f53b49fbbe46402358dc281be263c20919a426cbea86fbe9d36951fd5dd86465181d9d49be056616f53"
}
```

Formatted `content` JSON:

```json
[
{
"target": "f7c905827bc83e1330bee2c3a6a5b8e076976efd1b46b3e6d1ec2447a34785e2",
"rank": 0.00266
},
{
"follower": "bd0c0615960ff21214aee7f5b06fa0a104585938c8eb4b5cd4e2b109041fdf62",
"rank": 0.0025
},
{
"follower": "d05ab982e1105476ab68e4c6728d148f8e6222154e60cc359ef6b8599c820bea",
"rank": 0.00163
},
{
"follower": "6efd1b46b3e6d1ec2447af7c905827bc83e1330bee2c3a6a5b8e0769734785e2",
"rank": 0.00154
},
{
"follower": "bb17f1e4e516e75e82a5b5e81c0120ffeb24e9e92866962440b9888ae82e42a1",
"rank": 0.00111
},
{
"follower": "5097f9b8bd3ebb3c240a6a0c95bdf24d22a10211181f90ba29c41c31c889ba0a",
"rank": 0.000107
}
]
```

Error response:

```json
{
"kind": 7000,
"id": "96f6eec0b3e410db91b85bee714740ec76ec64a9eb60a5503fee4dfc02047c1a",
"pubkey": "5fc48ac4765ff81e9c51014b9d2f2c91621370f4c6b5452a9c06456e4cccaeb4",
"created_at": 1738635799,
"tags": [
[
"status",
"error",
"badly formatted key: npub1"
],
[
"e",
"1cd2c73f53e602ae6f081997962bd43c730a565053080ab27ef7efb7335f7f49"
],
[
"p",
"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
]
],
"content": "",
"sig": "6318c7ce6c57dd85779faadc4fed7733a1e50bd46205d52c96e535648dd2dd07e573e8d1fdef496d27014c80d1f2f604cb5337744d24000c00dde485ccdcf48c"
}
```
115 changes: 115 additions & 0 deletions kinds/5313.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
layout: default
title: Recommend Follows
description: Job that recommends follows based on an algorithm
---

This service returns a list of recommended pubkeys (the ones with highest rank excluding source and its follows) sorted by an algorithm.

# Input

None. The DVM `i` input tag SHOULD NOT be used and `content` SHOULD be empty.

# Params

| Parameter | Type | Description | Default Value |
|-----|-----|-----|-----|
| `source` | string | The source pubkey used for personalized algorithms | The pubkey signing the DVM request |
| `context` | string | Additional context for the algorithm to compute | - |
| `distance` | int | Maximum (or minimum) number of hops in the graph to perform the calculation to (or from) | `0` |
| `sort` | string | Algorithm used to sort results | Implementation-specific |
| `limit` | int | Maximum number of results returned in a response | Implementation-specific |

Pubkeys SHOULD be in hex format. Implementations MAY support automatic npub decoding.

Parameters `limit` and `sort` SHOULD NOT be required and are implementation-specific.

#### Sorting algorithms

Algorithms are used for sorting results and MAY be passed in the request. Each service will offer different ones, here is a non-exhaustive list:

- `globalPagerank`: Global Pagerank
- `personalizedPagerank`: Personalized Pagerank
- `graperank`: Graperank
- `verifiedFollowers`: Followers with a minimum rank (uses `personalizedPagerank` if source is provided or otherwise `globalPagerank`)
- `distance`: Number of hops in the graph between source and target

# Output

The response MUST be a standard DVM response including the corresponding `e` and `p` tags.

Its `content` field MUST return a JSON-stringified array of objects formatted as:

| Properties | Types | Description |
|-----|-----|-----|
| {`recommended`, `rank`} | {string, float} | Recommendation along with its rank |

Pubkeys SHOULD be in hex format.

Services MAY return objects in descending rank order for client convenience.

# How clients can use this

Offering users recommendations on accounts they may want to follow.

# Example

```json
{
"id": "588d828025eab6404ed17c6c7a70d09a67c5da4ffe780e2f943f32509fe8af23",
"pubkey": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
"created_at": 1732759754,
"kind": 5313,
"tags": [],
"content": "",
"sig": "e0174ad1416e0d722f06491909fe8e4781fd732c21df6424cf0f1dc422db53ba525d544a29927297f63543796750ed7abf5e3c10c0e40e72b8c916b9a751c078"
}
```

```json
{
"id": "171a0a7551c785ab0e2ac99577bfc25dd4fe7c28a19cacfcb625b4be2964ea4a",
"pubkey": "a9b008476119ea693cbd2f0b4de99fd346e2e30880b18d42234a1158bd323783",
"created_at": 1732759756,
"kind": 6313,
"tags": [
[
"e",
"588d828025eab6404ed17c6c7a70d09a67c5da4ffe780e2f943f32509fe8af23"
],
[
"p",
"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
]
],
"content": "[{\"recommended\":\"bd0c0615960ff21214aee7f5b06fa0a104585938c8eb4b5cd4e2b109041fdf62\",\"rank\":0.0025},{\"recommended\":\"d05ab982e1105476ab68e4c6728d148f8e6222154e60cc359ef6b8599c820bea\",\"rank\":0.00163},{\"recommended\":\"6efd1b46b3e6d1ec2447af7c905827bc83e1330bee2c3a6a5b8e0769734785e2\",\"rank\":0.00154},{\"recommended\":\"bb17f1e4e516e75e82a5b5e81c0120ffeb24e9e92866962440b9888ae82e42a1\",\"rank\":0.00111},{\"recommended\":\"5097f9b8bd3ebb3c240a6a0c95bdf24d22a10211181f90ba29c41c31c889ba0a\",\"rank\":0.000107}]",
"sig": "c79f34b9f5603b242e00f0b04782d579ffcec2cb45e511fbbf1ba3e04d5297f7eb7a071433b0a14300fbd766feaf5e8e1f6fbd216ae1cce1cb400f987fc2d0d2"
}
```

Formatted `content` JSON:

```json
[
{
"recommended": "bd0c0615960ff21214aee7f5b06fa0a104585938c8eb4b5cd4e2b109041fdf62",
"rank": 0.0025
},
{
"recommended": "d05ab982e1105476ab68e4c6728d148f8e6222154e60cc359ef6b8599c820bea",
"rank": 0.00163
},
{
"recommended": "6efd1b46b3e6d1ec2447af7c905827bc83e1330bee2c3a6a5b8e0769734785e2",
"rank": 0.00154
},
{
"recommended": "bb17f1e4e516e75e82a5b5e81c0120ffeb24e9e92866962440b9888ae82e42a1",
"rank": 0.00111
},
{
"recommended": "5097f9b8bd3ebb3c240a6a0c95bdf24d22a10211181f90ba29c41c31c889ba0a",
"rank": 0.000107
}
]
```
Loading