Skip to content

Commit

Permalink
fix: remove proxy pub keys from commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gluax committed Aug 20, 2024
1 parent e07be57 commit b1857be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 40 deletions.
49 changes: 14 additions & 35 deletions src/msgs/data_requests/execute/commit_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,19 @@ use super::*;
#[cfg_attr(not(feature = "cosmwasm"), derive(Serialize, Debug, PartialEq))]
#[cfg_attr(not(feature = "cosmwasm"), serde(rename_all = "snake_case"))]
pub struct Execute {
pub dr_id: String,
pub commitment: String,
pub proxy_public_keys: Vec<String>,
pub public_key: String,
pub proof: String,
pub dr_id: String,
pub commitment: String,
pub public_key: String,
pub proof: String,
}

impl Execute {
fn generate_hash(
dr_id: &str,
commitment: &str,
proxy_public_keys: &[String],
chain_id: &str,
contract_addr: &str,
dr_height: u64,
) -> Hash {
fn generate_hash(dr_id: &str, commitment: &str, chain_id: &str, contract_addr: &str, dr_height: u64) -> Hash {
hash([
"commit_data_result".as_bytes(),
dr_id.as_bytes(),
&dr_height.to_be_bytes(),
commitment.as_bytes(),
&proxy_public_keys.hash(),
chain_id.as_bytes(),
contract_addr.as_bytes(),
])
Expand All @@ -43,7 +34,6 @@ impl VerifySelf for Execute {
Ok(Self::generate_hash(
&self.dr_id,
&self.commitment,
&self.proxy_public_keys,
chain_id,
contract_addr,
dr_height,
Expand All @@ -52,11 +42,10 @@ impl VerifySelf for Execute {
}

pub struct ExecuteFactory {
dr_id: String,
commitment: String,
proxy_public_keys: Vec<String>,
public_key: String,
hash: Hash,
dr_id: String,
commitment: String,
public_key: String,
hash: Hash,
}

impl ExecuteFactory {
Expand All @@ -66,11 +55,10 @@ impl ExecuteFactory {

pub fn create_message(self, proof: Vec<u8>) -> crate::msgs::ExecuteMsg {
Execute {
dr_id: self.dr_id,
commitment: self.commitment,
proxy_public_keys: self.proxy_public_keys,
public_key: self.public_key,
proof: proof.to_hex(),
dr_id: self.dr_id,
commitment: self.commitment,
public_key: self.public_key,
proof: proof.to_hex(),
}
.into()
}
Expand All @@ -81,23 +69,14 @@ impl Execute {
dr_id: String,
commitment: String,
public_key: String,
proxy_public_keys: Vec<String>,
chain_id: &str,
contract_addr: &str,
dr_height: u64,
) -> ExecuteFactory {
let hash = Self::generate_hash(
&dr_id,
&commitment,
&proxy_public_keys,
chain_id,
contract_addr,
dr_height,
);
let hash = Self::generate_hash(&dr_id, &commitment, chain_id, contract_addr, dr_height);
ExecuteFactory {
dr_id,
commitment,
proxy_public_keys,
public_key,
hash,
}
Expand Down
9 changes: 4 additions & 5 deletions src/msgs/data_requests/execute_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ fn json_commit_result() {
}
});
let msg: ExecuteMsg = commit_result::Execute {
dr_id: "dr_id".to_string(),
commitment: "commitment".to_string(),
proxy_public_keys: vec!["proxy_public_key".to_string()],
public_key: "public_key".to_string(),
proof: "proof".to_string(),
dr_id: "dr_id".to_string(),
commitment: "commitment".to_string(),
public_key: "public_key".to_string(),
proof: "proof".to_string(),
}
.into();
#[cfg(not(feature = "cosmwasm"))]
Expand Down

0 comments on commit b1857be

Please sign in to comment.