I wonder if there is a Java implementation of Monero addresses validation code somewhere?

I've found this JS implementation which seems to work well:


and, an online version:


But I've been unable to make a Java port of this code. As soon as I try ot decode the address to a byte[], using tools such as this one, I get a different array than the one from the JS lib.

For example, this Monero test address: "46oTQPpoxoxQ6XGWwPqEK1YvADH8X91rFC6brLWRHokoAC5qwbYKA2e9jzQyapENw4V2w5Tz1d4LiMSuDhhFCCf77mQgLRA"

The JS lib decodes it to (as an Hex string):


When I try to do the samething in Java using:

byte[] decoded = Base58.decode(address);
String decodedStr = org.apache.commons.codec.binary.Hex.encodeHexString(decoded);

I get:


Any idea?

2 Answers 2


Please refer to the following as to why your Base58 decoding mismatches:

Base58 does not strictly specify the format. This results in some implementations being incompatible with others, for example with regard to alphabet order.


Monero has its own variant of Base58.

In Monero the Base58 encoding is performed in 8-byte blocks, except the last block which is the remaining (8 or less) bytes .


I'm not aware of an existing Java implementation that encodes/decodes in the specific way Monero does (as described above), so you will likely need to roll your own, which should be an easy task.

Please also note, the Base58 decoding does not validate an address, it simply decodes the human readable string representation to binary. Depending on your needs, you could perform a very minimal verification of just the length and valid Base58 characters, a slightly fuller verification where you also check the network byte (which doesn't require a full Base58 decode), or you can go all the way doing a full decode, checking the network byte, verifying the checksum and checking the public view and spend keys are valid curve points.

I'd also like to draw your attention to an ecosystem project: monero-java. It currently has very little in the way of address validation (lots of "TODO" comments in the relevant file MoneroUtils.java), so if you do end up writing the relevant code, please consider contributing back to that project.

  • 1
    I made it work! :-) I'm not so proud since I more or less simply copied existing JS/Python code without really understanding it, but at least it works! I also learned that Keccak-256 is another part that is a bit special and requires an extra library in Java. I'll try to make a PR when I have time. Thanks for your help! Sep 23, 2019 at 2:38
  • 1

Monero address validation using native Java has been merged into MoneroUtils.java of the monero-java project based on @electrotype's pull request.

Thanks @electrotype for your pull request and @jtgrassie for pointing to the Java library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.