From 539ac9915ed0d583e1b7033e3affc1e4d67a0002 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 4 May 2022 14:58:46 +0300 Subject: [PATCH] [#237] client: Sign container ID value at container removal Container contract expects signature of container ID value, which is SHA256 of container body. Not the signature of stable marshaled container.ID structure. Signed-off-by: Alex Vanin --- client/container.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/client/container.go b/client/container.go index b58f66e..be67260 100644 --- a/client/container.go +++ b/client/container.go @@ -446,14 +446,13 @@ func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) (* var cidV2 refs.ContainerID prm.id.WriteToV2(&cidV2) - data, err := cidV2.StableMarshal(nil) - if err != nil { - return nil, fmt.Errorf("marshal container ID: %w", err) - } + // container contract expects signature of container ID value + // don't get confused with stable marshaled protobuf container.ID structure + data := cidV2.GetValue() var sig neofscrypto.Signature - err = sig.Calculate(neofsecdsa.SignerRFC6979(c.prm.key), data) + err := sig.Calculate(neofsecdsa.SignerRFC6979(c.prm.key), data) if err != nil { return nil, fmt.Errorf("calculate signature: %w", err) }