From c58199385eab3b9f7cfec83a98f7b4da688aa473 Mon Sep 17 00:00:00 2001 From: ycc Date: Thu, 15 Feb 2024 23:24:07 +0100 Subject: [PATCH] Addinf trace function for invitation debug --- client/invitationhelpers.go | 1 + client/peer.go | 7 +++++++ endtoend_test.go | 10 +++++----- 3 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 client/invitationhelpers.go diff --git a/client/invitationhelpers.go b/client/invitationhelpers.go new file mode 100644 index 0000000..da13c8e --- /dev/null +++ b/client/invitationhelpers.go @@ -0,0 +1 @@ +package client diff --git a/client/peer.go b/client/peer.go index 5141f8c..e4643da 100644 --- a/client/peer.go +++ b/client/peer.go @@ -184,6 +184,10 @@ func (p *Peer) DeserializeUserMessage(data []byte) (*meowlib.UserMessage, error) // AsymEncryptMessage prepares a message to send to a specific peer contact func (p *Peer) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, error) { var enc *meowlib.EncryptedMessage + fmt.Println("[AsymEncryptMessage] Destination is:", p.ContactLookupKey) + fmt.Println("[AsymEncryptMessage] Contact encryption key is:", p.ContactEncryption) + fmt.Println("[AsymEncryptMessage] My signing key is:", p.MyIdentity.Private) + fmt.Println("[AsymEncryptMessage] Signature should be verified with:", p.MyIdentity.Public) enc, err := meowlib.AsymEncryptAndSign(p.ContactEncryption, p.MyIdentity.Private, Message) if err != nil { fmt.Println(err.Error()) @@ -194,6 +198,9 @@ func (p *Peer) AsymEncryptMessage(Message []byte) (*meowlib.EncryptedMessage, er // AsymDecryptMessage reads a message from a specific peer contact func (p *Peer) AsymDecryptMessage(Message []byte, Signature []byte) (DecryptedMessage []byte, err error) { + fmt.Println("[AsymDecryptMessage] Decrypting key is:", p.MyEncryptionKp.Private) + fmt.Println("[AsymDecryptMessage] Should have been encrypted with:", p.MyEncryptionKp.Public) + fmt.Println("[AsymDecryptMessage] Signature will be verified with:", p.ContactPublicKey) DecryptedMessage, err = meowlib.AsymDecryptAndCheck(p.MyEncryptionKp.Private, p.ContactPublicKey, Message, Signature) if err != nil { fmt.Println(err.Error()) diff --git a/endtoend_test.go b/endtoend_test.go index 629fde4..98d7300 100644 --- a/endtoend_test.go +++ b/endtoend_test.go @@ -41,15 +41,15 @@ func TestEndToEnd(t *testing.T) { } println(peer.Name) // print my invitation - a, _ := json.Marshal(peer.MyContact) + a, _ := json.Marshal(peer.GetMyContact()) fmt.Println(string(a)) // TODO : Convert invitation to QR Code - peer.MyContact.WritePng("invitation.png") - data, err := peer.MyContact.Compress() + peer.GetMyContact().WritePng("invitation.png") + data, err := peer.GetMyContact().Compress() if err != nil { println(err) } - peer.MyContact.WriteQr("qrcode.png") + peer.GetMyContact().WriteQr("qrcode.png") println("Compressed contact card :", len(data)) /////////////////////////////////////// // Simulate peer invitation response // @@ -65,7 +65,7 @@ func TestEndToEnd(t *testing.T) { ReceivedContact.ContactPublicKey = FirstFriendContactKp.Public ReceivedContact.EncryptionPublicKey = FirstFriendEncryptionKp.Public ReceivedContact.LookupPublicKey = FirstFriendLookupKp.Public - ReceivedContact.InvitationId = peer.MyContact.InvitationId + ReceivedContact.InvitationId = peer.GetMyContact().InvitationId FriendServer1KP := meowlib.NewKeyPair() FriendServer1 := meowlib.ServerCard{Name: "FriendServer1", Url: "http://myfriend.org/meow/", PublicKey: FriendServer1KP.Public, Description: "Fancy description"} ReceivedContact.PullServers = append(ReceivedContact.PullServers, &FriendServer1)