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

Genesis Boot core logic and CLI #31

Merged
merged 43 commits into from
Jun 15, 2022
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
28d49aa
Lots of changes, lots of broken things
jack-kearney Jun 9, 2022
627a26f
Envelope encryption working
jack-kearney Jun 9, 2022
fd00488
Updates but things are broken
jack-kearney Jun 9, 2022
80b7e86
Get envelope encrypt/decrypt working with cbor
emostov Jun 9, 2022
5506754
Run fmt
emostov Jun 9, 2022
214d78a
Remove expects in qos-crypto
emostov Jun 9, 2022
a943be1
Only use RsaPair::generate
emostov Jun 9, 2022
82db50e
Test encrypt
emostov Jun 9, 2022
cefe64e
State gated routes
emostov Jun 10, 2022
f56264a
Write pivot after checking manifest
emostov Jun 10, 2022
c6a7469
Initial pass at creating genesis outputs
emostov Jun 10, 2022
c0a7ebe
Factor out Genesis Output generation
emostov Jun 10, 2022
a3c1df5
fmt
emostov Jun 10, 2022
f602f98
Addres some clippy warnings
emostov Jun 10, 2022
774ffef
Updates and borsh migration
jack-kearney Jun 10, 2022
190a7d0
More borsh
jack-kearney Jun 10, 2022
876b5a7
Implement genesis test
jack-kearney Jun 10, 2022
0297ca5
First genesis CLI commands
jack-kearney Jun 11, 2022
225d499
Run fmt
emostov Jun 11, 2022
4bc2441
Remove unused cbor deps; Outline genesis test
emostov Jun 11, 2022
985b316
Add boot_genesis command
emostov Jun 11, 2022
9fbdbad
WIP :/
emostov Jun 11, 2022
b5bc21c
Make progress on integration test
emostov Jun 13, 2022
3aef55a
Add test for failing BootGenesisResponse deserialization
emostov Jun 13, 2022
e7e5444
Use local types instead of NSM types so we can derive borsh
emostov Jun 13, 2022
783be91
Delete unused code
emostov Jun 13, 2022
d3c78a8
Remove cbor deps
emostov Jun 13, 2022
aed8a56
Almost done with genesis e2e
emostov Jun 14, 2022
a50388c
Remove GenerateGenesisConfig from cli
emostov Jun 14, 2022
92c53c5
Genesis e2e CLI works
emostov Jun 14, 2022
5928e8b
Remove RsaPair::encrypt; only expose envelope_encrypt
emostov Jun 14, 2022
3f3afd3
Document some rsa functions
emostov Jun 14, 2022
09cb3fa
Update qos-core/src/client.rs
emostov Jun 14, 2022
f56a29a
Update qos-core/src/protocol/boot.rs
emostov Jun 14, 2022
f3cc26e
Update qos-core/src/protocol/boot.rs
emostov Jun 14, 2022
404f6ae
Apply suggestions from code review
emostov Jun 14, 2022
c0e5157
Update qos-core/src/protocol/boot.rs
emostov Jun 14, 2022
6d885ec
Apply suggestions from code review
emostov Jun 14, 2022
b5010b1
General clean up
emostov Jun 14, 2022
3d53a28
Merge branch 'bootstrap-and-genesis' of https://github.com/tkhq/qos i…
emostov Jun 14, 2022
4318682
Some more general clean up
emostov Jun 15, 2022
ee1c828
Slightly refactor create_genesis_set
emostov Jun 15, 2022
da7071e
Some more small clean up
emostov Jun 15, 2022
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
Prev Previous commit
Next Next commit
Slightly refactor create_genesis_set
emostov committed Jun 15, 2022

Verified

This commit was signed with the committer’s verified signature.
emostov Zeke Mostov
commit ee1c828048365041f8084d5c97c6009cb971101c
14 changes: 5 additions & 9 deletions qos-client/src/cli.rs
Original file line number Diff line number Diff line change
@@ -469,15 +469,11 @@ mod handlers {
// Assemble the genesis members from all the public keys in the key
// directory
let members: Vec<_> = key_files
.map(|maybe_key_path| maybe_key_path.unwrap().path())
.filter_map(|key_path| {
let path = key_path.unwrap().path();
let split: Vec<_> = path
.file_name()
.unwrap()
.to_str()
.unwrap()
.split(".")
.collect();
let file_name =
key_path.file_name().map(|f| f.to_string_lossy()).unwrap();
let split: Vec<_> = file_name.split(".").collect();

// TODO: do we want to dissallow having anything in this folder
// that is not a public key for the quorum set?
@@ -486,7 +482,7 @@ mod handlers {
return None
}

let public_key = RsaPub::from_pem_file(path)
let public_key = RsaPub::from_pem_file(key_path.clone())
.expect("Failed to read in rsa pub key.");

Some(SetupMember {
2 changes: 1 addition & 1 deletion qos-core/src/protocol/boot.rs
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ impl ManifestEnvelope {

let is_valid_signature = pub_key
.verify_sha256(&approval.signature, &self.manifest.hash())
.map_err(|e| ProtocolError::CryptoError)?;
.map_err(|_| ProtocolError::CryptoError)?;
if !is_valid_signature {
return Err(ProtocolError::InvalidManifestApproval(
approval.clone(),
1 change: 1 addition & 0 deletions qos-core/src/protocol/mod.rs
Original file line number Diff line number Diff line change
@@ -199,6 +199,7 @@ mod handlers {
};
}

// TODO: Add tests for this in the middle of some integration tests
pub fn status(
req: &ProtocolMsg,
state: &mut ProtocolState,
18 changes: 15 additions & 3 deletions qos-crypto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ impl From<openssl::error::ErrorStack> for CryptoError {
}

/// RSA Private key pair.
#[derive(Clone)]
pub struct RsaPair {
private_key: Rsa<Private>,
public_key: RsaPub,
@@ -158,7 +159,7 @@ impl Deref for RsaPair {
}
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct RsaPub {
public_key: Rsa<Public>,
}
@@ -375,10 +376,21 @@ mod test {
}

#[test]
fn e2e_envelope_crypto() {
fn e2e_envelope_crypto_private_key() {
let data = b"a nation that vapes big puffy clouds";
let private = RsaPair::generate().unwrap();
let envelope = private.envelope_encrypt(data).unwrap();
let decrypted = private.envelope_decrypt(&envelope).unwrap();

assert_eq!(data.to_vec(), decrypted);
}

#[test]
fn e2e_envelope_crypto_public_key() {
let data = b"a nation that vapes big puffy clouds";
let private = RsaPair::generate().unwrap();
let envelope = private.public_key.envelope_encrypt(data).unwrap();
let public: RsaPub = private.clone().try_into().unwrap();
let envelope = public.envelope_encrypt(data).unwrap();
let decrypted = private.envelope_decrypt(&envelope).unwrap();

assert_eq!(data.to_vec(), decrypted);