diff --git a/README.md b/README.md index e171a16..51328f3 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ See the [BUDs](./buds) folder and specifically [BUD-01](./buds/01.md) and [BUD-0 - [BUD-04: Mirroring blobs](./buds/04.md) - [BUD-06: Upload requirements](./buds/06.md) - [BUD-08: Nostr File Metadata Tags](./buds/08.md) +- [BUD-10: Chunked blobs](./buds/10.md) ## Event kinds @@ -49,6 +50,7 @@ See the [BUDs](./buds) folder and specifically [BUD-01](./buds/01.md) and [BUD-0 | ------- | ------------------- | ------------------ | | `24242` | Authorization event | [01](./buds/01.md) | | `10063` | User Server List | [03](./buds/03.md) | +| `2001` | Merkle tree | [10](./buds/10.md) | ## License diff --git a/buds/10.md b/buds/10.md new file mode 100644 index 0000000..7263a4e --- /dev/null +++ b/buds/10.md @@ -0,0 +1,82 @@ +# BUD-10 + +## Chunked blobs + +`draft` `optional` + +Breaking large blobs into smaller chunks for distribution + +### Chunking method + +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 + +Clients SHOULD not pad the remaining chunk, If clients need privacy they should use random chunk sizes and optionally encrypt the large blob + +Clients MUST create a merkle tree using the chunk hashes as the leaf nodes + +### Merkle tree encoding + +Clients MAY choose to store the merkle tree on nostr relays using the `2001` kind event + +The merkle tree MUST be in the format of `[, , ]` + +The merkle tree MUST be stored in the events `content` as a base64 encoded [`CBOR`](https://cbor.io/) object + +Clients MUST add an `x` tag with the merkle root to the `2001` event + +Example: + +```marmaid +graph TD + Root["Root (ABCDEFG)"] --> H1["ABCD"] + Root --> H2["EFG"] + + H1 --> H3["AB"] + H1 --> H4["CD"] + H2 --> H5["EF"] + H2 --> H6["G"] + + H3 --> A["A"] + H3 --> B["B"] + H4 --> C["C"] + H4 --> D["D"] + H5 --> E["E"] + H5 --> F["F"] + H6 --> G["G"] +``` + +``` +[Unit8(ABCDEFG), + [Unit8(ABCD), + [Unit(AB), + Unit(A), + Unit(B) + ], + [Unit(CD), + Unit(C), + Unit(D) + ] + ], + [Unit(EFG), + [Unit(EF), + Unit(E), + Unit(F) + ], + [Unit(G), + Unit(G) + ] + ] +]; +``` + +### Metadata + +Clients MAY include additional metadata tags in the `2001` event to help other clients know the filename or mime type + +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