Skip to content

Add post-encryption validation to TransformedRecordSerializer#4010

Merged
alecgrieser merged 3 commits intoFoundationDB:mainfrom
g31pranjal:encrypt_decrypt_verify
Mar 26, 2026
Merged

Add post-encryption validation to TransformedRecordSerializer#4010
alecgrieser merged 3 commits intoFoundationDB:mainfrom
g31pranjal:encrypt_decrypt_verify

Conversation

@g31pranjal
Copy link
Copy Markdown
Member

@g31pranjal g31pranjal commented Mar 18, 2026

Summary

  • Adds writeEncryptionValidationRatio field to TransformedRecordSerializer
  • Adds shouldValidateEncryption() and validateEncrypt(beforeEncrypt, afterEncrypt, timer) in serialize: after encryption, a sampled fraction of writes decrypt the result and assert the bytes match the pre-encryption plaintext.
  • Ratio semantics mirror writeValidationRatio: 0.0 disables, 1.0 validates all, anything in between samples randomly.
  • Adds test for relevant additions.

@g31pranjal g31pranjal added the enhancement New feature or request label Mar 18, 2026
@g31pranjal g31pranjal requested a review from alecgrieser March 18, 2026 00:48
Copy link
Copy Markdown
Collaborator

@alecgrieser alecgrieser left a comment

Choose a reason for hiding this comment

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

Overall, this looks good to me. Just a few minor things


/**
* Allows the user to specify a portion of encryptions that will be validated. Every validated encryption will
* decrypt the result and verify it matches the original plaintext. If the ratio is less than or equal to 0.0,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would probably be good to note the semantics of what happens if the decrypted result does not match the original plaintext here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done!

* @return this <code>Builder</code>
*/
@Nonnull
public Builder<M> setWriteEncryptionValidationRatio(double writeEncryptionValidationRatio) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we want a separate ratio for validating reads? Even if we do, I think it would be fine to do that in a separate PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It might be worth to have something similar for validating reads as well. However, note that the ratio for validating reads should be configured independently from that for validating writes - given the difference in the read/write workloads in the adopter. In either case, leaving it for a separate PR.

@g31pranjal g31pranjal requested a review from alecgrieser March 26, 2026 11:53
@alecgrieser alecgrieser merged commit 736034a into FoundationDB:main Mar 26, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants