diff --git a/neofsid/neofsid_contract.go b/neofsid/neofsid_contract.go index 6849010..667d009 100644 --- a/neofsid/neofsid_contract.go +++ b/neofsid/neofsid_contract.go @@ -18,6 +18,10 @@ type ( } ) +const ( + ownerSize = 1 + interop.Hash160Len + 4 +) + const ( netmapContractKey = "netmapScriptHash" containerContractKey = "containerScriptHash" @@ -33,7 +37,7 @@ func _deploy(data interface{}, isUpdate bool) { for iterator.Next(it) { kv := iterator.Value(it).([][]byte) // V2 format - if len(kv[0]) == 25 { + if len(kv[0]) == ownerSize { info := std.Deserialize(kv[1]).(UserInfo) key := append([]byte{ownerKeysPrefix}, kv[0]...) for i := range info.Keys { @@ -83,11 +87,11 @@ func Update(script []byte, manifest []byte, data interface{}) { // AddKey binds list of provided public keys to OwnerID. Can be invoked only by // Alphabet nodes. // -// This method panics if OwnerID is not 25 byte or public key is not 33 byte long. +// This method panics if OwnerID is not ownerSize byte or public key is not 33 byte long. // If key is already bound, ignores it. func AddKey(owner []byte, keys []interop.PublicKey) { // V2 format - if len(owner) != 25 { + if len(owner) != ownerSize { panic("incorrect owner") } @@ -147,11 +151,11 @@ func AddKey(owner []byte, keys []interop.PublicKey) { // RemoveKey unbinds provided public keys from OwnerID. Can be invoked only by // Alphabet nodes. // -// This method panics if OwnerID is not 25 byte or public key is not 33 byte long. +// This method panics if OwnerID is not ownerSize byte or public key is not 33 byte long. // If key is already unbound, ignores it. func RemoveKey(owner []byte, keys []interop.PublicKey) { // V2 format - if len(owner) != 25 { + if len(owner) != ownerSize { panic("incorrect owner") } @@ -201,10 +205,10 @@ func RemoveKey(owner []byte, keys []interop.PublicKey) { // Key method returns list of 33-byte public keys bound with OwnerID. // -// This method panics if owner is not 25 byte long. +// This method panics if owner is not ownerSize byte long. func Key(owner []byte) [][]byte { // V2 format - if len(owner) != 25 { + if len(owner) != ownerSize { panic("incorrect owner") }