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

Ability To Sign Arbitrary Strings #29

Open
claytantor opened this issue Feb 17, 2023 · 0 comments
Open

Ability To Sign Arbitrary Strings #29

claytantor opened this issue Feb 17, 2023 · 0 comments

Comments

@claytantor
Copy link

When attempting to create an identity JWT for the wallet, which could be used for a backend, there is no way to sign the jwt payload. Using signTransaction returns an empty string.

Given a common JWT payload:

const payload = {
            "pk": ledgerAccount.publicKey,
            "sub": ledgerAccount.address,
            "exp": exp,
            "iat": d.getTime()
        }

and a ledger sign implementation with HID transport...

  // secp256k1 is the default curve used by XRP
  const signPayload = async (
    payload,
    accountIndex = 0, // change that to get details of accounts at different indexes
    keyIndex = 0, 
    ledgerTransport) => 
  {
    let transport = ledgerTransport
    if (!transport) {
      transport = await getLedgerTransport()
      if (!transport) {
        return undefined
      }
    }

    const xrp = new AppXrp(transport)
    console.log("sign payload", payload);

    try {
      const bip32Path = `44'/144'/${accountIndex}'/0/${keyIndex}`;
      const txe = encode(payload);
      const signedPayload = await xrp.signTransaction(bip32Path, txe);
      console.log("signTransaction signedPayload", signedPayload);
      return { signedPayload, bip32Path }
    } 
    catch (error) {
      if (error instanceof Error) {
        console.error(error)
        return
        // handleError(error)
      }
      return undefined
    }  
  }

an empty result is returned for the signed body.

{
    "signedPayload": "",
    "bip32Path": "44'/144'/0'/0/0"
}
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

1 participant