Update messengerEthereum.js

Suspending forcefully making Y point as even for messenger, as this is not Taproot.
This commit is contained in:
tripathyr 2023-10-15 08:53:11 +05:30 committed by GitHub
parent 3ef1bc5b41
commit 2a5faefdaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,15 +4,16 @@
'use strict';
const floEthereum = EXPORTS;
//This needs y point to be even always. If y point is odd, it wil be converted to even
const ethAddressFromPrivateKey = floEthereum.ethAddressFromPrivateKey = function(privateKey){
var t1,t1_x,t1_y,t1_x_BigInt,t1_y_BigInt,t2,t3,t4;
var groupOrder = BigInt("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
t1 = bitjs.newPubkey(privateKey);
t1_x = t1.slice(2, 66); t1_y = t1.slice(-64);
t1_x_BigInt = BigInt("0x"+t1_x);t1_y_BigInt = BigInt("0x"+t1_y);
if (t1_y_BigInt % 2n !== 0n) { t1_y_BigInt = (groupOrder-t1_y_BigInt)%groupOrder; t1_y=t1_y_BigInt.toString(16)};
//Suspending Odd Even checks for Messenger App
// t1_x_BigInt = BigInt("0x"+t1_x);t1_y_BigInt = BigInt("0x"+t1_y);
// if (t1_y_BigInt % 2n !== 0n) { t1_y_BigInt = (groupOrder-t1_y_BigInt)%groupOrder; t1_y=t1_y_BigInt.toString(16)};
t2 = t1_x.toString(16) + t1_y.toString(16);
t3 = keccak.keccak_256(Crypto.util.hexToBytes(t2));
t4 = keccak.extractLast20Bytes(t3);