-
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathx25519_test.go
More file actions
32 lines (24 loc) · 822 Bytes
/
x25519_test.go
File metadata and controls
32 lines (24 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package keys_test
import (
"fmt"
"testing"
"github.com/keys-pub/keys"
"github.com/stretchr/testify/require"
)
func TestNewX25519KeyFromPrivateKey(t *testing.T) {
// Test new X25519Key and X25519Key from private key are the same
X25519Key := keys.GenerateX25519Key()
X25519KeyOut := keys.NewX25519KeyFromPrivateKey(X25519Key.PrivateKey())
require.Equal(t, X25519Key.PrivateKey(), X25519KeyOut.PrivateKey())
require.Equal(t, X25519Key.PublicKey().Bytes(), X25519KeyOut.PublicKey().Bytes())
}
func TestX25519KeyConversion(t *testing.T) {
sk := keys.GenerateEdX25519Key()
bk := sk.X25519Key()
bpk := sk.PublicKey().X25519PublicKey()
require.Equal(t, bk.PublicKey().Bytes()[:], bpk.Bytes()[:])
}
func ExampleGenerateX25519Key() {
alice := keys.GenerateX25519Key()
fmt.Printf("Alice: %s\n", alice.ID())
}