Skip to content

Wrong payload being signed #1442

@gagdiez

Description

@gagdiez

The current implementation of SignTransaction signs the transaction.encode(), which is the borsh serialized version of the transaction:

const encodedTx = transaction.encode();
const signedTransaction = new SignedTransaction({
transaction,
signature: new Signature({
keyType: transaction.publicKey.keyType,
data: await signer.signMessage(encodedTx),
}),
});

In reality, we need to sign the sha256 hash of the borsh serialized transaction:

const encodedTx = new Uint8Array(sha256.sha256.array(transaction.encode()));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Shipped 🚀

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions