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

Signature Verification Fails for Program Derived Addresses (PDAs) in transferNativeSol #4135

Open
UncleTom29 opened this issue Oct 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@UncleTom29
Copy link

Description and context

I am encountering a signature verification failure when using the transferNativeSol function from the Wormhole SDK. The issue arises during the bridging of native SOL tokens from Solana to another chain. Specifically, the transaction fails with a signature verification error for Program Derived Addresses (PDAs) or ancillary accounts that should not require manual signatures.

I am manually signing the transaction using the necessary keypairs (payer and sender) as expected. However, the error persists, indicating that signatures for certain PDAs are missing or invalid, even though these addresses should be handled automatically by the Solana runtime.

Steps to reproduce

  1. Use transferNativeSol from Wormhole SDK to initiate a native SOL token transfer.
  2. Sign the transaction with the payer / sender keypairs.
  3. Submit the transaction to the Solana network.

Code Snippet:

const { Connection, Keypair, PublicKey } = require('@solana/web3.js');
const { transferNativeSol, tryNativeToUint8Array } = require('@certusone/wormhole-sdk');

const connection = new Connection(getProviderUrl('SOLANA'));
const payerKeypair = Keypair.fromSecretKey(Buffer.from(wallet.privateKey, 'hex'));

const bridgeAddress = new PublicKey(coreBridgeAddresses['SOLANA']);
const tokenBridgeAddress = new PublicKey(tokenBridgeAddresses['SOLANA']);
const transferAmount = BigInt(parseFloat(amount) * LAMPORTS_PER_SOL);
const targetAddress = tryNativeToUint8Array(receivingAddress, receivingChainId);

const transaction = await transferNativeSol(
  connection,
  bridgeAddress,
  tokenBridgeAddress,
  payerKeypair.publicKey,
  transferAmount,
  targetAddress,
  targetChain
);

transaction.feePayer = payerKeypair.publicKey;
transaction.partialSign(payerKeypair);

const rawTransaction = transaction.serialize();
const txid = await connection.sendRawTransaction(rawTransaction);
await connection.confirmTransaction(txid);

Experienced behavior

The transaction fails with the following error message:

Error: Signature verification failed.
Invalid signature for public key(s) [`7o62Jhwp1WHnSiUrfYGTo3D9cb33tDwxU1H3uqvCezdL`, `HMFJPt3hGdtNRwXcQa3moEEwkZaPukjR9G3i4hdbY2aU`].

These public keys correspond to PDAs or ancillary accounts, which are derived automatically by the Wormhole SDK or the Solana runtime. These addresses should not require manual signatures.

Expected behavior

The Program Derived Addresses (PDAs) or ancillary accounts created during the transaction should not require explicit manual signing. The Solana runtime is expected to handle the signature verification for these addresses without issues. The transaction should succeed with only the necessary keypairs being signed (payer and sender).

Solution recommendation

Ensure that PDAs and ancillary accounts used in the transferNativeSol function are handled automatically by the Wormhole SDK, without requiring manual signatures. The SDK should align with Solana's expected runtime behavior where PDAs are verified without manual intervention.

@UncleTom29 UncleTom29 added the bug Something isn't working label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant