simplify by removing cbor and full merkle tree

This commit is contained in:
hzrd149
2024-11-12 10:04:25 +00:00
parent 4d82f98b3c
commit e39afe2149

View File

@@ -6,7 +6,7 @@
Breaking large blobs into smaller chunks for distribution
### Chunking method
### Chunking
The client MAY break large blobs into any number or size of chunks. although its recommended to use the size `1Mb` or `4Mb` for small and large chunks
@@ -14,68 +14,69 @@ Clients MUST NOT pad the remaining chunk, If clients need privacy they should us
Clients MUST create a merkle tree using the chunk hashes as the leaf nodes
### Merkle tree encoding
### Publishing
The merkle tree MUST be in the format of `[<root hash (Uint8)>, <left>, <right>]` and be encoded using [`CBOR`](https://cbor.io/)
Clients should publish a `2001` kind event after chunking the file in order to store the list of chunks
The events `content` MUST be set to am ordered JSON array of the chunks sha256 hashes. e.g.
Example:
```json
[
"7e668b56a58c7891e0cf263ea3f093b75eebade23d663a45aa9920f347b3d671", // A
"9b9c44a91396f19fd8700986eb0586dff2dcccf96c75bc2caefef302bcd78da1", // B
"7a281548f1223664b855b10b08e59e84389ccabeb742517f6cd75eda2724a798", // C
"fadeccee86b123088bbc452df10e8fbc99d4c2f22a70ef7a35605ec8e439c345", // D
"5d62398419e6d136771541f3d2215e0ce31b1be45e99dbc64b43a4b734b447ca" // E
]
```
The event MUST have an `x` tag with the value of the unsorted sha256 [Merkle root](https://en.wikipedia.org/wiki/Merkle_tree)
Example merkle tree:
```mermaid
graph TD
Root["Root (ABCDEFG)"] --> H1["ABCD"]
Root --> H2["EFG"]
Root["Root (ABCDE)"] --> ABCD
Root --> E
H1 --> H3["AB"]
H1 --> H4["CD"]
H2 --> H5["EF"]
H2 --> H6["G"]
ABCD --> AB
ABCD --> CD
H3 --> A["A"]
H3 --> B["B"]
H4 --> C["C"]
H4 --> D["D"]
H5 --> E["E"]
H5 --> F["F"]
H6 --> G["G"]
AB --> A
AB --> B
CD --> C
CD --> D
```
```
[Unit8(ABCDEFG),
[Unit8(ABCD),
[Unit8(AB),
Unit8(A),
Unit8(B)
],
[Unit8(CD),
Unit8(C),
Unit8(D)
]
],
[Unit8(EFG),
[Unit8(EF),
Unit8(E),
Unit8(F)
],
[Unit8(G),
Unit8(G)
]
]
];
```
### Metadata
### Merkle tree storage
Clients MAY choose to store the merkle tree on nostr relays using the `2001` kind event
The event MUST include an `x` tag with the merkle root to the `2001` event
The event MAY include additional metadata tags to help other clients know the filename, mime type or servers to download from
The `2001` event MAY include additional metadata tags to help other clients know the filename, mime type or servers to download from
Metadata tags:
- `name` Filename
- `summary` A short summary of the file
- `m` Mime type of file
- `size` Total size in bytes of the file
- `x` Merkle root
- `server` (multiple) Recommended servers to download chunks from
### Examples
Example `2001` event
```json
{
"id": "9d0a95a2d2681a758ca4023256e62ff71494d8346b62f11601029b1f74b3b933",
"pubkey": "84ac0424fa2dec0ffd6a1f256afd1d18304cc127081f2c81da499fe4b875f1d6",
"created_at": 1731405194,
"kind": 2001,
"content": "[\"7e668b56a58c7891e0cf263ea3f093b75eebade23d663a45aa9920f347b3d671\",\"9b9c44a91396f19fd8700986eb0586dff2dcccf96c75bc2caefef302bcd78da1\",\"7a281548f1223664b855b10b08e59e84389ccabeb742517f6cd75eda2724a798\",\"fadeccee86b123088bbc452df10e8fbc99d4c2f22a70ef7a35605ec8e439c345\",\"5d62398419e6d136771541f3d2215e0ce31b1be45e99dbc64b43a4b734b447ca\"]",
"tags": [
[ "x", "ebb6b0c58ad555db23c9a34e449ea8d37cfc9644cc0982f0facea11d1c3dfab0" ],
[ "name", "example.mp4" ],
[ "m", "video/mp4" ],
[ "size", "4823449" ],
[ "server", "https://cdn.example.com" ],
[ "server", "https://nostr.download" ]
],
"sig": "f930eceb7dd8f5bfe9c238e7ec124b6ca34fc335688be1aaa1cb41c33f722c86e23a527aadbed266767d5b6224451bddeac9cf9b43ac7c068c8388cbdbcbd189"
}
```