Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MobileCoin addresses are Base58, not Base64. #1637

Open
christian-oudard opened this issue Nov 26, 2024 · 3 comments
Open

MobileCoin addresses are Base58, not Base64. #1637

christian-oudard opened this issue Nov 26, 2024 · 3 comments

Comments

@christian-oudard
Copy link

christian-oudard commented Nov 26, 2024

I'm working with Fire Digital (https://fire.cx/, https://github.com/xederifofficial), and we're building a cryptocurrency exchange. My current project is a Signal bot to process deposits and withdrawals for MobileCoin. signal-cli crashes when I put in my MobileCoin wallet, due to a confusion between Base58 and Base64.

Currently, this is being handled by re-encoding Base58 addresses as Base64, but it would be convenient to have this done automatically by signal-cli.

$ signal-cli --mobile-coin-address=4RN98ba92FqD3u3bS63XyNMHBmCm8TVDRprF1FaHfUD9kUGtfPmE3SXAKBkEr1uB7gbFBURXRrFUjvGZyMCkHPPCcGEx9pvQodsfHBQaV7YFtfUCspSvynDfo4EGYLb2hgK7xeJGKvy49BZmfCadqLd4pULaEmtxY64XEHwW2bauEYrXhWZ4SMAELRc78ptpqBiN2VAsPd99FPXsCyV2Y6RaLd3KRRmbawaSTrxWwA9Pt9dSS

java.lang.IllegalArgumentException: Last unit does not have enough valid bits
        at java.base/java.util.Base64$Decoder.decode0(Base64.java:872)
        at java.base/java.util.Base64$Decoder.decode(Base64.java:570)
        at java.base/java.util.Base64$Decoder.decode(Base64.java:593)
        at org.asamk.signal.commands.UpdateProfileCommand.handleCommand(UpdateProfileCommand.java:48)
        at org.asamk.signal.commands.CommandHandler.handleLocalCommand(CommandHandler.java:35)
        at org.asamk.signal.App.handleLocalCommand(App.java:278)
        at org.asamk.signal.App.handleCommand(App.java:179)
        at org.asamk.signal.App.init(App.java:144)
        at org.asamk.signal.Main.main(Main.java:56)

$ signal-cli --version
signal-cli 0.13.9
@m-ueberall
Copy link

m-ueberall commented Nov 26, 2024

AFAIK, --mobile-coin-address is not a valid argument, so maybe this should be reported against a downstream project/fork? (EDIT: Strike that, it's mentioned in signal-cli.1.adoc)

Apart from that, why not simply convert the argument "4RN98ba92…" using B64=$(echo '4RN98ba92…' | base58 -d | base64 -w0); signal-cli --mobile-coin-address=${B64}?

@AsamK
Copy link
Owner

AsamK commented Nov 29, 2024

signal-cli is using base64 for all binary data. I'm not a fan of adding an additional encoding scheme, as base58 conversion should be straight forward for signal-cli users.

@christian-oudard
Copy link
Author

It's pretty not-straightforward, because the base58 encoding and the base64 encoding are based on the protobuf printable.proto binary representation, and there are some issues with protobuf field length bytes being included or not included. Basically all the mobilecoin tools speak base58, but because the Signal integration happened before we standardized on that, they require this incompatible encoding. Mostly I'm saying this as a reference in case anyone comes across the same issue.

Here's an example implementation:
https://github.com/mobilecoinofficial/full-service/blob/main/python/mobilecoin/util/__init__.py
And here's some of the signal code doing the base58 conversion correctly:
https://github.com/signalapp/Signal-Android/blob/main/app/src/main/java/org/thoughtcrime/securesms/payments/MobileCoinPublicAddress.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants