From 5cdb0fc4bbabe75e1ad4334a249bd41844231a8c Mon Sep 17 00:00:00 2001 From: josibake Date: Mon, 29 Apr 2024 16:55:30 +0200 Subject: [PATCH] nit: fixup variable names to match BIP352 --- src/index.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7ebac18..c60b1f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -80,30 +80,29 @@ export class SilentPayment { const A = Buffer.from(ecc.pointFromScalar(a) as Uint8Array); const outpoint_hash = SilentPayment._outpointsHash(utxos, A); - // Generating Pmn for each Bm in the group + // Generating Pmk for each Bm in the group 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); - let n = 0; + let k = 0; for (const [Bm, amount] of group.BmValues) { - const tn = taggedHash( + const tk = taggedHash( "BIP0352/SharedSecret", - Buffer.concat([ecdh_shared_secret!, SilentPayment._ser32(n)]) + Buffer.concat([ecdh_shared_secret!, SilentPayment._ser32(k)]) ); - // Let Pmn = tn·G + Bm - const Pmn = Buffer.from(ecc.pointAdd(ecc.pointMultiply(G, tn) as Uint8Array, Bm) as Uint8Array); + // Let Pmk = tk·G + Bm + const Pmk = Buffer.from(ecc.pointAdd(ecc.pointMultiply(G, tk) as Uint8Array, Bm) as Uint8Array); - // Encode Pmn as a BIP341 taproot output - const address = Pmn.slice(1).toString("hex"); + // Encode Pmk as a BIP341 taproot output + const address = Pmk.slice(1).toString("hex"); const newTarget: Target = { address }; newTarget.value = amount; ret.push(newTarget); - n += 1; + k += 1; } - n += 1; } return ret; }