MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestGenSecp256k1Keypair

Function TestGenSecp256k1Keypair

crypto/asymmetric/keypair_test.go:32–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func 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
57func TestGenECDHSharedSecret(t *testing.T) {
58 privateKey1, publicKey1, _ := GenSecp256k1KeyPair()

Callers

nothing calls this directly

Calls 5

DebugfFunction · 0.92
GenSecp256k1KeyPairFunction · 0.85
FatalMethod · 0.80
ErrorMethod · 0.80
SerializeMethod · 0.45

Tested by

no test coverage detected