forked from TrueCloudLab/frostfs-sdk-go
Alex Vanin
94476f9055
Due to source code relocation from GitHub. Signed-off-by: Alex Vanin <a.vanin@yadro.com>
24 lines
683 B
Go
24 lines
683 B
Go
package user_test
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
"crypto/elliptic"
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestIDFromKey(t *testing.T) {
|
|
// examples are taken from https://docs.neo.org/docs/en-us/basic/concept/wallets.html
|
|
rawPub, _ := hex.DecodeString("03cdb067d930fd5adaa6c68545016044aaddec64ba39e548250eaea551172e535c")
|
|
x, y := elliptic.UnmarshalCompressed(elliptic.P256(), rawPub)
|
|
require.True(t, x != nil && y != nil)
|
|
|
|
var id user.ID
|
|
|
|
user.IDFromKey(&id, ecdsa.PublicKey{Curve: elliptic.P256(), X: x, Y: y})
|
|
|
|
require.Equal(t, "NNLi44dJNXtDNSBkofB48aTVYtb1zZrNEs", id.EncodeToString())
|
|
}
|