Revert-revert migrate to ed25519-dalek crate (#3877)

* Revert "Revert "Migrate from ring to ed25519-dalek, take 2 (#3844)" (#3868)"

This reverts commit 6a878602f2.

* Fix Signature::verify method
This commit is contained in:
Tyera Eulberg
2019-04-18 14:37:20 -06:00
committed by GitHub
parent 8514d27c2f
commit a9cfae486c
14 changed files with 156 additions and 111 deletions

View File

@@ -14,6 +14,7 @@ use crate::streamer::receiver;
use crate::streamer::responder;
use crate::window_service::WindowService;
use bincode::deserialize;
use ed25519_dalek;
use rand::thread_rng;
use rand::Rng;
use solana_client::rpc_client::RpcClient;
@@ -60,7 +61,7 @@ pub struct Replicator {
slot: u64,
ledger_path: String,
storage_keypair: Arc<Keypair>,
signature: ring::signature::Signature,
signature: ed25519_dalek::Signature,
cluster_entrypoint: ContactInfo,
ledger_data_file_encrypted: PathBuf,
sampling_offsets: Vec<u64>,
@@ -107,10 +108,10 @@ pub fn sample_file(in_path: &Path, sample_offsets: &[u64]) -> io::Result<Hash> {
}
fn get_entry_heights_from_blockhash(
signature: &ring::signature::Signature,
signature: &ed25519_dalek::Signature,
storage_entry_height: u64,
) -> u64 {
let signature_vec = signature.as_ref();
let signature_vec = signature.to_bytes();
let mut segment_index = u64::from(signature_vec[0])
| (u64::from(signature_vec[1]) << 8)
| (u64::from(signature_vec[1]) << 16)
@@ -354,7 +355,7 @@ impl Replicator {
#[cfg(feature = "chacha")]
{
let mut ivec = [0u8; 64];
ivec.copy_from_slice(self.signature.as_ref());
ivec.copy_from_slice(&self.signature.to_bytes());
let num_encrypted_bytes = chacha_cbc_encrypt_ledger(
&self.blocktree,
@@ -383,7 +384,7 @@ impl Replicator {
use rand_chacha::ChaChaRng;
let mut rng_seed = [0u8; 32];
rng_seed.copy_from_slice(&self.signature.as_ref()[0..32]);
rng_seed.copy_from_slice(&self.signature.to_bytes()[0..32]);
let mut rng = ChaChaRng::from_seed(rng_seed);
for _ in 0..NUM_STORAGE_SAMPLES {
self.sampling_offsets
@@ -448,7 +449,7 @@ impl Replicator {
&self.storage_keypair.pubkey(),
self.hash,
self.slot,
Signature::new(self.signature.as_ref()),
Signature::new(&self.signature.to_bytes()),
);
let mut tx = Transaction::new_unsigned_instructions(vec![ix]);
client