Skip to content

Commit

Permalink
use getSharedSecret
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
josibake authored and Overtorment committed May 31, 2024
1 parent d3a45d7 commit ac3faa0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ 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);

let k = 0;
for (const [Bm, amount] of group.BmValues) {
Expand Down
4 changes: 4 additions & 0 deletions src/noble_ecc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const ecc = {
return { parity, xOnlyPubkey: P.slice(1) };
}),

getSharedSecret: (sk: Uint8Array, pk: Uint8Array, compressed?: boolean): Uint8Array => {
return necc.getSharedSecret(sk, pk, defaultTrue(compressed));
},

pointFromScalar: (sk: Uint8Array, compressed?: boolean): Uint8Array | null => throwToNull(() => necc.getPublicKey(sk, defaultTrue(compressed))),

pointCompress: (p: Uint8Array, compressed?: boolean): Uint8Array => {
Expand Down

0 comments on commit ac3faa0

Please sign in to comment.