Documentation ¶
Overview ¶
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://github.com/TrueCloudLab/frostfs-api).
On client side:
import "github.com/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
Index ¶
- func IDFromKey(id *ID, key ecdsa.PublicKey)
- type ID
- func (x *ID) DecodeString(s string) error
- func (x ID) EncodeToString() string
- func (x ID) Equals(x2 ID) bool
- func (x *ID) ReadFromV2(m refs.OwnerID) error
- func (x *ID) SetScriptHash(scriptHash util.Uint160)
- func (x ID) String() string
- func (x ID) WalletBytes() []byte
- func (x ID) WriteToV2(m *refs.OwnerID)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
ID identifies users of the FrostFS system.
ID is mutually compatible with github.com/TrueCloudLab/frostfs-api-go/v2/refs.OwnerID message. See ReadFromV2 / WriteToV2 methods.
Instances can be created using built-in var declaration. Zero ID is not valid, so it MUST be initialized using some modifying function (e.g. SetScriptHash, IDFromKey, etc.).
func (*ID) DecodeString ¶
DecodeString decodes FrostFS API V2 protocol string. Returns an error if s is malformed.
DecodeString always changes the ID.
See also EncodeToString.
func (ID) EncodeToString ¶
EncodeToString encodes ID into FrostFS API V2 protocol string.
See also DecodeString.
func (*ID) ReadFromV2 ¶
ReadFromV2 reads ID from the refs.OwnerID message. Returns an error if the message is malformed according to the FrostFS API V2 protocol.
See also WriteToV2.
func (*ID) SetScriptHash ¶
SetScriptHash forms user ID from wallet address scripthash.
func (ID) String ¶
String implements fmt.Stringer.
String is designed to be human-readable, and its format MAY differ between SDK versions. String MAY return same result as EncodeToString. String MUST NOT be used to encode ID into FrostFS protocol string.
func (ID) WalletBytes ¶
WalletBytes returns FrostFS user ID as Neo3 wallet address in a binary format.
Return value MUST NOT be mutated: to do this, first make a copy.
See also Neo3 wallet docs.