Skip to content

Conversation

@Nabil-Salah
Copy link
Contributor

Description

Describe the changes introduced by this PR and what does it affect

Changes

List of changes this PR includes

Related Issues

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring

Signed-off-by: nabil salah <nabil.salah203@gmail.com>
Signed-off-by: nabil salah <nabil.salah203@gmail.com>

// Helper functions

func bytesEqual(a, b []byte) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func TestEncryptionDecryptionRoundtrip(t *testing.T) {
f := func(kp keyPair, msg randomMessage) bool {
message := []byte(msg)
encrypted, err := Encrypt(message, kp.PublicKey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract that logic into a function e.g encryptThenDecrypt and the only thing would be left is comparing the decrypted with the message

func (keyPair) Generate(rand *rand.Rand, size int) reflect.Value {
pub, priv, err := ed25519.GenerateKey(crypto_rand.Reader)
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

}

// NaCl sealed box adds 48 bytes overhead (32 bytes ephemeral key + 16 bytes MAC)
expectedSize := len(message) + 48
Copy link
Contributor

@xmonader xmonader Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract the 48 into a constant, and use it here


// Generate implements quick.Generator for keyPair
func (keyPair) Generate(rand *rand.Rand, size int) reflect.Value {
pub, priv, err := ed25519.GenerateKey(crypto_rand.Reader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have a rand already?

…nctions

Signed-off-by: nabil salah <nabil.salah203@gmail.com>
@Nabil-Salah Nabil-Salah requested a review from xmonader July 29, 2025 14:58
@Nabil-Salah Nabil-Salah merged commit 534345d into main Jul 29, 2025
1 check passed
@Nabil-Salah Nabil-Salah deleted the development_crypto_propertytests branch July 29, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants