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.
(cherry picked from commit b491354e51
)
Conflicts:
Cargo.lock
Cargo.toml
programs/bpf/Cargo.lock
runtime/Cargo.toml
sdk/src/feature_set.rs
sdk/src/transaction.rs
sdk/src/transaction/sanitized.rs
This commit is contained in:
1
sdk/program/src/ed25519_program.rs
Normal file
1
sdk/program/src/ed25519_program.rs
Normal file
@@ -0,0 +1 @@
|
||||
crate::declare_id!("Ed25519SigVerify111111111111111111111111111");
|
@@ -1,5 +1,6 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
use crate::clock::DEFAULT_MS_PER_SLOT;
|
||||
use crate::ed25519_program;
|
||||
use crate::message::Message;
|
||||
use crate::secp256k1_program;
|
||||
use log::*;
|
||||
@@ -28,20 +29,22 @@ impl FeeCalculator {
|
||||
}
|
||||
|
||||
pub fn calculate_fee(&self, message: &Message) -> u64 {
|
||||
let mut num_secp256k1_signatures: u64 = 0;
|
||||
let mut num_signatures: u64 = 0;
|
||||
for instruction in &message.instructions {
|
||||
let program_index = instruction.program_id_index as usize;
|
||||
// Transaction may not be sanitized here
|
||||
if program_index < message.account_keys.len() {
|
||||
let id = message.account_keys[program_index];
|
||||
if secp256k1_program::check_id(&id) && !instruction.data.is_empty() {
|
||||
num_secp256k1_signatures += instruction.data[0] as u64;
|
||||
if (secp256k1_program::check_id(&id) || ed25519_program::check_id(&id))
|
||||
&& !instruction.data.is_empty()
|
||||
{
|
||||
num_signatures += instruction.data[0] as u64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.lamports_per_signature
|
||||
* (u64::from(message.header.num_required_signatures) + num_secp256k1_signatures)
|
||||
* (u64::from(message.header.num_required_signatures) + num_signatures)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@ pub mod bpf_loader_deprecated;
|
||||
pub mod bpf_loader_upgradeable;
|
||||
pub mod clock;
|
||||
pub mod decode_error;
|
||||
pub mod ed25519_program;
|
||||
pub mod entrypoint;
|
||||
pub mod entrypoint_deprecated;
|
||||
pub mod epoch_schedule;
|
||||
|
Reference in New Issue
Block a user