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

Bump ed25519-dalek to 2.1.1, ed25519-dalek-bip32 to 0.3.0 #26

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 66 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ criterion = "0.5.1"
curve25519-dalek = { version = "4.1.3", features = ["digest", "rand_core"] }
derivation-path = { version = "0.2.0", default-features = false }
digest = "0.10.7"
ed25519-dalek = "=1.0.1"
ed25519-dalek-bip32 = "0.2.0"
ed25519-dalek = "=2.1.1"
ed25519-dalek-bip32 = "0.3.0"
env_logger = "0.9.3"
five8_const = "0.1.3"
getrandom = "0.2.10"
Expand Down
2 changes: 1 addition & 1 deletion ed25519-program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ solana-sdk-ids = { workspace = true }

[dev-dependencies]
hex = { workspace = true }
rand0-7 = { workspace = true }
rand = { workspace = true }
solana-hash = { workspace = true }
solana-keypair = { workspace = true }
solana-logger = { workspace = true }
Expand Down
26 changes: 13 additions & 13 deletions ed25519-program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use {
bytemuck::bytes_of,
bytemuck_derive::{Pod, Zeroable},
ed25519_dalek::{ed25519::signature::Signature, Signer, Verifier},
ed25519_dalek::{Signature, Signer, Verifier},
solana_feature_set::{ed25519_precompile_verify_strict, FeatureSet},
solana_instruction::Instruction,
solana_precompile_error::PrecompileError,
Expand Down Expand Up @@ -59,9 +59,9 @@ pub fn offsets_to_ed25519_instruction(offsets: &[Ed25519SignatureOffsets]) -> In
}
}

pub fn new_ed25519_instruction(keypair: &ed25519_dalek::Keypair, message: &[u8]) -> Instruction {
pub fn new_ed25519_instruction(keypair: &ed25519_dalek::SigningKey, message: &[u8]) -> Instruction {
let signature = keypair.sign(message).to_bytes();
let pubkey = keypair.public.to_bytes();
let pubkey = keypair.verifying_key().to_bytes();

assert_eq!(pubkey.len(), PUBKEY_SERIALIZED_SIZE);
assert_eq!(signature.len(), SIGNATURE_SERIALIZED_SIZE);
Expand Down Expand Up @@ -151,7 +151,7 @@ pub fn verify(
)?;

let signature =
Signature::from_bytes(signature).map_err(|_| PrecompileError::InvalidSignature)?;
Signature::from_slice(signature).map_err(|_| PrecompileError::InvalidSignature)?;

// Parse out pubkey
let pubkey = get_data_slice(
Expand All @@ -162,7 +162,7 @@ pub fn verify(
PUBKEY_SERIALIZED_SIZE,
)?;

let publickey = ed25519_dalek::PublicKey::from_bytes(pubkey)
let publickey = ed25519_dalek::VerifyingKey::try_from(pubkey)
.map_err(|_| PrecompileError::InvalidPublicKey)?;

// Parse out message
Expand Down Expand Up @@ -219,7 +219,7 @@ pub mod test {
super::*,
ed25519_dalek::Signer as EdSigner,
hex,
rand0_7::{thread_rng, Rng},
rand::{thread_rng, Rng},
solana_feature_set::FeatureSet,
solana_hash::Hash,
solana_keypair::Keypair,
Expand Down Expand Up @@ -437,7 +437,7 @@ pub mod test {
fn test_ed25519() {
solana_logger::setup();

let privkey = ed25519_dalek::Keypair::generate(&mut thread_rng());
let privkey = ed25519_dalek::SigningKey::generate(&mut thread_rng());
let message_arr = b"hello";
let mut instruction = new_ed25519_instruction(&privkey, message_arr);
let mint_keypair = Keypair::new();
Expand All @@ -453,7 +453,7 @@ pub mod test {
assert!(tx.verify_precompiles(&feature_set).is_ok());

let index = loop {
let index = thread_rng().gen_range(0, instruction.data.len());
let index = thread_rng().gen_range(0..instruction.data.len());
// byte 1 is not used, so this would not cause the verify to fail
if index != 1 {
break index;
Expand All @@ -474,7 +474,7 @@ pub mod test {
fn test_offsets_to_ed25519_instruction() {
solana_logger::setup();

let privkey = ed25519_dalek::Keypair::generate(&mut thread_rng());
let privkey = ed25519_dalek::SigningKey::generate(&mut thread_rng());
let messages: [&[u8]; 3] = [b"hello", b"IBRL", b"goodbye"];
let data_start =
messages.len() * SIGNATURE_OFFSETS_SERIALIZED_SIZE + SIGNATURE_OFFSETS_START;
Expand Down Expand Up @@ -502,8 +502,8 @@ pub mod test {

let mut instruction = offsets_to_ed25519_instruction(&offsets);

let pubkey = privkey.public.as_ref();
instruction.data.extend_from_slice(pubkey);
let pubkey = privkey.verifying_key();
instruction.data.extend_from_slice(pubkey.as_ref());

for message in messages {
let signature = privkey.sign(message).to_bytes();
Expand All @@ -524,7 +524,7 @@ pub mod test {
assert!(tx.verify_precompiles(&feature_set).is_ok());

let index = loop {
let index = thread_rng().gen_range(0, instruction.data.len());
let index = thread_rng().gen_range(0..instruction.data.len());
// byte 1 is not used, so this would not cause the verify to fail
if index != 1 {
break index;
Expand All @@ -547,7 +547,7 @@ pub mod test {
let mint_keypair = Keypair::new();

// sig created via ed25519_dalek: both pass
let privkey = ed25519_dalek::Keypair::generate(&mut thread_rng());
let privkey = ed25519_dalek::SigningKey::generate(&mut thread_rng());
let message_arr = b"hello";
let instruction = new_ed25519_instruction(&privkey, message_arr);
let tx = Transaction::new_signed_with_payer(
Expand Down
4 changes: 2 additions & 2 deletions keypair/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ edition = { workspace = true }

[dependencies]
bs58 = { workspace = true, features = ["std"] }
ed25519-dalek = { workspace = true }
ed25519-dalek = { workspace = true, features = ["rand_core"] }
ed25519-dalek-bip32 = { workspace = true, optional = true }
rand0-7 = { workspace = true }
rand = { workspace = true }
solana-derivation-path = { workspace = true, optional = true }
solana-pubkey = { workspace = true }
solana-seed-derivable = { workspace = true, optional = true }
Expand Down
Loading
Loading