From b138a714689cd6be9bb56f5f51539a7fccf59fab Mon Sep 17 00:00:00 2001 From: Aaron D Goldman Date: Thu, 7 Dec 2023 23:04:37 -0800 Subject: [PATCH] Add context to CIP124 EventIDs --- CIPs/cip-124.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/CIPs/cip-124.md b/CIPs/cip-124.md index 3e87f57..4fc7471 100644 --- a/CIPs/cip-124.md +++ b/CIPs/cip-124.md @@ -48,13 +48,14 @@ An eventId is a special type of [StreamId](https://cips.ceramic.network/CIPs/cip ```js concatBytes( - varint(0xce), // streamid varint - varint(0x05), // cip-124 EventID varint - varint(network_id), // network_id varint - last8bytes(sha256(sort_value)), // separator [u8; 8] + varint(0xce), // streamid varint b'\xce\x01' + varint(0x05), // cip-124 EventID varint b'\x05' + varint(network_id), // network_id varint 1 or 5 bytes + last8Bytes(sha256(separator_key + "|" + separator_value)), // separator [u8; 8] + context_value // [u8; 8] + cbor(blockNumber), // 0 - u64_max; 1-9 bytes last8bytes(sha256(controller)), // controller [u8; 8] last4bytes(init_event_cid_bytes), // StreamID [u8; 4] - cbor(event_height), // event_height cbor unsigned int event_cid_bytes, // [u8] ) ``` @@ -63,10 +64,15 @@ Where: * `0xce` is the streamid multicode as defined in the [multicodec table](https://github.com/multiformats/multicodec/blob/master/table.csv). * `0x05` is the streamtype code for an cip-124 EventID as defined in the [streamTypes table](../tables/streamtypes.csv). * `network_id` is a number as defined in the [networkIds table](../tables/networkIds.csv) -* `sort_value` is based on a user provided value for *sort-key* and *sort-value* +* `separator_key` is the header field that has the separator_value in it. +* `separator_value` is the value in the field specified by the separator_key +* `context_key` is the header field that has the context_value in it. +* `context_value` is the first 8 bytes of the value in the field specified by the context_key. +* `blockNumber` is the ETH blockNumber from the after header or a prev time event. + * If the after header is not present then follow the prev cain to a time event. + * If there is no time event in the chain then use 0 * `controller` is the controller DID of the stream this event belongs to * `init_event_cid_bytes` is the CID of the first Event of the this stream. -* `event_height` is the "height" of the event InitEvent. For InitEvents this value is `0` else `prev.event_height + 1`. * `event_cid_bytes` the CID of the event itself * `last8bytes` and `last4bytes` takes the last N bytes of the input and prepends with zeros if the input is shorter