-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Implement EIP-1024 #11284
base: master
Are you sure you want to change the base?
feat: Implement EIP-1024 #11284
Conversation
It looks like @hskang9 signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
the next step here would probably be to expose these methods as an rpc endpoint |
util/EIP-1024/src/lib.rs
Outdated
let send_pk = Public::from_unsafe_slice(&pk_byte32).unwrap(); | ||
let cipher_bytes = hex::decode(encrypted_data.ciphertext).unwrap(); | ||
let nonce_bytes = hex::decode(encrypted_data.nonce).unwrap(); | ||
let nonce = array_ref!(nonce_bytes, 0, 24).clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use copy_from_slice instead and remove dependency to arrayref
util/EIP-1024/src/lib.rs
Outdated
let nonce = array_ref!(nonce_bytes, 0, 24).clone(); | ||
println!("cipher_bytes: {:?}\n nonce: {:?}\n send_pk: {:?}\n recv_sk: {:?}\n", cipher_bytes, nonce, hex::encode(*send_pk), hex::encode(recv_sk.secret()) ); | ||
let result = saltbabe::crypto_box::open(&cipher_bytes, &nonce, &send_pk, &recv_sk.secret()).unwrap(); | ||
return Ok(str::from_utf8(&result.clone()).unwrap().to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be something like:
saltbabe::crypto_box::open(&cipher_bytes, &nonce, &send_pk, &recv_sk.secret())
.and_then(|r| String::from_utf8(r).map_err(|e| Error::Custom(e.to_string())))
|
||
pub fn gen_keypair() -> KeyPair<Secret, Public> { | ||
|
||
KeyPair::<Secret, Public>::generate_keypair().unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either change so that this function returns Result<KeyPair, Error>
or use expect!
and provide a proof why is it is infallible.
|
||
#[cfg(test)] | ||
mod tests { | ||
extern crate saltbabe; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extern crate not needed
@@ -0,0 +1,139 @@ | |||
extern crate saltbabe; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the file is missing license header.
FYI, this PR depends on |
description = "EIP-1024 encryption" | ||
keywords = ["eip-1024", "eip1024", "eip"] | ||
license = "GPL-3.0" | ||
authors = ["hskang9 <[email protected]>"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should include Parity Technologies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -0,0 +1,674 @@ | |||
GNU GENERAL PUBLIC LICENSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a copy in the main directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
use saltbabe::traits::FromUnsafeSlice; | ||
|
||
fn main() { | ||
let bob_sk = "mJxmrVq8pfeR80HMZBTkjV+RiND1lqPqLuCdDUiduis="; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is correctly indented using tabs, the rest uses spaces. Please reformat to all tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
util/EIP-1024/src/lib.rs
Outdated
const VERSION: &str = "x25519-xsalsa20-poly1305"; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct EncryptedData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to enforce documentation for all public types:
#![warn(missing_docs)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
util/EIP-1024/src/lib.rs
Outdated
@@ -0,0 +1,139 @@ | |||
extern crate saltbabe; | |||
#[macro_use] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use tabs
across the entire codebase, could you please reformat this file (and all other files) accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
util/EIP-1024/Cargo.toml
Outdated
edition = "2018" | ||
|
||
[dependencies] | ||
saltbabe = "0.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This crate is missing a link to the repo, where can we inspect the code easily and file issues in case of problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I should add that.
Exposing over RPC is missing. This crate is now only standalone, I don't think it full covers #9893 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my way to make RPC in traits
and impl
folder. I will work on eth.rs
file.
@hskang9 status on this? |
Sorry for late response. I thought this was excluded in Eth 2.0 timeline, so I thought this was halted. I will try to work on this. |
resolves #9893