Using ed_verify to validate signature

I’m developing a predicate to validate a signature using Solana network wallets. To accomplish this, I’m utilizing the ed_verify() function. However, despite passing mocked values for the public key, signature, and message hash, the function consistently fails to return true.

Code of my POC

forc = “0.56.0”
fuel-core = “0.26.0”
sway = “0.59.0”

Predicate code:

predicate;

use std::{
    b512::B512,
    constants::ZERO_B256,
    ecr::{
        EcRecoverError,
        ed_verify,
    },
    tx::{
        tx_id,
        tx_witness_data,
    },
};

configurable {
    SIGNER: b256 = ZERO_B256,
}

fn main() -> bool {
    let signature: B512 = tx_witness_data(0);

    let result = ed_verify(SIGNER, signature, tx_id());

    return result.is_ok();
}

Error:
image

How to run the project:

  1. run command pnpm chain:start to start local network
  2. you can run pnpm build:resources to generate predicate and script
  3. Run pnpm dev to start the project

To get a project id you can access this link

1 Like

HI @pedropereiradev ,

  1. Can you provide the full results of your fuelup show here.

  2. Can you attempt to see if the predicate execution works if you just return true; first, just to ensure there isn’t something else failing in the predicate execution itself.

  3. Have you tried the actual ED255 test data for the ed_verify function first just to see if the data we used in our own test works against your function here.

  4. Can you provide the exact ED255 verification data here that you are using, i.e. the transaction hash, signature and account?

1 Like

Versions Config build:
image

1 Like

I changed my script to use the example and receipt true as expected

I’m thinking that the problem could be when I make the conversion of solana public key to b256 pattern.

1 Like

Here is a print of fuelup show:
image

Hi @pedropereiradev ,

Can you try using the example data for the ed_verify function first? The example code can be found here:

Then, can you try recovering this Solana signature/public key/message with a Typescript or Rust ED25519-dalek library, such as:

Then if you get it recovering, post the code for that here. This will help us rule out any particular cryptography issues.

Fuel uses ED25519-DALEK not sure if that is what Solana uses for their keys:

Hi @pedropereiradev ,

Can you try using the example data for the ed_verify module first?

Then, can you try recovering this Solana signature/public key/message with a Typescript or Rust ED25519-dalek library, such as:

Then if you get it recovering, post the code for that here. This will help us rule out any particular cryptography issues.

Fuel uses ED25519-DALEK not sure if that is what Solana uses for their keys: