secret_store: use ecies::encrypt/ecies::decrypt. (#8125)

This commit is contained in:
Toralf Wittner 2018-03-15 16:49:13 +01:00 committed by Svyatoslav Nikolsky
parent acd7192b17
commit fed4864939

View File

@ -19,7 +19,7 @@ use std::u16;
use std::ops::Deref; use std::ops::Deref;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use serde_json; use serde_json;
use ethcrypto::ecies::{encrypt_single_message, decrypt_single_message}; use ethcrypto::ecies;
use ethkey::{Secret, KeyPair}; use ethkey::{Secret, KeyPair};
use ethkey::math::curve_order; use ethkey::math::curve_order;
use ethereum_types::{H256, U256}; use ethereum_types::{H256, U256};
@ -241,7 +241,7 @@ pub fn deserialize_message(header: &MessageHeader, payload: Vec<u8>) -> Result<M
pub fn encrypt_message(key: &KeyPair, message: SerializedMessage) -> Result<SerializedMessage, Error> { pub fn encrypt_message(key: &KeyPair, message: SerializedMessage) -> Result<SerializedMessage, Error> {
let mut header: Vec<_> = message.into(); let mut header: Vec<_> = message.into();
let payload = header.split_off(MESSAGE_HEADER_SIZE); let payload = header.split_off(MESSAGE_HEADER_SIZE);
let encrypted_payload = encrypt_single_message(key.public(), &payload)?; let encrypted_payload = ecies::encrypt(key.public(), &[], &payload)?;
let header = deserialize_header(&header)?; let header = deserialize_header(&header)?;
build_serialized_message(header, encrypted_payload) build_serialized_message(header, encrypted_payload)
@ -249,7 +249,7 @@ pub fn encrypt_message(key: &KeyPair, message: SerializedMessage) -> Result<Seri
/// Decrypt serialized message. /// Decrypt serialized message.
pub fn decrypt_message(key: &KeyPair, payload: Vec<u8>) -> Result<Vec<u8>, Error> { pub fn decrypt_message(key: &KeyPair, payload: Vec<u8>) -> Result<Vec<u8>, Error> {
Ok(decrypt_single_message(key.secret(), &payload)?) Ok(ecies::decrypt(key.secret(), &[], &payload)?)
} }
/// Fix shared encryption key. /// Fix shared encryption key.