signal-cli icon indicating copy to clipboard operation
signal-cli copied to clipboard

MobileCoin addresses are Base58, not Base64.

Open christian-oudard opened this issue 1 year ago • 3 comments

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

christian-oudard avatar Nov 26 '24 14:11 christian-oudard

~~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}?

m-ueberall avatar Nov 26 '24 16:11 m-ueberall

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.

AsamK avatar Nov 29 '24 20:11 AsamK

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

christian-oudard avatar Dec 03 '24 20:12 christian-oudard