Skip to content

Commit

Permalink
refs: Prohibit IDs consisting of all zero bytes
Browse files Browse the repository at this point in the history
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 <leonard@morphbits.io>
  • Loading branch information
cthulhu-rider committed Jul 11, 2024
1 parent 62e4ae0 commit 20a2515
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions proto-docs/refs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions refs/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 20a2515

Please # to comment.