Skip to content

Commit

Permalink
hash source registry
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe committed May 14, 2024
1 parent 497f60b commit 6c5a813
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
3 changes: 3 additions & 0 deletions spec/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ paths:
hash:
type: string
description: The current hash which is to be used as input for computing a retention solution
hash_source:
type: string
description: The source of the hash as defined by the Hash Source Registry.
difficulty:
type: integer
description: The current difficulty of the challenge representing the number of bits of leading zeros the resulting hash must contain
Expand Down
24 changes: 16 additions & 8 deletions spec/registry/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The DID DHT Method Specification Registry 1.0

**Draft Created:** November 20, 2023

**Latest Update:** May 2, 2024
**Latest Update:** May 14, 2024

**Editors:**
~ [Gabe Cohen](https://github.com/decentralgabe)
Expand Down Expand Up @@ -92,7 +92,6 @@ These properties are for use on a service object, in the value of [service](http
| `sig` | String or array of strings | `enc=E` where `E` is a string or array of strings | id=s1;t=TestService;se=https://test-service.com/1;enc=1 |
| `enc` | String or array of strings | `sig=S` where `S` is a string or array of strings | id=s1;t=TestService;se=https://test-service.com/1;sig=2 |


### Interoperable DID Methods

As an **OPTIONAL** extension, some existing DID methods can leverage `did:dht` to broaden their feature set. This registry serves
Expand Down Expand Up @@ -168,25 +167,34 @@ ensure the maintenance of an active timelock, which serves as a proof-of-legitim

1. Generate a relative [[ref:timelock]] transaction for the Bitcoin blockchain with the following attributes:
- Set the lock duration to 1000
- Add locked value locked must be no less than the mean value of the upper quintile of [UTXOs](https://en.wikipedia.org/wiki/Unspent_transaction_output) as of a block that is no more than 10 blocks earlier from the block the locking transaction is included in (this effectively provides a 10 block grace period for the transaction to make it into the chain).
- Add locked value locked must be no less than the mean value of the upper quintile of
[UTXOs](https://en.wikipedia.org/wiki/Unspent_transaction_output) as of a block that is no more than 10 blocks earlier from the block
the locking transaction is included in (this effectively provides a 10 block grace period for the transaction to make it into the chain).
- Add an `OP_RETURN` string composed of the following comma-separated values:
- The block number used to compute the mean value of the upper quintile of [UTXOs](https://en.wikipedia.org/wiki/Unspent_transaction_output).
- The `URI` where your node can be addressed
2. Include the [[ref:timelock]] transaction within 10 blocks of the block number specified for the average UTXO value calculation.
3. If this is a relocking transaction that refreshes an existing registration of a node:
- The relocking transaction ****MUST**** spend the outputs of the lock it replaces.
- If the operator wants to prevent other nodes and clients using the decentralized registry from dropping the Registered Gateway from their Registered Gateway list, the relocking transaction ****MUST**** be included in the blockchain within ten blocks of the previous lock's expiration.
- If the operator wants to prevent other nodes and clients using the decentralized registry from dropping the Registered Gateway from their
Registered Gateway list, the relocking transaction ****MUST**** be included in the blockchain within ten blocks of the previous lock's expiration.

##### Hash Source

##### Hash
The hash source used for providing [Retention Challenges](../index.html#retained-did-set) is configurable. The registry table
below serves as a way to define new hash sources and communicate them as a part of the [Gateway API](../index.html#gateway-api).

The hash source to be used is [Bitcoin block hashes](https://csrc.nist.gov/glossary/term/block_header#:~:text=Definitions%3A,cryptographic%20nonce%20(if%20needed).). It is ****RECOMMENDED**** to use the most recent block hash value.
| Hash Source Name | Hash Source |
|------------------|-------------------------------------------|
| `bitcoin` | [Bitcoin block hashes](https://csrc.nist.gov/glossary/term/block_header#:~:text=Definitions%3A,cryptographic%20nonce%20(if%20needed) |

##### Discovery

To discover Bitcoin Anchored Gateways one must follow the following steps:

1. Starting at block height of `817714` traverse the chain, checking the value of the `OP_RETURN` field of transactions with _at least_ **6 confirmations**.
2. Find transactions that match the form `block number + uri`, as per the [steps outlined in the section above](#bitcoin-anchored-gateways).
1. Starting at block height of `817714` traverse the chain, checking the value of the `OP_RETURN` field of
transactions with _at least_ **6 confirmations**.
2. Find transactions that match the form `block number + URI`, as per the [steps outlined in the section above](#bitcoin-anchored-gateways).

## References

Expand Down
38 changes: 20 additions & 18 deletions spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The DID DHT Method Specification 1.0

**Draft Created:** October 20, 2023

**Last Updated:** May 13, 2024
**Last Updated:** May 14, 2024

**Editors:**
~ [Gabe Cohen](https://github.com/decentralgabe)
Expand Down Expand Up @@ -255,15 +255,14 @@ the set of Service resource aliases (e.g. `s0`) for each [Service](#services).

Additionally:

- A version number ****MUST**** be present. The version number for this specification version
- A version number ****MUST**** be present. The version number for this specification version
is **0** (e.g. `v=0`). The version number is not present in the corresponding DID Document.

- The `vm` property ****MUST**** always contain _at least_ the [[ref:Identity Key]] represented by `k0`.
- The `vm` property ****MUST**** always contain _at least_ the [[ref:Identity Key]] represented by `k0`.

- Verification Relationships (`auth`, `asm`, `agm`, `inv`, `del`) without any members ****MUST**** be omitted.

- If there are no [Services](#services) the `svc` property ****MUST**** be omitted.
- Verification Relationships (`auth`, `asm`, `agm`, `inv`, `del`) without any members ****MUST**** be omitted.

- If there are no [Services](#services) the `svc` property ****MUST**** be omitted.

**Example Root Record**

Expand Down Expand Up @@ -725,8 +724,9 @@ A [[ref:Retention Solution]] is a form of [proof of work](https://en.bitcoin.it/
DID identifier, using input values supplied by a given [gateway](registry/index.html#gateways). The proof of work is
performed using the [SHA-256 hashing algorithm](https://en.wikipedia.org/wiki/SHA-2) over the concatenation of a the
`did` identifier and random [`nonce`](https://en.wikipedia.org/wiki/Cryptographic_nonce) supplied by the user, and a
`hash` value [supplied by the gateway](#get-the-current-challenge). The result of a given proof of work attempt is
referred to as the `retention` value.
`hash` value [supplied by the gateway](#get-the-current-challenge). The source of a given `hash` referred to as a
`hash_source` ****MUST**** be one of the values specified in the [Hash Source Registry](registry/index.html#hash-source).
The result of a given proof of work attempt is referred to as the `retention` value.

The resulting `retention` value is determined to be a valid [[ref:Retention Solution]] based on whether it has the
requisite number of leading zeros defined by the `difficulty`. Difficulty values are
Expand Down Expand Up @@ -894,6 +894,7 @@ surfacing a [[ref:Retention Challenge]].
- **Returns:** `application/json`
- `200` - Success.
- `hash` - **string** - **REQUIRED** - The current hash which is to be used as input for computing a [[ref:Retention Solution]].
- `hash_source` - **string** - **REQUIRED** - The source of the hash as defined by the [Hash Source Registry](registry/index.html#hash-source).
- `difficulty` - **integer** - **REQUIRED** - The current difficulty of the challenge, representing the number of
bits of leading zeros the resulting hash must contain.
- `expiry` - **integer** - An _approximate_ expiry date-time value, if a valid [[ref:Retention Solution]] is
Expand All @@ -907,6 +908,7 @@ surfacing a [[ref:Retention Challenge]].
```json
{
"hash": "000000000000000000022be0c55caae4152d023dd57e8d63dc1a55c1f6de46e7",
"hash_source": "bitcoin",
"difficulty": 26,
"expiry": 1715578600
}
Expand Down Expand Up @@ -1214,6 +1216,11 @@ However, we provide additional guidance for [DID Resolvers](https://www.w3.org/T
[DID Document Metadata](https://www.w3.org/TR/did-core/#did-document-metadata) and
[DID Resolution Metadata](https://www.w3.org/TR/did-core/#did-resolution-metadata) as follows:

::: todo
[](https://github.com/TBD54566975/did-dht-method/issues/136)
Register `types`, `gateway`, and `expiry` types in the [DID Specification Registry](https://www.w3.org/TR/did-spec-registries).
:::

#### DID Document Metadata

* The metadata [`versionId` property](https://www.w3.org/TR/did-core/#dfn-versionid) ****MUST**** be set to the
Expand All @@ -1230,22 +1237,17 @@ for the DID.
* If the [[ref:DID Document]] has [been deactivated](#deactivate) the
[`deactivated` property](https://www.w3.org/TR/did-core/#dfn-deactivated) ****MUST**** be set to `true`.

#### DID Resolution Metadata

* The metadata `types` property ****MUST**** be set to the array of strings representing type values, if
[type data](#type-indexing) is present in the [[ref:DID Document]]'s packet.

* The metadata `gateway` property ****MUST**** be set to the string representing the [[ref:Gateway]]'s URI
from which the DID was resolved. This is useful in cases where a [DID Resolvers](https://www.w3.org/TR/did-core/#dfn-did-resolvers)
performs resolution against an [Authoritative Gateway](#designating-authoritative-gateways).

* The metadata `expiry` property ****MUST**** be set to the integer representing the expiry date-time value
for the DID in the [[ref:Gateway]]'s [Retained DID Set](#retained-did-set).

::: todo
[](https://github.com/TBD54566975/did-dht-method/issues/136)
Register `types`, `gateway`, and `expiry` types in the [DID Specification Registry](https://www.w3.org/TR/did-spec-registries/#did-document-metadata).
:::
#### DID Resolution Metadata

* The metaata `gateway` property ****MUST**** be set to the string representing the [[ref:Gateway]]'s URI
from which the DID was resolved. This is useful in cases where a [DID Resolvers](https://www.w3.org/TR/did-core/#dfn-did-resolvers)
performs resolution against an [Authoritative Gateway](#designating-authoritative-gateways).

## Security and Privacy Considerations

Expand Down

0 comments on commit 6c5a813

Please sign in to comment.