From f318138e9567e25ab1a660c2a9789ab26b12f2cf Mon Sep 17 00:00:00 2001 From: BokkyPooBah Date: Thu, 28 Dec 2023 18:07:44 +1100 Subject: [PATCH] checkStealthAddress wip --- docs/index.html | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/docs/index.html b/docs/index.html index 5080a4d..1cbba6b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1834,9 +1834,21 @@
Stealth Meta-Address
}, async processData(provider) { function checkStealthAddress(stealthAddress, ephemeralPublicKey, viewingPrivateKey, spendingPublicKey) { + const result = {}; // console.log(moment().format("HH:mm:ss") + " processData - checkStealthAddress - stealthAddress: " + stealthAddress + ", ephemeralPublicKey: " + ephemeralPublicKey + ", viewingPrivateKey: " + viewingPrivateKey + ", spendingPublicKey: " + spendingPublicKey); console.log(" Check stealthAddress: " + stealthAddress + ", ephemeralPublicKey: " + ephemeralPublicKey + ", viewingPrivateKey: " + viewingPrivateKey + ", spendingPublicKey: " + spendingPublicKey); - + result.sharedSecret = nobleCurves.secp256k1.getSharedSecret(viewingPrivateKey.substring(2), ephemeralPublicKey.substring(2), false); + // console.log(" sharedSecret: " + result.sharedSecret); + result.hashedSharedSecret = ethers.utils.keccak256(result.sharedSecret.slice(1)); + // console.log(" hashedSharedSecret: " + result.hashedSharedSecret); + result.hashedSharedSecretPoint = nobleCurves.secp256k1.ProjectivePoint.fromPrivateKey(result.hashedSharedSecret.substring(2)); + // console.log(" hashedSharedSecretPoint: ", result.hashedSharedSecretPoint); + result.stealthPublicKey = nobleCurves.secp256k1.ProjectivePoint.fromHex(spendingPublicKey.substring(2)).add(result.hashedSharedSecretPoint); + // console.log(" stealthPublicKey: ", result.stealthPublicKey); + result.stealthAddress = ethers.utils.computeAddress("0x" + result.stealthPublicKey.toHex(false)); + // console.log(" match: " + (result.stealthAddress == stealthAddress)); + result.match = result.stealthAddress == stealthAddress; + return result; } console.log(moment().format("HH:mm:ss") + " processData BEGIN"); // console.log(moment().format("HH:mm:ss") + " processData - events: " + JSON.stringify(this.events)); @@ -1850,14 +1862,14 @@
Stealth Meta-Address
for (const [address, accountData] of Object.entries(addresses)) { for (const [stealthMetaAddress, stealthMetaAddressData] of Object.entries(accountData.stealthMetaAddresses)) { console.log(" Checking " + address.substring(0, 20) + " " + stealthMetaAddress.substring(0, 30)); - // console.log(JSON.stringify(stealthMetaAddressData)); const stealthAddress = eventData.stealthAddress; const ephemeralPublicKey = eventData.ephemeralPublicKey; const viewingPrivateKey = stealthMetaAddressData.viewingPrivateKey; const spendingPublicKey = stealthMetaAddressData.spendingPublicKey; const status = checkStealthAddress(stealthAddress, ephemeralPublicKey, viewingPrivateKey, spendingPublicKey); - - + for (const [k, v] of Object.entries(status)) { + console.log(" ", k, "=>", v); + } } } }