forked from TrueCloudLab/frostfs-sdk-go
Alex Vanin
94476f9055
Due to source code relocation from GitHub. Signed-off-by: Alex Vanin <a.vanin@yadro.com>
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
/*
|
|
Package user provides functionality related to FrostFS users.
|
|
|
|
User identity is reflected in ID type. Each user has its own unique identifier
|
|
within the same network.
|
|
|
|
FrostFS user identification is compatible with Neo accounts:
|
|
|
|
import "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
import "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
|
|
|
var id user.ID
|
|
|
|
var scriptHash util.Uint160 // user account in FrostFS
|
|
id.SetScriptHash(scriptHash)
|
|
|
|
var key keys.PublicKey // user's public key
|
|
user.IDFromKey(&id, k.PrivateKey.PublicKey)
|
|
|
|
ID is compatible with the FrostFS Smart Contract API:
|
|
|
|
var id user.ID
|
|
// ...
|
|
|
|
wallet := id.WalletBytes()
|
|
|
|
// use wallet in call
|
|
|
|
Encoding/decoding mechanisms are used to transfer identifiers:
|
|
|
|
var id user.ID
|
|
// ...
|
|
|
|
s := id.EncodeToString() // on transmitter
|
|
err = id.DecodeString(s) // on receiver
|
|
|
|
Instances can be also used to process FrostFS API protocol messages
|
|
(see neo.fs.v2.refs package in https://git.frostfs.info/TrueCloudLab/frostfs-api).
|
|
|
|
On client side:
|
|
|
|
import "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
|
|
|
|
var msg refs.OwnerID
|
|
id.WriteToV2(&msg)
|
|
|
|
// send msg
|
|
|
|
On server side:
|
|
|
|
// recv msg
|
|
|
|
var id user.ID
|
|
|
|
err := id.ReadFromV2(msg)
|
|
// ...
|
|
|
|
// process id
|
|
*/
|
|
package user
|