Skip to content

Commit

Permalink
checkStealthAddress wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bokkypoobah committed Dec 28, 2023
1 parent 933c8a9 commit f318138
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1834,9 +1834,21 @@ <h5>Stealth Meta-Address</h5>
},
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));
Expand All @@ -1850,14 +1862,14 @@ <h5>Stealth Meta-Address</h5>
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);
}
}
}
}
Expand Down

0 comments on commit f318138

Please sign in to comment.