[#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 <alexey@nspcc.ru>
This commit is contained in:
parent
526b45e207
commit
539ac9915e
1 changed files with 4 additions and 5 deletions
|
@ -446,14 +446,13 @@ func (c *Client) ContainerDelete(ctx context.Context, prm PrmContainerDelete) (*
|
||||||
var cidV2 refs.ContainerID
|
var cidV2 refs.ContainerID
|
||||||
prm.id.WriteToV2(&cidV2)
|
prm.id.WriteToV2(&cidV2)
|
||||||
|
|
||||||
data, err := cidV2.StableMarshal(nil)
|
// container contract expects signature of container ID value
|
||||||
if err != nil {
|
// don't get confused with stable marshaled protobuf container.ID structure
|
||||||
return nil, fmt.Errorf("marshal container ID: %w", err)
|
data := cidV2.GetValue()
|
||||||
}
|
|
||||||
|
|
||||||
var sig neofscrypto.Signature
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("calculate signature: %w", err)
|
return nil, fmt.Errorf("calculate signature: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue