session: change PrivateToken interface methods

This commit replaces PublicKey() and SignData() methods of PrivateToken
with PrivateKey() in order to have the ability to sign data with
session key using service package functions.
This commit is contained in:
Leonard Lyubich 2020-05-18 13:11:39 +03:00
parent ba27e296c3
commit af28735ca6
3 changed files with 7 additions and 39 deletions

View file

@ -4,8 +4,6 @@ import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
crypto "github.com/nspcc-dev/neofs-crypto"
)
type pToken struct {
@ -30,14 +28,9 @@ func NewPrivateToken(validUntil uint64) (PrivateToken, error) {
}, nil
}
// Sign signs data with session private key.
func (t *pToken) Sign(data []byte) ([]byte, error) {
return crypto.Sign(t.sessionKey, data)
}
// PublicKey returns a binary representation of the session public key.
func (t *pToken) PublicKey() []byte {
return crypto.MarshalPublicKey(&t.sessionKey.PublicKey)
// PrivateKey returns a binary representation of the session public key.
func (t *pToken) PrivateKey() *ecdsa.PrivateKey {
return t.sessionKey
}
func (t *pToken) Expired(epoch uint64) bool {