feat: add ed25519 signature verify program

Solang requires a method for verify ed25519 signatures. Add a new
builtin program at address Ed25519SigVerify111111111111111111111111111
which takes any number of ed25519 signature, public key, and message.
If any of the signatures fails to verify, an error is returned.

The changes for the web3.js package will go into another commit, since
the tests test against a released solana node. Adding web3.js ed25519
testing will break CI.
This commit is contained in:
Sean Young
2021-09-03 22:35:38 +01:00
parent d461a9ac10
commit 8b9e472a6c
17 changed files with 577 additions and 13 deletions

View File

@ -4,6 +4,7 @@
use {
crate::{
ed25519_instruction::verify_signatures,
hash::Hash,
instruction::{CompiledInstruction, Instruction, InstructionError},
message::{Message, SanitizeMessageError},
@ -450,6 +451,18 @@ impl Transaction {
feature_set.is_active(&feature_set::libsecp256k1_fail_on_bad_count::id()),
);
e.map_err(|_| TransactionError::InvalidAccountIndex)?;
} else if crate::ed25519_program::check_id(program_id)
&& feature_set.is_active(&feature_set::ed25519_program_enabled::id())
{
let instruction_datas: Vec<_> = self
.message()
.instructions
.iter()
.map(|instruction| instruction.data.as_ref())
.collect();
let data = &instruction.data;
let e = verify_signatures(data, &instruction_datas);
e.map_err(|_| TransactionError::InvalidAccountIndex)?;
}
}
Ok(())

View File

@ -2,6 +2,7 @@
use {
crate::{
ed25519_instruction::verify_signatures,
hash::Hash,
message::{v0, MappedAddresses, MappedMessage, SanitizedMessage, VersionedMessage},
nonce::NONCED_TX_MARKER_IX_INDEX,
@ -222,6 +223,18 @@ impl SanitizedTransaction {
feature_set.is_active(&feature_set::libsecp256k1_fail_on_bad_count::id()),
);
e.map_err(|_| TransactionError::InvalidAccountIndex)?;
} else if crate::ed25519_program::check_id(program_id)
&& feature_set.is_active(&feature_set::ed25519_program_enabled::id())
{
let instruction_datas: Vec<_> = self
.message()
.instructions()
.iter()
.map(|instruction| instruction.data.as_ref())
.collect();
let data = &instruction.data;
let e = verify_signatures(data, &instruction_datas);
e.map_err(|_| TransactionError::InvalidAccountIndex)?;
}
}
Ok(())