Documentation
¶
Overview ¶
Package user provides functionality related to NeoFS users.
User identity is reflected in ID type. Each user has its own unique identifier within the same network.
Index ¶
Examples ¶
Constants ¶
const IDSize = 25
IDSize is the size of an ID in bytes.
Variables ¶
var ErrZeroID = errors.New("zero user ID")
ErrZeroID is an error returned on zero ID encounter.
Functions ¶
This section is empty.
Types ¶
type ID ¶
ID identifies users of the NeoFS system and represents Neo3 account address. Zero ID is usually prohibited, see docs for details.
ID implements built-in comparable interface.
ID is mutually compatible with refs.OwnerID message. See ID.FromProtoMessage / ID.ProtoMessage methods.
Example (Marshalling) ¶
Instances can be also used to process NeoFS API V2 protocol messages with [https://github.com/nspcc-dev/neofs-api] package.
package main
import (
"github.com/nspcc-dev/neofs-sdk-go/user"
)
func main() {
// On the client side.
var id user.ID
msg := id.ProtoMessage()
// *send message*
// On the server side.
_ = id.FromProtoMessage(msg)
}
Output:
func DecodeString ¶
DecodeString creates new ID and makes ID.DecodeString.
func NewFromECDSAPublicKey ¶
NewFromECDSAPublicKey creates new ID corresponding to Neo3 verification script hash of the given ECDSA public key. The point must be on the [elliptic.P256] curve.
func NewFromScriptHash ¶
NewFromScriptHash creates new ID and makes [ID.SetScriptHash].
func (*ID) DecodeString ¶
DecodeString decodes NeoFS API V2 protocol string. Returns an error if s is malformed. Use DecodeString to decode s into a new ID.
DecodeString always changes the ID.
See also EncodeToString.
Example ¶
Encoding mechanisms are used to transfer identifiers on server.
package main
import (
"github.com/nspcc-dev/neofs-sdk-go/user"
)
func main() {
var id user.ID
// ...
var s string
_ = id.DecodeString(s)
}
Output:
func (ID) EncodeToString ¶
EncodeToString encodes ID into NeoFS API V2 protocol string.
See also DecodeString.
Example ¶
Encoding mechanisms are used to transfer identifiers on client.
package main
import (
"github.com/nspcc-dev/neofs-sdk-go/user"
)
func main() {
var id user.ID
// ...
_ = id.EncodeToString()
}
Output:
func (*ID) FromProtoMessage ¶
FromProtoMessage validates m according to the NeoFS API protocol and restores x from it.
See also ID.ProtoMessage.
func (ID) ProtoMessage ¶
ProtoMessage converts x into message to transmit using the NeoFS API protocol.
See also ID.FromProtoMessage.
func (ID) ScriptHash ¶
ScriptHash gets scripthash from user ID.
type Signer ¶
type Signer interface {
// Signer signs data on behalf of the user.
neofscrypto.Signer
// UserID returns ID of the associated user.
UserID() ID
}
Signer represents a NeoFS user authorized by a digital signature.
func NewAutoIDSigner ¶
func NewAutoIDSigner(key ecdsa.PrivateKey) Signer
NewAutoIDSigner returns Signer with neofscrypto.ECDSA_SHA512 signature scheme and user ID automatically resolved from the ECDSA public key.
See also NewAutoIDSignerRFC6979.
func NewAutoIDSignerRFC6979 ¶
func NewAutoIDSignerRFC6979(key ecdsa.PrivateKey) Signer
NewAutoIDSignerRFC6979 is an analogue of NewAutoIDSigner but with neofscrypto.ECDSA_DETERMINISTIC_SHA256 signature scheme.
func NewSigner ¶
func NewSigner(s neofscrypto.Signer, usr ID) Signer
NewSigner combines provided neofscrypto.Signer and ID into Signer.
See also NewAutoIDSigner.