-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Config): convert between versions and expose it in the gen-cli
- Loading branch information
Showing
9 changed files
with
373 additions
and
97 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use ed25519_dalek::VerifyingKey; | ||
use failure::Error; | ||
|
||
use crate::Config; | ||
|
||
/// Can be used akin to a test fixture | ||
pub(crate) async fn generate_test_hpos_config() -> Result<(Config, VerifyingKey), Error> { | ||
// emulate the UI | ||
|
||
let master = hc_seed_bundle::UnlockedSeedBundle::new_random() | ||
.await | ||
.unwrap(); | ||
|
||
let passphrase = sodoken::BufRead::from(b"test-passphrase".to_vec()); | ||
let revocation_bundle = master.derive(0).await.unwrap(); | ||
let revocation_pub_key = revocation_bundle.get_sign_pub_key().read_lock().to_vec(); | ||
|
||
let device_derivation_path = 2; | ||
let device_bundle = master.derive(device_derivation_path).await.unwrap(); | ||
let device_bundle_encoded_bytes = device_bundle | ||
.lock() | ||
.add_pwhash_cipher(passphrase) | ||
.lock() | ||
.await | ||
.unwrap(); | ||
let device_bundle_base64 = base64::encode(&device_bundle_encoded_bytes); | ||
|
||
// derive the holoport ID | ||
|
||
let holoport_id = device_bundle.derive(1).await.unwrap(); | ||
|
||
let holoport_id = holoport_id.get_sign_pub_key().read_lock().to_vec(); | ||
|
||
// initialize a new Config struct | ||
let email = "[email protected]".to_string(); | ||
let password = "password".to_string(); | ||
let registration_code = "registration-code".to_string(); | ||
let rev_key_bytes = revocation_pub_key[0..32].try_into().unwrap(); | ||
let revocation_pub_key = VerifyingKey::from_bytes(&rev_key_bytes).unwrap(); | ||
let holoport_id_bytes = holoport_id[0..32].try_into().unwrap(); | ||
let holoport_id = VerifyingKey::from_bytes(&holoport_id_bytes).unwrap(); | ||
|
||
Config::new( | ||
// email: String, | ||
email.clone(), | ||
// password: String, | ||
password, | ||
// registration_code: String, | ||
registration_code, | ||
// revocation_pub_key: VerifyingKey, | ||
revocation_pub_key, | ||
// derivation_path: String, | ||
device_derivation_path.to_string(), | ||
// device_bundle: String, | ||
device_bundle_base64.clone(), | ||
// device_pub_key: VerifyingKey, | ||
holoport_id, | ||
) | ||
} |
Oops, something went wrong.