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

feat(eth): <- adds sha256 message signer to that #27

Merged
merged 4 commits into from
May 8, 2024
Merged
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
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion common/eos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "eos"
license = "MIT"
publish = false
edition = "2021"
version = "6.11.3"
version = "6.11.4"
readme = "README.md"
rust-version = "1.56"
keywords = ["provable", "defi", "crypto"]
Expand Down
10 changes: 0 additions & 10 deletions common/eos/src/eos_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,3 @@ pub struct ProducerSchedule {
pub version: u32,
pub producers: ProducerKeys,
}

#[derive(Debug)]
pub struct EosRawTxData {
pub sender: String,
pub mint_nonce: u64,
pub receiver: String,
pub asset_amount: u64,
pub asset_name: String,
pub eth_address: String,
}
2 changes: 1 addition & 1 deletion common/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ license = "MIT"
publish = false
edition = "2021"
name = "ethereum"
version = "6.14.1"
version = "6.15.0"
readme = "README.md"
rust-version = "1.56"
keywords = ["defi", "crypto"]
Expand Down
13 changes: 11 additions & 2 deletions common/ethereum/src/eth_crypto/eth_private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{convert::TryFrom, fmt, str::FromStr};

use common::{
constants::MAX_DATA_SENSITIVITY_LEVEL,
crypto_utils::{generate_random_private_key, keccak_hash_bytes},
crypto_utils::{generate_random_private_key, keccak_hash_bytes, sha256_hash_bytes},
strip_hex_prefix,
traits::DatabaseInterface,
types::{Byte, Result},
Expand Down Expand Up @@ -91,10 +91,19 @@ impl EthSigningCapabilities for EthPrivateKey {
self.sign_hash(hash).map(EthSignature::set_recovery_param)
}

fn hash_and_sign_msg(&self, message: &[Byte]) -> Result<EthSignature> {
fn keccak_hash_and_sign_msg(&self, message: &[Byte]) -> Result<EthSignature> {
self.sign_hash(keccak_hash_bytes(message))
}

fn sha256_hash_and_sign_msg(&self, message: &[Byte]) -> Result<EthSignature> {
self.sign_hash(H256::from_slice(&sha256_hash_bytes(message)))
}

fn hash_and_sign_msg(&self, message: &[Byte]) -> Result<EthSignature> {
// NOTE: For backwards compatibility, where keccack was the default hashing for eth sigs
self.keccak_hash_and_sign_msg(message)
}

fn hash_and_sign_msg_with_eth_prefix(&self, message: &[Byte]) -> Result<EthSignature> {
let eth_msg_prefix = b"\x19Ethereum Signed Message:\n";

Expand Down
2 changes: 2 additions & 0 deletions common/ethereum/src/eth_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub trait EthTxInfoCompatible {
pub trait EthSigningCapabilities {
fn sign_hash(&self, hash: EthHash) -> Result<EthSignature>;
fn hash_and_sign_msg(&self, message: &[Byte]) -> Result<EthSignature>;
fn keccak_hash_and_sign_msg(&self, message: &[Byte]) -> Result<EthSignature>;
fn sha256_hash_and_sign_msg(&self, message: &[Byte]) -> Result<EthSignature>;
fn hash_and_sign_msg_with_eth_prefix(&self, message: &[Byte]) -> Result<EthSignature>;
fn sign_hash_and_set_eth_recovery_param(&self, hash: EthHash) -> Result<EthSignature>;
}
2 changes: 1 addition & 1 deletion common/sentinel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
edition = "2021"
version = "0.2.0"
version = "0.2.1"
name = "sentinel-lib"
authors = [ "Greg Kapka <gregkapka@gmail.com>" ]
description = "shared fxnality for pTokens sentinels"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,26 @@ impl TryFrom<Vec<String>> for WebSocketMessagesResetChainArgs {
});
}

let mut arg = args[0].clone();
let arg1 = args[0].clone();

let network_id = NetworkId::try_from(&arg).map_err(|_| WebSocketMessagesError::UnrecognizedNetworkId(arg))?;
let network_id = NetworkId::try_from(&arg1).map_err(|_| WebSocketMessagesError::UnrecognizedNetworkId(arg1))?;

arg = args[1].clone();
let use_latest_block = matches!(arg.to_lowercase().as_ref(), "latest");
let arg2 = args[1].clone();
let use_latest_block = matches!(arg2.to_lowercase().as_ref(), "latest");

let block_num = if use_latest_block {
None
} else {
let n = arg.parse::<u64>().map_err(|_| WebSocketMessagesError::ParseInt(arg))?;
let n = arg2
.parse::<u64>()
.map_err(|_| WebSocketMessagesError::ParseInt(arg2))?;
Some(n)
};

arg = args[2].clone();
let confs = arg.parse::<u64>().map_err(|_| WebSocketMessagesError::ParseInt(arg))?;
let arg3 = args[2].clone();
let confs = arg3
.parse::<u64>()
.map_err(|_| WebSocketMessagesError::ParseInt(arg3))?;

let validate = matches!(args[3].as_ref(), "true");

Expand Down
Loading