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

Small updates #14

Merged
merged 3 commits into from
May 31, 2024
Merged

Small updates #14

merged 3 commits into from
May 31, 2024

Conversation

josibake
Copy link
Contributor

  • Use getSharedSecret instead of Point.multiply
  • Return targets in the original order requested by the caller

josibake and others added 3 commits May 31, 2024 12:15
Use getSharedSecret instead of multiply directly. Did some digging and getSharedSecret
is using multiply under the hood, but looks like there is an outstanding todo to make
it constant time, so if/when that happens we wont need to update anything here.
previously, the silent payment outputs were being added at the end
of the target array, which changes the order from what the caller requested.

instead, keep track of the original index while creating silent payment
outputs and return the targets in the original order.
@josibake
Copy link
Contributor Author

H/t @Overtorment for the test case (cherry-picked from #13 )

@@ -84,10 +85,10 @@ export class SilentPayment {
for (const group of silentPaymentGroups) {
// Bscan * a * outpoint_hash
const ecdh_shared_secret_step1 = Buffer.from(ecc.privateMultiply(outpoint_hash, a) as Uint8Array);
const ecdh_shared_secret = ecc.pointMultiply(group.Bscan, ecdh_shared_secret_step1);
const ecdh_shared_secret = Buffer.from(ecc.getSharedSecret(ecdh_shared_secret_step1, group.Bscan) as Uint8Array);
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious, how is this better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently, it doesn't change anything since getSharedSecret is calling Point.multiply under the hood (which was surprising to me). But ideally, getSharedSecret should be doing a constant time multiplication. If getSharedSecret is updated in the future to do constant time multiplication, we won't have to change anything here. I seem to remember seeing a todo in the noble crypto repos about changing this to constant time, but will need to go back and find it.

@Overtorment Overtorment merged commit fe858ef into BlueWallet:master May 31, 2024
1 check passed
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.

2 participants