From 526792324db66dc31ad82a7aa05aeb35f6e90046 Mon Sep 17 00:00:00 2001 From: Stanislav Bogatyrev Date: Tue, 18 Aug 2020 18:26:51 +0300 Subject: [PATCH] [#56] Add separate checksum type NeoFS uses different checksum algorithms. It looks like we need to explicitly define what algorithm is used in each particular case. Signed-off-by: Stanislav Bogatyrev --- object/service.proto | 10 ++++++++-- object/types.proto | 4 ++-- refs/types.proto | 18 ++++++++++++++++++ storagegroup/types.proto | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/object/service.proto b/object/service.proto index 67d41ed..dba34d6 100644 --- a/object/service.proto +++ b/object/service.proto @@ -385,6 +385,9 @@ message GetRangeHashRequest { // Carries binary salt to XOR object payload ranges before hash calculation. bytes salt = 3; + + // Checksum algorithm type + neo.fs.v2.refs.ChecksumType type = 4; } // Body of get range hash object request message. Body body = 1; @@ -402,8 +405,11 @@ message GetRangeHashRequest { message GetRangeHashResponse { // Response body message Body { - // Carries list of homomorphic hashes in a binary format. - repeated bytes hash_list = 1; + // Checksum algorithm type + neo.fs.v2.refs.ChecksumType type = 1; + + // List of range hashes in a binary format. + repeated bytes hash_list = 2; } // Body of get range hash object response message. Body body = 1; diff --git a/object/types.proto b/object/types.proto index 5c448c3..9121d6d 100644 --- a/object/types.proto +++ b/object/types.proto @@ -67,13 +67,13 @@ message Header { uint64 payload_length = 5; // Hash of payload bytes - bytes payload_hash = 6; + Checksum payload_hash = 6; // Special object type ObjectType object_type = 7; // Homomorphic hash of the object payload. - bytes homomorphic_hash = 8; + Checksum homomorphic_hash = 8; // Session token, if it was used during Object creation. // Need it to verify integrity and authenticity out of Request scope. diff --git a/refs/types.proto b/refs/types.proto index a17571d..29ddd2a 100644 --- a/refs/types.proto +++ b/refs/types.proto @@ -47,3 +47,21 @@ message Signature { // Signature bytes sign = 2; } + +// Checksum algorithm type +enum ChecksumType { + // Unknown. Not used + CHECKSUM_TYPE_UNSPECIFIED = 0; + + // Tillich-Zemor homomorphic hash funciton + TZ = 1; + + // SHA-256 + SHA256 = 2; +} + +// Checksum message +message Checksum { + ChecksumType type = 1; + bytes sum = 2; +} diff --git a/storagegroup/types.proto b/storagegroup/types.proto index 196a867..305f2dd 100644 --- a/storagegroup/types.proto +++ b/storagegroup/types.proto @@ -18,7 +18,7 @@ message StorageGroup { // payloads of the storage group members // The order of concatenation is the same as the order of the members in the // Members field. - bytes validation_hash = 2; + Checksum validation_hash = 2; // expiration_epoch carries last NeoFS epoch number of the storage group // lifetime.