Property testing crypto package#49
Merged
Merged
Conversation
Signed-off-by: nabil salah <nabil.salah203@gmail.com>
Signed-off-by: nabil salah <nabil.salah203@gmail.com>
xmonader
reviewed
Jul 29, 2025
|
|
||
| // Helper functions | ||
|
|
||
| func bytesEqual(a, b []byte) bool { |
Contributor
There was a problem hiding this comment.
xmonader
reviewed
Jul 29, 2025
| func TestEncryptionDecryptionRoundtrip(t *testing.T) { | ||
| f := func(kp keyPair, msg randomMessage) bool { | ||
| message := []byte(msg) | ||
| encrypted, err := Encrypt(message, kp.PublicKey) |
Contributor
There was a problem hiding this comment.
extract that logic into a function e.g encryptThenDecrypt and the only thing would be left is comparing the decrypted with the message
xmonader
reviewed
Jul 29, 2025
| func (keyPair) Generate(rand *rand.Rand, size int) reflect.Value { | ||
| pub, priv, err := ed25519.GenerateKey(crypto_rand.Reader) | ||
| if err != nil { | ||
| panic(err) |
xmonader
reviewed
Jul 29, 2025
| } | ||
|
|
||
| // NaCl sealed box adds 48 bytes overhead (32 bytes ephemeral key + 16 bytes MAC) | ||
| expectedSize := len(message) + 48 |
Contributor
There was a problem hiding this comment.
extract the 48 into a constant, and use it here
xmonader
reviewed
Jul 29, 2025
|
|
||
| // Generate implements quick.Generator for keyPair | ||
| func (keyPair) Generate(rand *rand.Rand, size int) reflect.Value { | ||
| pub, priv, err := ed25519.GenerateKey(crypto_rand.Reader) |
Contributor
There was a problem hiding this comment.
don't we have a rand already?
…nctions Signed-off-by: nabil salah <nabil.salah203@gmail.com>
xmonader
approved these changes
Jul 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Describe the changes introduced by this PR and what does it affect
Changes
List of changes this PR includes
Related Issues
Checklist