Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update APIs to use MobileCoinRng instead of RngSeed #197

Merged
merged 3 commits into from
Sep 27, 2022

Conversation

carybakker
Copy link
Contributor

@carybakker carybakker commented Sep 23, 2022

Soundtrack of this PR: A 'random' InSync song lol

Motivation

Sync up iOS and Android's implementation of idempotence for cross-platform compatibility

In this PR

  • Deprecate the API calls for prepareTransaction that use RngSeed
  • De-Deprecate the API calls that use MobileCoinRng
  • Deprecated APIs will generate a new RNG from the seed, and then call the de-deprecated APIs with that RNG (all that part is done by the API client code on Android). Then for equivalency, when we receive an Rng via the de-deprecated APIs (that match Android in that they accept an Rng), we will generate a seed used to create a new ChaCha20Rng for the building of the output transaction (which will match Android once Android is updated to generate the seed before any other use).

@voloshyn
Copy link
Contributor

would be great to have a test for this, @dolanbernard can you provide a test data from Android to cross-test?

completion: @escaping (
Result<PendingSinglePayloadTransaction, TransactionPreparationError>
) -> Void
) {
guard let rngSeed = rng.generateRngSeed() else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure this is correct, if you only use the RNG to create a seed which you then pass around to see our internal RNG, that defeats the purpose of letting them pass in their own RNG class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Android uses the input Rng to seed the RNG for output idempotence. So here, we are doing the same as Android with respect to the output transaction creation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

well then, doesnt seem to be as flexible as I initially thought, but if its the same as android thats correct

completion: @escaping (
Result<PendingSinglePayloadTransaction, TransactionPreparationError>
) -> Void
) {
guard let rngSeed = rng.generateRngSeed() else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same feedback here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same answer as above :)

@carybakker
Copy link
Contributor Author

would be great to have a test for this, @dolanbernard can you provide a test data from Android to cross-test?

Test has been added with matching data (passing successfully)

@carybakker carybakker merged commit d068257 into master Sep 27, 2022
@carybakker carybakker deleted the task/android-ios-idempotence-compatibility branch September 27, 2022 00:03
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.

None yet

4 participants