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

ED25519 signature verification #211

Open
ronanyeah opened this issue Jan 18, 2022 · 5 comments
Open

ED25519 signature verification #211

ronanyeah opened this issue Jan 18, 2022 · 5 comments
Labels
Reference Reference for the Cookbook

Comments

@ronanyeah
Copy link

I am trying to figure out if signature verification is possible onchain. If it is I will create an example for the cookbook.

I have tried to implement it with various ed25519 rust crates but keep running out of CPU:
Screenshot from 2022-01-17 22-31-46

I think this file is relevant, but relates to the SDK (which is offchain only):
https://github.com/solana-labs/solana/blob/master/sdk/src/ed25519_instruction.rs

@ronanyeah
Copy link
Author

I'm hoping to achieve something like this:

fn verify(message: &[u8; 32], sig_bytes: &[u8; 64], signer: &Pubkey) -> bool {
    let signature = Signature::new(sig_bytes);
    let keypair = Signer::new(signer.to_bytes());
    let result = keypair.verify(message, &signature);
    result.is_ok()
}

@jacobcreech
Copy link
Collaborator

jacobcreech commented Jan 18, 2022

@ronanyeah you should be able to achieve this with the ed25519 program https://docs.solana.com/developing/runtime-facilities/programs#ed25519-program

CPI to that program within yours and you're good

@ronanyeah
Copy link
Author

Thanks! I'm currently porting this file from Transaction::new_signed_with_payer to use CPI, invoke(...) etc.

@ronanyeah
Copy link
Author

ronanyeah commented Jan 18, 2022

Apparently this program doesn't work for CPI for GPU reasons: Program failed to complete: Program Ed25519SigVerify111111111111111111111111111 not supported by inner instructions

solana-labs/solana#19843

Apparently the correct approach is to verify the signature in a separate instruction, then walk through the instructions in your program code using Sysvar1nstructions1111111111111111111111111 to confirm the signature value.

@jacobcreech jacobcreech added the Reference Reference for the Cookbook label Feb 28, 2022
@ZafarMansoori
Copy link

I want to verify multiple signature in solana smart contract how can i do this . i am able to verify signle signature in smart contract . but how can i verify multiple signature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reference Reference for the Cookbook
Projects
None yet
Development

No branches or pull requests

3 participants