628ae20c72
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
27 lines
549 B
Go
27 lines
549 B
Go
package pool
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"crypto/elliptic"
|
|
"crypto/rand"
|
|
"math/big"
|
|
)
|
|
|
|
// NewEphemeralKey creates new private key used for NeoFS session. It'll be
|
|
// removed after refactoring to use neo-go crypto library.
|
|
func NewEphemeralKey() (*ecdsa.PrivateKey, error) {
|
|
c := elliptic.P256()
|
|
priv, x, y, err := elliptic.GenerateKey(c, rand.Reader)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
key := &ecdsa.PrivateKey{
|
|
PublicKey: ecdsa.PublicKey{
|
|
Curve: c,
|
|
X: x,
|
|
Y: y,
|
|
},
|
|
D: new(big.Int).SetBytes(priv),
|
|
}
|
|
return key, nil
|
|
}
|