From 96e17c9b17477ca1407eeefca8d5cd91f82f8988 Mon Sep 17 00:00:00 2001 From: 0xdcarns Date: Mon, 14 Feb 2022 20:07:22 -0500 Subject: [PATCH] comment cleanup --- netclient/ncutils/encryption.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/netclient/ncutils/encryption.go b/netclient/ncutils/encryption.go index 207a2c7f..2976c913 100644 --- a/netclient/ncutils/encryption.go +++ b/netclient/ncutils/encryption.go @@ -10,7 +10,7 @@ import ( ) const ( - chunkSize = 16000 // 16128 bytes max message size + chunkSize = 16000 // 16000 bytes max message size ) // BoxEncrypt - encrypts traffic box @@ -30,7 +30,7 @@ func BoxDecrypt(encrypted []byte, senderPublicKey *[32]byte, recipientPrivateKey copy(decryptNonce[:], encrypted[:24]) decrypted, ok := box.Open(nil, encrypted[24:], &decryptNonce, senderPublicKey, recipientPrivateKey) if !ok { - return nil, fmt.Errorf("could not decrypt message") + return nil, fmt.Errorf("could not decrypt message, %v", encrypted) } return decrypted, nil } @@ -41,8 +41,6 @@ func Chunk(message []byte, recipientPubKey *[32]byte, senderPrivateKey *[32]byte for i := 0; i < len(message); i += chunkSize { end := i + chunkSize - // necessary check to avoid slicing beyond - // slice capacity if end > len(message) { end = len(message) } @@ -95,10 +93,7 @@ func convertMsgToBytes(msg []byte) ([][]byte, error) { // ConvertBytesToMsg - converts the chunked message into a MQ message // encode action func convertBytesToMsg(b [][]byte) ([]byte, error) { - // var totalSize = len(b) * len(splitKey) - // for _, buf := range b { - // totalSize += len(buf) - // } + var buffer []byte // allocate a buffer with adequate sizing for i := range b { // append bytes to it with key buffer = append(buffer, b[i]...)