Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

what's the address of the precompiled contract SR25519.sol? #39

Closed
LaceLetho opened this issue Apr 13, 2022 · 6 comments
Closed

what's the address of the precompiled contract SR25519.sol? #39

LaceLetho opened this issue Apr 13, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@LaceLetho
Copy link

Description

I'm trying to utilize the SR25519.sol interface to verify a sr25519 encrypted message

I have tried on Shiden at 0x0000000000000000000000000000000000005001
but it threw a VM exception: revert

@LaceLetho LaceLetho added the bug Something isn't working label Apr 13, 2022
@Dinonard
Copy link
Member

Dinonard commented Apr 13, 2022

Hello,

You can find the exact address used in the precompiles.rs file in Astar repo.
E.g. for Shiden:
https://github.com/AstarNetwork/Astar/blob/master/runtime/shiden/src/precompiles.rs

Please note that even though you might see that e.g. Astar has some precompiles, that doesn't mean it's already live on chain.
Make sure also to compare spec_version of the code in the repo to the one that's deployed on-chain.

@LaceLetho
Copy link
Author

Thanks for your detailed explanation, now I know the address is 0x5002 and it's live on Shiden.

But when I test it, I can't get expected result.

const c = await ethers.getContractAt("SR25519","0x0000000000000000000000000000000000005002");

const r = await c.verify("0xcae65573cd7522dbed18547b872d66f663b1765b3ee1544d84a5b34c38038f6e",
"0xf4101bf19623d82998e4e55324127f056b8af7b81da17716ce630534d857583259efb40626529e4b09afbe6a0edf1549de0c36a59b6bbcac2dd2ed07bae47586",
"0x6f");

console.log(r);

the code above return false, but I get true while verify the message in polkadot.js portal
image

Is it caused by any mistake in the verify's param type?

ps: the "ethers" object is in hardhat context

@Dinonard
Copy link
Member

Dinonard commented Apr 13, 2022

Could be the encoding of the data in your script.

verify signature looks like:

    function verify(
        bytes32 public_key,
        bytes calldata signature,
        bytes calldata message
    ) external view returns (bool);

I haven't used this myself but perhaps @Maar-io can help.

@Dinonard
Copy link
Member

You can check https://github.com/AstarNetwork/astarbase for code examples on how the contract is used.

I will close this ticket since it's not a bug.

@Maar-io
Copy link
Member

Maar-io commented Apr 20, 2022

@LaceLetho please check how the message is built before you sign it.
you need to have PREFIX and POSTFIX, just like astarbase contract is using it

@LaceLetho
Copy link
Author

Got it, thanks for your explanation

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants