From 20a2515f6f409c88e7917f2ad3ad14d2f4af84d5 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 11 Jul 2024 12:11:43 +0400 Subject: [PATCH] refs: Prohibit IDs consisting of all zero bytes Container and object IDs are SHA-256 checksums of their contents. It is almost impossible to find data that corresponds to a zero identifier. Setting 32 zeros rather indicates a client error. Reserving a zero value will also make application development easier: corresponding type will have a reserved invalid value within itself. Even if the unimaginable and some structure will actually have a zero hash - so be it, the problem is negligible for the final benefit. Note that zero `OwnerID` is already invalid at least due to the non-zero prefix. Therefore does not need clarification. Signed-off-by: Leonard Lyubich --- proto-docs/refs.md | 6 ++++-- refs/types.proto | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/proto-docs/refs.md b/proto-docs/refs.md index 18d32c4..27222e0 100644 --- a/proto-docs/refs.md +++ b/proto-docs/refs.md @@ -71,7 +71,8 @@ content-addressed. `ContainerID` is a 32 byte long [SHA256](https://csrc.nist.gov/publications/detail/fips/180/4/final) hash of -stable-marshalled container message. +stable-marshalled container message. ID consisting of all zero bytes is +reserved for undefined value and must not be specified as a field. String presentation is a [base58](https://tools.ietf.org/html/draft-msporny-base58-02) encoded string. @@ -97,7 +98,8 @@ It means `ObjectID` will change if the `header` or the `payload` changes. `ObjectID` is a 32 byte long [SHA256](https://csrc.nist.gov/publications/detail/fips/180/4/final) hash of the object's `header` field, which, in it's turn, contains the hash of the object's -payload. +payload. ID consisting of all zero bytes is reserved for undefined value and +must not be specified as a field. String presentation is a [base58](https://tools.ietf.org/html/draft-msporny-base58-02) encoded string. diff --git a/refs/types.proto b/refs/types.proto index 2986792..70c941b 100644 --- a/refs/types.proto +++ b/refs/types.proto @@ -22,7 +22,8 @@ message Address { // `ObjectID` is a 32 byte long // [SHA256](https://csrc.nist.gov/publications/detail/fips/180/4/final) hash of // the object's `header` field, which, in it's turn, contains the hash of the object's -// payload. +// payload. ID consisting of all zero bytes is reserved for undefined value and +// must not be specified as a field. // // String presentation is a // [base58](https://tools.ietf.org/html/draft-msporny-base58-02) encoded string. @@ -42,7 +43,8 @@ message ObjectID { // // `ContainerID` is a 32 byte long // [SHA256](https://csrc.nist.gov/publications/detail/fips/180/4/final) hash of -// stable-marshalled container message. +// stable-marshalled container message. ID consisting of all zero bytes is +// reserved for undefined value and must not be specified as a field. // // String presentation is a // [base58](https://tools.ietf.org/html/draft-msporny-base58-02) encoded string.