(t *testing.T)
| 30 | ) |
| 31 | |
| 32 | func TestGenSecp256k1Keypair(t *testing.T) { |
| 33 | privateKey, publicKey, err := GenSecp256k1KeyPair() |
| 34 | log.Debugf("privateKey: %x", privateKey.Serialize()) |
| 35 | log.Debugf("publicKey: %x", publicKey.Serialize()) |
| 36 | if err != nil { |
| 37 | t.Fatal("failed to generate private key") |
| 38 | } |
| 39 | |
| 40 | in := []byte("Hey there dude. How are you doing? This is a test.") |
| 41 | |
| 42 | out, err := ec.Encrypt((*ec.PublicKey)(publicKey), in) |
| 43 | if err != nil { |
| 44 | t.Fatal("failed to encrypt:", err) |
| 45 | } |
| 46 | |
| 47 | dec, err := ec.Decrypt((*ec.PrivateKey)(privateKey), out) |
| 48 | if err != nil { |
| 49 | t.Fatal("failed to decrypt:", err) |
| 50 | } |
| 51 | |
| 52 | if !bytes.Equal(in, dec) { |
| 53 | t.Error("decrypted data doesn't match original") |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | func TestGenECDHSharedSecret(t *testing.T) { |
| 58 | privateKey1, publicKey1, _ := GenSecp256k1KeyPair() |
nothing calls this directly
no test coverage detected