MultiversX Tracker is Live!

pokkst/litecoinj message verification problem - Address.fromKey() returning wrong address

Bitcoin Stack Exchange

Bitcoin News / Bitcoin Stack Exchange 218 Views

I have a problem with java library pokkst/litecoinj. I am using the regular bitcoinj library to verify signed messages with success. As pokkst/litecoinj is a fork of bitcoinj I have expected it to work in same or close manner.

I have a method:

private boolean isSignatureValid(NetworkParameters params, String address, String message, String signature) { try { Address signingAddress = Address.fromString(params, address); ECKey key = ECKey.signedMessageToKey(message, signature); Address addressFromKey = Address.fromKey(params, key, signingAddress.getOutputScriptType()); return signingAddress.equals(addressFromKey); } catch (SignatureException | AddressFormatException exception) { LOGGER.error(exception.getMessage()); return false; } catch (NullPointerException exception) { LOGGER.error("Address cannot be null!"); return false; }
}

Given data (this is just a test wallet so I do not worry about it):

params -> MainNetParams.get();
address -> ltc1qhlnfnzc6djz92ylf89cvsw7jzyl98hx79ye5a5
message -> test-test-test-test-test
signature -> IC6AcfBff2TA1brwVneXPFtUyHCu1hffTvcaTyNM+i5IbNc7UgNIA4bdVu3mpr0awTsaIK7lpY4O5pS4+/SJDUw=

Important: this address and signature are generated using Electrum-LTC wallet, cause I haven't found any other litecoin wallet that will allow me to sign messages.

When I run a test against this method, i see that addressFromKey is different than signingAddress and it's value is ltc1qewvcwvf9ln6uypme8wskmg5khqwpss7v9zcrj7

My code for Bitcoin message verification is very similar, and it is working fine.

I don't have access to the wallet keys, a wallet address, message and signature is all I have.

What am I doing wrong? May this be a bug in the library? Or could it be something wrong with Electrum-LTC?


Get BONUS $200 for FREE!

You can get bonuses upto $100 FREE BONUS when you:
πŸ’° Install these recommended apps:
πŸ’² SocialGood - 100% Crypto Back on Everyday Shopping
πŸ’² xPortal - The DeFi For The Next Billion
πŸ’² CryptoTab Browser - Lightweight, fast, and ready to mine!
πŸ’° Register on these recommended exchanges:
🟑 Binance🟑 Bitfinex🟑 Bitmart🟑 Bittrex🟑 Bitget
🟑 CoinEx🟑 Crypto.com🟑 Gate.io🟑 Huobi🟑 Kucoin.



Comments