[#105] neofsid: Add docs

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-07-13 21:08:27 +03:00 committed by Alex Vanin
parent a23b56fff9
commit 47af5e3f9c
2 changed files with 35 additions and 1 deletions

View file

@ -1,2 +1,20 @@
// NeoFSID contract description. /*
NeoFSID contract is a contract deployed in NeoFS side chain.
NeoFSID contract used to store connection between OwnerID and it's public keys.
OwnerID is a 25-byte N3 wallet address that can be produced from public key.
It is one-way conversion. In simple cases NeoFS verifies ownership by checking
signature and relation between public key and OwnerID.
In more complex cases, user can use public keys unrelated to OwnerID to maintain
secure access to the data. NeoFSID contract stores relation between OwnerID and
arbitrary public keys. Data owner can bind or unbind public key with it's account
by invoking Bind or Unbind methods of NeoFS contract in main chain. After that,
Alphabet nodes produce multi signed AddKey and RemoveKey invocations of NeoFSID
contract.
Contract notifications
NeoFSID contract does not produce notifications to process.
*/
package neofsid package neofsid

View file

@ -60,6 +60,8 @@ func _deploy(data interface{}, isUpdate bool) {
runtime.Log("neofsid contract initialized") runtime.Log("neofsid contract initialized")
} }
// Migrate method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Migrate(script []byte, manifest []byte, data interface{}) bool { func Migrate(script []byte, manifest []byte, data interface{}) bool {
ctx := storage.GetReadOnlyContext() ctx := storage.GetReadOnlyContext()
@ -74,6 +76,11 @@ func Migrate(script []byte, manifest []byte, data interface{}) bool {
return true return true
} }
// 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.
// If key is already bound, ignores it.
func AddKey(owner []byte, keys []interop.PublicKey) { func AddKey(owner []byte, keys []interop.PublicKey) {
if len(owner) != 25 { if len(owner) != 25 {
panic("addKey: incorrect owner") panic("addKey: incorrect owner")
@ -142,6 +149,11 @@ addLoop:
runtime.Log("addKey: key bound to the owner") runtime.Log("addKey: key bound to the owner")
} }
// 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.
// If key is already unbound, ignores it.
func RemoveKey(owner []byte, keys []interop.PublicKey) { func RemoveKey(owner []byte, keys []interop.PublicKey) {
if len(owner) != 25 { if len(owner) != 25 {
panic("removeKey: incorrect owner") panic("removeKey: incorrect owner")
@ -206,6 +218,9 @@ rmLoop:
common.SetSerialized(ctx, owner, info) common.SetSerialized(ctx, owner, info)
} }
// Key method returns list of 33-byte public keys bound with OwnerID.
//
// This method panics if owner is not 25 byte long.
func Key(owner []byte) [][]byte { func Key(owner []byte) [][]byte {
if len(owner) != 25 { if len(owner) != 25 {
panic("key: incorrect owner") panic("key: incorrect owner")
@ -218,6 +233,7 @@ func Key(owner []byte) [][]byte {
return info.Keys return info.Keys
} }
// Version returns version of the contract.
func Version() int { func Version() int {
return version return version
} }