Jump to content

Recommended Posts

I am trying to use Ripple multi-sig. I have followed docs https://xrpl.org/set-up-multi-signing.html, https://xrpl.org/send-a-multi-signed-transaction.html. 

I have used ripple testnet for all these tests.

I am able to perform tasks like:

  1. Create accounts and add them as signers to one account
  2. Disable master key of the account in which I added.

Finally when I try to withdraw funds from this account using signatures from these signers, I get error

"error": "internal",
    "error_code": 71,
    "error_message": "Invalid signature.",

The json which I tried to submit is provided. I have also tried to submit as blob using submit command which creates error

 "error": "invalidTransaction",
    "error_exception": "fails local checks: Transaction has bad signature.",

 {
    "method": "submit_multisigned",
    "params": [
        {
           "tx_json": { "TransactionType" : "Payment", "Account" : "rNvoW4LG6wXVZm6RXbo7qyNRmQj4TNUmTz", "Destination" : "rsuUjfWxrACCAwGQDsNeZUhpzXf1n1NK5Z","DestinationTag": 384725397, "Amount": "1000000", "Fee": "1200", "Flags": 2147483648, "Sequence": 5,"SigningPubKey": "","Signers" : [
                 {
                    "Signer" : {
                       "Account" : "rGtMsMktyGKC8QeTb6phSSYLG7JWaB1Dir",
                       "SigningPubKey" : "020d4888ba4f8cbb96fa5a2eead2e6bbc90ba94cadae29a4aebe2a7cc62c96b278",
                       "TxnSignature" : "3045022100AC5BBDAAB33F50CEA6DB89DFC65CCDF306B346B3A5975AF8344260548870F3B9022079EEF9C2BFDD0930C6FC72D88DD48D80D97531F9A8349C5B6372E979D76FF603"
                    }
                 },
                 {
                    "Signer" : {
                       "Account" : "rhNfCZXnqoX35ndyhYgHxhjPy2xs5rg9Lq",
                       "SigningPubKey" : "02b0f22c98a07257f0251d678a23be8e00b238180dde29a71fc3fabfe17740a5cc",
                       "TxnSignature" : "3045022100F1651743DE011E213623C8DB46D35ED89088D0563CE7C399A45AD4BDB349B63002207255ADA9385538C3589D79DF814F9D93836908A09C02E73CDE5303E865963211"
                    }
                 }
              ]}
        }
    ]
}

Share this post


Link to post
Share on other sites
Posted (edited)

@mDuo13 I use libsecp256k1 library for signing (https://github.com/bitcoin-core/secp256k1).
The ripple ledger accepts different types of transactions signed using this. This issue comes only in case of multisigned transaction.

Edited by josepajay

Share this post


Link to post
Share on other sites

Maybe you have an error in your transaction serialization code, so you're signing correctly, but the wrong thing? How do you get the bytes that you are signing?

Share this post


Link to post
Share on other sites

@Sukrim  I use ripple python module (https://github.com/ripple/ripple-dev-portal/blob/master/content/_code-samples/tx-serialization/serialize.py ) to serialize the json to bytes. Hash these bytes using ripple standards (https://xrpl.org/basic-data-types.html#hashes) to get unsigned transaction hash, which I sign using different private keys.

Share this post


Link to post
Share on other sites

Interesting. I wrote that module myself, but I haven't tested it extensively with multi-signatures. It's possible that I made an oversight and it doesn't serialize transactions correctly for multi-signatures.

 

EDIT: Oh, also, are you sure you're using the correct prefix for an unsigned multi-signing transaction? (SMT\0 instead of STX\0)

Share this post


Link to post
Share on other sites

@mDuo13

I am using the correct prefix, but I figured out the issue.
I inspected the JS implementation of ripple and found that in line https://github.com/ripple/ripple-binary-codec/blob/master/src/binary.js#L49,

account-id is added as suffix to the unsigned transaction (in case of multi-signing) which I was not doing. I did not find anything regarding this suffix in ripple documentation.
After computing the account-id from the public key and adding it to the blob before hashing fixed my issue of invalid signature.

Thanks for helping out.

Share this post


Link to post
Share on other sites

That's a great catch, and something I had no idea about.

I've had the project of describing the signing process itself in more detail on my backlog for a while, but I've added it as an issue in the public repo just now with notes on this detail, so when I—or someone else, if the community beats me to it—write the docs, this will be included!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...