frostfs-api-go/session/types.go

50 lines
1.6 KiB
Go
Raw Normal View History

2019-11-18 13:34:06 +00:00
package session
import (
2020-04-29 09:44:35 +00:00
"context"
"crypto/ecdsa"
2020-03-31 07:05:26 +00:00
"github.com/nspcc-dev/neofs-api-go/internal"
)
2019-11-18 13:34:06 +00:00
// PrivateToken is an interface of session private part.
type PrivateToken interface {
// PublicKey must return a binary representation of session public key.
PublicKey() []byte
2019-11-18 13:34:06 +00:00
// Sign must return the signature of passed data.
//
// Resulting signature must be verified by crypto.Verify function
// with the session public key.
Sign([]byte) ([]byte, error)
}
2019-11-18 13:34:06 +00:00
// PrivateTokenSource is an interface of private token storage with read access.
type PrivateTokenSource interface {
// Fetch must return the storage record corresponding to the passed key.
//
// Resulting error must be ErrPrivateTokenNotFound if there is no corresponding record.
Fetch(TokenID) (PrivateToken, error)
}
// PrivateTokenStore is an interface of the storage of private tokens addressable by TokenID.
type PrivateTokenStore interface {
PrivateTokenSource
// Store must save passed private token in the storage under the given key.
//
// Resulting error must be nil if private token was stored successfully.
Store(TokenID, PrivateToken) error
}
2020-04-29 09:44:35 +00:00
// KeyStore is an interface of the storage of public keys addressable by OwnerID,
type KeyStore interface {
// Get must return the storage record corresponding to the passed key.
//
// Resulting error must be ErrKeyNotFound if there is no corresponding record.
Get(context.Context, OwnerID) ([]*ecdsa.PublicKey, error)
}
2020-04-29 09:50:52 +00:00
// ErrPrivateTokenNotFound is raised when addressed private token was not found in storage.
const ErrPrivateTokenNotFound = internal.Error("private token not found")