Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Keypair Derivation (HC-dpki lib) #863

Merged
merged 93 commits into from Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
fdcaf2d
pw fns to enc and dec for util
zo-el Jan 2, 2019
7950723
Merge branch 'refactor-sodium-pkg' into hc-dpki
zo-el Jan 2, 2019
76a71f9
keypair wit seed
zo-el Jan 3, 2019
46425ec
work on keypair, decrypt not working
zo-el Jan 6, 2019
0a8b5a3
decrypte mess usign keypair | without failure case testing
zo-el Jan 7, 2019
38800cb
all tests pass for decodign with failures
zo-el Jan 7, 2019
fb98a97
util for pwencrypt and pwdecode
zo-el Jan 8, 2019
763b9e3
worked on getBundle for keypairs
zo-el Jan 8, 2019
f2f2039
keypair getid done and tested
zo-el Jan 8, 2019
3d4892f
getting keypairs from bundle
zo-el Jan 9, 2019
f547f2d
ran fmt and documentation done
zo-el Jan 9, 2019
f5e007c
refactor to bundle struct
zo-el Jan 9, 2019
48bafb2
added with_raw_parts to the core_types | and refactored using core_ty…
zo-el Jan 10, 2019
07e776d
used with_secure stingyly
zo-el Jan 10, 2019
4c25e2e
improved the bundle type and cleant the code
zo-el Jan 10, 2019
84d8cc7
added secbuf from a string
zo-el Jan 11, 2019
55f9e65
work on seed |deviceseed|devicepinseed|rootseed| tested
zo-el Jan 11, 2019
9bc1c3c
able to get from bundle seeds | tested
zo-el Jan 14, 2019
91c26be
update sodium return types
zo-el Jan 14, 2019
2d7be2f
updated keypair with std return types
zo-el Jan 14, 2019
cd7fcab
Documentation for seed and keypair
zo-el Jan 15, 2019
baefbd4
std seed derivation return types
zo-el Jan 15, 2019
8f48119
fmt
zo-el Jan 15, 2019
d9f0a38
clean up code
zo-el Jan 15, 2019
5c96b73
Merge branch 'develop' into hc-dpki
zo-el Jan 15, 2019
75275e4
func to get mnemonics for a seed
zo-el Jan 15, 2019
b014430
able to get seed from a mnemonic
zo-el Jan 15, 2019
cda067a
make fmt
zo-el Jan 15, 2019
ce9744b
refactor pkg name 'hc_dpki'
zo-el Jan 15, 2019
cc26f78
removed all the panics
zo-el Jan 15, 2019
485c851
added comments to the bundls.rs
zo-el Jan 15, 2019
86a90d1
removed seed derivation
zo-el Jan 15, 2019
d8c94bf
impl SodiumError to the from HolochainError
zo-el Jan 15, 2019
40326a4
small changes
zo-el Jan 15, 2019
1136446
fmt
zo-el Jan 15, 2019
e755523
Merge branch 'develop' into hc-dpki
zo-el Jan 15, 2019
a9669db
cleared most of the unwraps
zo-el Jan 15, 2019
6764bcb
Update doc for get_id
Connoropolous Jan 15, 2019
9a3042d
Update hc_dpki/src/util.rs
Connoropolous Jan 15, 2019
028fea7
optimaized key bundling
zo-el Jan 16, 2019
b8e3755
removed the Keys struct
zo-el Jan 16, 2019
80e88d6
optimized the pw enc fn
zo-el Jan 16, 2019
693ffa1
Merge branch 'hc-dpki' of https://github.com/holochain/holochain-rust…
zo-el Jan 16, 2019
ad13641
make fmt
zo-el Jan 16, 2019
029154f
Merge branch 'develop' into hc-dpki
zo-el Jan 16, 2019
a6fa5b5
Merge branch 'develop' into hc-dpki
zo-el Jan 16, 2019
47f2ede
Merge branch 'develop' into hc-dpki
Jan 17, 2019
7b7286a
Merge branch 'develop' into hc-dpki
zo-el Jan 18, 2019
49f5aff
Merge branch 'develop' into hc-dpki
zo-el Jan 18, 2019
54fcf7b
clean up
zo-el Jan 18, 2019
71cd3b5
Merge branch 'hc-dpki' of https://github.com/holochain/holochain-rust…
zo-el Jan 18, 2019
3068318
bundling process kept secure
zo-el Jan 18, 2019
8e309d4
Merge branch 'develop' into hc-dpki
zo-el Jan 18, 2019
eded169
simplify the conditions on secbuf
zo-el Jan 18, 2019
2b43b88
Merge branch 'hc-dpki' of https://github.com/holochain/holochain-rust…
zo-el Jan 18, 2019
a14794c
Merge branch 'develop' into hc-dpki
zippy Jan 19, 2019
d673284
Merge branch 'develop' into hc-dpki
Jan 21, 2019
b567d21
Merge branch 'develop' into hc-dpki
neonphog Jan 23, 2019
52d263a
keep secrets in secure memory
neonphog Jan 23, 2019
c9d0b5f
Merge pull request #912 from holochain/hc-dpki-david
zo-el Jan 24, 2019
9765947
fmt
neonphog Jan 24, 2019
b62dad2
remove warnings
zo-el Jan 24, 2019
5f534d7
Merge branch 'develop' into hc-dpki
Jan 24, 2019
d2a4429
Merge branch 'develop' into hc-dpki
neonphog Jan 24, 2019
0bb69b3
updated verify fn in keypair
zo-el Jan 24, 2019
2657ea3
Merge branch 'hc-dpki' of https://github.com/holochain/holochain-rust…
zo-el Jan 24, 2019
ec99097
make fmt
zo-el Jan 24, 2019
e82f507
Merge branch 'develop' into hc-dpki
zo-el Jan 24, 2019
e1fc1fb
Merge branch 'develop' into hc-dpki
Jan 25, 2019
d7cc30f
Merge branch 'develop' into hc-dpki
Jan 26, 2019
0ed5606
Merge branch 'develop' into hc-dpki
Jan 26, 2019
751f312
Merge branch 'develop' into hc-dpki
zo-el Jan 27, 2019
bf30b6d
update var names to understand better
zo-el Jan 29, 2019
17c2106
Merge branch 'hc-dpki' of https://github.com/holochain/holochain-rust…
zo-el Jan 29, 2019
888cdaf
Merge branch 'develop' into hc-dpki
zo-el Jan 29, 2019
0bf746b
Merge branch 'develop' into hc-dpki
zo-el Jan 29, 2019
8a232f4
Merge branch 'develop' into hc-dpki
zippy Jan 30, 2019
ac73ecc
Merge branch 'develop' into hc-dpki
Jan 30, 2019
ba3c778
Merge branch 'develop' into hc-dpki
zo-el Feb 1, 2019
1237968
update error
zo-el Feb 1, 2019
e2079c0
fix bug
zo-el Feb 1, 2019
38af31b
fix CI
zo-el Feb 1, 2019
c5d9788
update to pass the ci
zo-el Feb 1, 2019
4f2f147
Merge branch 'develop' into hc-dpki
zo-el Feb 1, 2019
dfcee86
Merge branch 'develop' into hc-dpki
zo-el Feb 2, 2019
559fff8
Merge branch 'develop' into hc-dpki
Feb 2, 2019
4f0f1fe
Merge branch 'develop' into hc-dpki
Feb 4, 2019
37210d9
comment out the decryption and encryption fns
zo-el Feb 5, 2019
f4fceef
Merge branch 'develop' into hc-dpki
zo-el Feb 5, 2019
1529ccd
Merge branch 'develop' into hc-dpki
zo-el Feb 5, 2019
e0f64aa
use interactive password hashing for unit tests
neonphog Feb 5, 2019
5dbd191
Merge branch 'develop' into hc-dpki
zo-el Feb 5, 2019
39d610b
Merge branch 'develop' into hc-dpki
Feb 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -13,6 +13,7 @@ members = [
"net_ipc",
"nodejs_waiter",
"sodium",
"hc_dpki",
"test_bin",
]
exclude = [
Expand Down
2 changes: 0 additions & 2 deletions core_types/Cargo.toml
Expand Up @@ -27,8 +27,6 @@ holochain_core_types_derive = { path = "../core_types_derive" }
uuid = { version = "=0.7.1", features = ["v4"] }
regex = "^1.1"



[dev-dependencies]
test_utils = { path = "../test_utils"}
holochain_core = { path = "../core"}
Expand Down
44 changes: 44 additions & 0 deletions core_types/src/agent.rs
Expand Up @@ -42,6 +42,21 @@ impl KeyBuffer {
KeyBuffer(b.clone())
}

/// generate a key buffer from raw bytes from two parts (no correction)
pub fn with_raw_parts(
a: &[u8; KeyBuffer::HALF_KEY_LEN],
b: &[u8; KeyBuffer::HALF_KEY_LEN],
) -> KeyBuffer {
let mut buf: [u8; KeyBuffer::KEY_LEN] = [0; 64];
for i in 0..KeyBuffer::HALF_KEY_LEN {
buf[i] = a[i];
}
for i in 0..KeyBuffer::HALF_KEY_LEN {
buf[KeyBuffer::HALF_KEY_LEN + i] = b[i];
}
neonphog marked this conversation as resolved.
Show resolved Hide resolved
KeyBuffer(buf)
}

/// render a base64url encoded user identity with reed-solomon parity bytes
pub fn render(&self) -> String {
let enc = Encoder::new(KeyBuffer::PARITY_LEN);
Expand Down Expand Up @@ -151,6 +166,35 @@ mod tests {
format!("{{\"nick\":\"bob\",\"key\":\"{}\"}}", GOOD_ID).into()
}

#[test]
fn it_should_allow_buffer_with_pair() {
// let buf = test_base64_to_agent_id(GOOD_ID).unwrap().to_buffer();
let buf = KeyBuffer::with_raw_parts(
&[
177, 169, 221, 194, 39, 33, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239,
190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239,
],
&[
190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239, 190,
251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 224, 0, 0,
],
);
assert_eq!(
&[
177, 169, 221, 194, 39, 33, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239,
190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239
],
buf.get_sig()
);
assert_eq!(
&[
190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239, 190,
251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 239, 190, 251, 224, 0, 0
],
buf.get_enc()
);
}

#[test]
fn it_should_allow_buffer_access() {
let buf = test_base64_to_agent_id(GOOD_ID).unwrap().to_buffer();
Expand Down
18 changes: 18 additions & 0 deletions hc_dpki/Cargo.toml
@@ -0,0 +1,18 @@
[package]
name = "holochain_dpki"
version = "0.1.0"
authors = ["zo-el<zo@el.org>"]
edition = "2018"

[dependencies]
arrayref = "0.3.5"
base64 = "0.10.0"
bip39 = "0.6.0-beta.1"
boolinator = "2.4.0"
holochain_sodium = { path = "../sodium" }
holochain_core_types = { path = "../core_types" }
serde = "1.0"
serde_derive = "1.0"
serde_json = { version = "1.0", features = ["preserve_order"] }
rustc-serialize = "0.3.24"

18 changes: 18 additions & 0 deletions hc_dpki/src/bundle.rs
@@ -0,0 +1,18 @@
/// This struct is the bundle for the Key pairs. i.e. signing and encryption keys
///
/// The bundle_type tells if the bundle is a RootSeed bundle | DeviceSeed bundle | DevicePINSeed Bundle | ApplicationKeys Bundle
///
/// the data includes a base64 encoded string of the ReturnBundleData Struct that was created by combining all the keys in one SecBuf
pub struct KeyBundle {
pub bundle_type: String,
pub hint: String,
pub data: String,
}

/// This struct type is for the return type for util::pw_enc
#[derive(RustcDecodable, RustcEncodable)]
pub struct ReturnBundleData {
pub salt: Vec<u8>,
pub nonce: Vec<u8>,
pub cipher: Vec<u8>,
}
11 changes: 11 additions & 0 deletions hc_dpki/src/error.rs
@@ -0,0 +1,11 @@
/// Error for hc-dpki lib to use in your code.
#[derive(Debug)]
pub enum DPKIError {
ErrorMessage(String),
}

impl DPKIError {
pub fn new(msg: &str) -> DPKIError {
DPKIError::ErrorMessage(msg.to_string())
}
}