2022-04-11 06:30:22 +00:00
|
|
|
/*
|
2022-12-29 10:46:18 +00:00
|
|
|
Package user provides functionality related to FrostFS users.
|
2022-04-11 06:30:22 +00:00
|
|
|
|
|
|
|
User identity is reflected in ID type. Each user has its own unique identifier
|
|
|
|
within the same network.
|
|
|
|
|
2022-12-29 10:46:18 +00:00
|
|
|
FrostFS user identification is compatible with Neo accounts:
|
2022-08-24 14:17:40 +00:00
|
|
|
|
2022-04-11 06:30:22 +00:00
|
|
|
import "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
|
|
import "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
|
|
|
|
|
|
|
var id user.ID
|
|
|
|
|
2022-12-29 10:46:18 +00:00
|
|
|
var scriptHash util.Uint160 // user account in FrostFS
|
2022-04-11 06:30:22 +00:00
|
|
|
id.SetScriptHash(scriptHash)
|
|
|
|
|
|
|
|
var key keys.PublicKey // user's public key
|
|
|
|
user.IDFromKey(&id, k.PrivateKey.PublicKey)
|
|
|
|
|
2022-12-29 10:46:18 +00:00
|
|
|
ID is compatible with the FrostFS Smart Contract API:
|
2022-08-24 14:17:40 +00:00
|
|
|
|
2022-04-11 06:30:22 +00:00
|
|
|
var id user.ID
|
|
|
|
// ...
|
|
|
|
|
|
|
|
wallet := id.WalletBytes()
|
|
|
|
|
|
|
|
// use wallet in call
|
|
|
|
|
|
|
|
Encoding/decoding mechanisms are used to transfer identifiers:
|
2022-08-24 14:17:40 +00:00
|
|
|
|
2022-04-11 06:30:22 +00:00
|
|
|
var id user.ID
|
|
|
|
// ...
|
|
|
|
|
|
|
|
s := id.EncodeToString() // on transmitter
|
|
|
|
err = id.DecodeString(s) // on receiver
|
|
|
|
|
2022-12-29 10:46:18 +00:00
|
|
|
Instances can be also used to process FrostFS API protocol messages
|
2023-03-07 11:20:03 +00:00
|
|
|
(see neo.fs.v2.refs package in https://git.frostfs.info/TrueCloudLab/frostfs-api).
|
2022-04-11 06:30:22 +00:00
|
|
|
|
|
|
|
On client side:
|
2022-08-24 14:17:40 +00:00
|
|
|
|
2023-03-07 11:20:03 +00:00
|
|
|
import "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
2022-04-11 06:30:22 +00:00
|
|
|
|
|
|
|
var msg refs.OwnerID
|
|
|
|
id.WriteToV2(&msg)
|
|
|
|
|
|
|
|
// send msg
|
|
|
|
|
|
|
|
On server side:
|
2022-08-24 14:17:40 +00:00
|
|
|
|
2022-04-11 06:30:22 +00:00
|
|
|
// recv msg
|
|
|
|
|
|
|
|
var id user.ID
|
|
|
|
|
|
|
|
err := id.ReadFromV2(msg)
|
|
|
|
// ...
|
|
|
|
|
|
|
|
// process id
|
|
|
|
*/
|
|
|
|
package user
|