Skip to content

Commit

Permalink
hotfix on task payload
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Oct 2, 2024
1 parent cf60815 commit 936a9b6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dkn-compute"
version = "0.2.6"
version = "0.2.7"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
Expand Down
5 changes: 3 additions & 2 deletions src/payloads/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ impl TaskResponsePayload {
preimage.extend_from_slice(task_id.as_ref());
preimage.extend_from_slice(result.as_ref());

let task_id = task_id.to_string();
let signature = sign_bytes_recoverable(&sha256hash(preimage), signing_secret_key);
let ciphertext = encrypt_bytes(result, encrypting_public_key)?;

Ok(TaskResponsePayload {
ciphertext: hex::encode(ciphertext),
task_id,
signature,
task_id: task_id.to_string(),
ciphertext,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn sign_bytes_recoverable(message: &[u8; 32], secret_key: &SecretKey) -> Str
/// Returns hexadecimal encoded ciphertext.
#[inline]
pub fn encrypt_bytes(data: impl AsRef<[u8]>, public_key: &PublicKey) -> Result<String> {
ecies::encrypt(public_key.serialize().as_slice(), data.as_ref())
ecies::encrypt(&public_key.serialize(), data.as_ref())
.wrap_err("could not encrypt data")
.map(hex::encode)
}
Expand Down

0 comments on commit 936a9b6

Please sign in to comment.