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

Function TestCipheringBasic

crypto/cipher_test.go:30–51  ·  view source on GitHub ↗

Test 1: Encryption and decryption.

(t *testing.T)

Source from the content-addressed store, hash-verified

28
29// Test 1: Encryption and decryption.
30func TestCipheringBasic(t *testing.T) {
31 privkey, _, err := asymmetric.GenSecp256k1KeyPair()
32 if err != nil {
33 t.Fatal("failed to generate private key")
34 }
35
36 in := []byte("Hey there dude. How are you doing? This is a test.")
37
38 out, err := EncryptAndSign(privkey.PubKey(), in)
39 if err != nil {
40 t.Fatal("failed to encrypt:", err)
41 }
42
43 dec, err := DecryptAndCheck(privkey, out)
44 if err != nil {
45 t.Fatal("failed to decrypt:", err)
46 }
47
48 if !bytes.Equal(in, dec) {
49 t.Error("decrypted data doesn't match original")
50 }
51}
52
53func TestCipheringErrors(t *testing.T) {
54 privkey, _, err := asymmetric.GenSecp256k1KeyPair()

Callers

nothing calls this directly

Calls 6

GenSecp256k1KeyPairFunction · 0.92
EncryptAndSignFunction · 0.85
DecryptAndCheckFunction · 0.85
FatalMethod · 0.80
PubKeyMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected