frostfs-sdk-go/user/doc.go
Pavel Pogodaev 6ce73790ea
All checks were successful
DCO / DCO (pull_request) Successful in 38s
Tests and linters / Tests (pull_request) Successful in 1m13s
Tests and linters / Lint (pull_request) Successful in 2m36s
[#276] Merge repo with frostfs-api-go
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2024-10-22 14:05:12 +00:00

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-sdk-go/api/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