Skip to content

Conversation

@CDRussell
Copy link
Member

@CDRussell CDRussell commented Dec 17, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/72649045549333/task/1212290226255081?focus=true

Description

Adds sync crypto support for byte arrays, adding the ability to encrypt and decrypt them similar to the existing functions which support strings only.

There's a few extra changes required because of needing to extend the test suite, as well as a few FakeCrypto implementations for testing, each needing tweaked.

But the core change is:

  • add the new APIs which accept a byte array
  • change the existing APIs to first convert String -> Byte Array as they are doing now already, then invoke the other function so that the logic is shared between the two impls.

Steps to test this PR

  • QA optional
  • Can smoke test sync still works ok; e.g., set up two devices and update a password on one of them, make sure it syncs

Note

Adds ByteArray encrypt/decrypt APIs to sync crypto, implements them in native and real crypto, and updates tests and fakes accordingly.

  • API
    • Extend SyncCrypto with encrypt(data: ByteArray) and decrypt(data: ByteArray); clarify string encrypt returns Base64.
  • Implementation
    • RealSyncCrypto: implement new ByteArray methods with error recording; keep string methods; early-return on empty inputs.
  • Native library
    • SyncLib/SyncNativeLib: add ByteArray overloads for encryptData/decryptData and wire through SyncNativeLibImpl.
    • Introduce EncryptBytesResult and DecryptBytesResult; adapt string methods to reuse ByteArray flow.
  • Tests
    • SyncCryptoTest: add ByteArray encrypt/decrypt tests and adjust string tests.
    • Update FakeCrypto in tests (app, autofill, saved-sites, sync-settings) to implement new ByteArray methods.

Written by Cursor Bugbot for commit 610d556. This will update automatically on new commits. Configure here.

Copy link
Member Author

CDRussell commented Dec 17, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@CDRussell CDRussell marked this pull request as ready for review December 17, 2025 14:57
@CDRussell CDRussell requested a review from malmstein as a code owner December 17, 2025 14:57
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch from 08feebf to d36ea31 Compare December 17, 2025 15:14
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch from 6833195 to 38e016a Compare December 17, 2025 15:14
Copy link
Contributor

@malmstein malmstein left a comment

Choose a reason for hiding this comment

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

SHIP IT

@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch from d36ea31 to 32ff896 Compare December 17, 2025 17:02
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch from 38e016a to 259e824 Compare December 17, 2025 17:07
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch 2 times, most recently from 0c92c2f to 76cd1e5 Compare December 17, 2025 17:07
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch 2 times, most recently from 7f14801 to c7269ca Compare December 17, 2025 17:09
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch from 76cd1e5 to e268906 Compare December 17, 2025 17:09
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch from c7269ca to 3b1274f Compare December 17, 2025 17:27
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch from e268906 to 3d1db92 Compare December 17, 2025 17:27
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch from 3b1274f to b537d28 Compare December 17, 2025 17:45
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch 2 times, most recently from b8f6d64 to c46ac61 Compare December 17, 2025 17:51
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch 2 times, most recently from 9f55739 to 7076d7e Compare December 17, 2025 17:55
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch from c46ac61 to b706df5 Compare December 17, 2025 17:55
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch from 7076d7e to e779640 Compare December 17, 2025 17:56
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch 2 times, most recently from b2e25e9 to 8fad7c6 Compare December 17, 2025 17:58
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch 3 times, most recently from c3d194b to 4becbdb Compare December 18, 2025 11:07
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch from 8fad7c6 to 68609b8 Compare December 18, 2025 11:07
syncCrypto.encrypt("something".toByteArray())

verify(recorder).record(DATA_ENCRYPT)
}
Copy link

Choose a reason for hiding this comment

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

Bug: Test verification never executes due to preceding exception

The verify(recorder).record(...) statements in whenEncryptByteArrayFailsThenExceptionThrown and whenDecryptByteArrayFailsThenExceptionThrown are placed after the line that throws an exception. Since syncCrypto.encrypt()/decrypt() throws before reaching the verification, these assertions never run. The tests will pass even if the recorder is never called in production, potentially masking missing error recording behavior.


Please tell me if this was useful or not with a 👍 or 👎.

Additional Locations (1)

Fix in Cursor Fix in Web

@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch 2 times, most recently from fa156a9 to 6b6dc6d Compare December 18, 2025 18:09
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch from 4becbdb to 29fc78f Compare December 18, 2025 18:09
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch from 6b6dc6d to ee92e81 Compare December 18, 2025 19:31
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch 2 times, most recently from 30b7555 to f3e5f30 Compare December 18, 2025 19:47
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch 2 times, most recently from 4957e06 to 4f4a176 Compare December 18, 2025 20:09
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch 2 times, most recently from e0b3b07 to c651d8e Compare December 19, 2025 10:51
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch 2 times, most recently from 5eacdaa to 05596f0 Compare December 19, 2025 13:39
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch from c651d8e to 7636a72 Compare December 19, 2025 13:39
@CDRussell CDRussell force-pushed the feature/craig/update_sync_crypto_apis_byte_array branch from 05596f0 to 610d556 Compare December 19, 2025 13:41
@CDRussell CDRussell force-pushed the feature/craig/sync_deletion_of_duck_ai_chats branch from 7636a72 to 3dfdcb3 Compare December 19, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants