# Using ed\_verify to validate signature

**URL:** <https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870>\
**Category:** Sway\
**Created:** [June 17, 2024, 2:00pm UTC](https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870 "2024-06-17T14:00:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedropereiradev](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/pedropereiradev/32/3176_2.png) [@pedropereiradev](https://forum.fuel.network/u/pedropereiradev)\
**Post date:** [June 17, 2024, 2:00pm UTC](https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870/1 "2024-06-17T14:00:07Z")

</div>

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](https://github.com/pedropereiradev/walletconnect-solana-js)

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

Predicate code:

```auto
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](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/b/b2af0a6d7c81f1c832c8727502ebbb7f37be2f56.png)

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](https://cloud.walletconnect.com/)

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/nick/32/2330_2.png) [@nick](https://forum.fuel.network/u/nick)\
**Post date:** [June 17, 2024, 2:36pm UTC](https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870/2 "2024-06-17T14:36:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pedropereiradev](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/pedropereiradev/32/3176_2.png) [@pedropereiradev](https://forum.fuel.network/u/pedropereiradev)\
**Post date:** [June 17, 2024, 4:58pm UTC](https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870/3 "2024-06-17T16:58:16Z")

</div>

Versions Config build:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/6/6464c16e454692bea9e72ae08438c3e60a475918.png)

---

<div class="post-metadata">

**Author:** ![pedropereiradev](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/pedropereiradev/32/3176_2.png) [@pedropereiradev](https://forum.fuel.network/u/pedropereiradev)\
**Post date:** [June 17, 2024, 4:58pm UTC](https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870/4 "2024-06-17T16:58:48Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/8/873c5f85a11198af97f689492ecc42403167ced0.png)

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

---

<div class="post-metadata">

**Author:** ![pedropereiradev](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/pedropereiradev/32/3176_2.png) [@pedropereiradev](https://forum.fuel.network/u/pedropereiradev)\
**Post date:** [June 17, 2024, 8:18pm UTC](https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870/5 "2024-06-17T20:18:37Z")

</div>

Here is a print of `fuelup show`:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/d/d454e483f5be9bcfa2e9a09ffe831f789ebfa9cd.png)

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/nick/32/2330_2.png) [@nick](https://forum.fuel.network/u/nick)\
**Post date:** [June 19, 2024, 9:44am UTC](https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870/6 "2024-06-19T09:44:50Z")

</div>

Hi @pedropereiradev ,

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

> <https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/ecr.sw#L141>

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

> **[ed25519\_dalek - Rust](https://docs.rs/ed25519-dalek/latest/ed25519_dalek/)**
>
> A Rust implementation of ed25519 key generation, signing, and verification.

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:

> **[Fuel Specifications | Fuel Docs](https://docs.fuel.network/docs/specs/protocol/cryptographic-primitives/#eddsa-public-key-cryptography)**
>
> Official specifications for the Fuel Network

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/nick/32/2330_2.png) [@nick](https://forum.fuel.network/u/nick)\
**Post date:** [June 19, 2024, 9:58am UTC](https://forum.fuel.network/t/using-ed-verify-to-validate-signature/5870/7 "2024-06-19T09:58:21Z")

</div>

Hi @pedropereiradev ,

Can you try using the example data for the ed\_verify module first?

> <https://github.com/FuelLabs/sway/blob/7f8f31843bed8459c53196bd6b689c0b05b05f61/test/src/in_language_tests/test_programs/ecr_inline_tests/src/main.sw#L110>

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

> **[ed25519\_dalek - Rust](https://docs.rs/ed25519-dalek/latest/ed25519_dalek/)**
>
> A Rust implementation of ed25519 key generation, signing, and verification.

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:

> **[Fuel Specifications | Fuel Docs](https://docs.fuel.network/docs/specs/protocol/cryptographic-primitives/#eddsa-public-key-cryptography)**
>
> Official specifications for the Fuel Network
