Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad committed Nov 13, 2024
1 parent 336291b commit b672182
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
15 changes: 6 additions & 9 deletions cosmwasm/enclaves/execute/src/registration/offchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ pub fn save_attestation_combined(
}

let out_path = make_sgx_secret_path(if is_migration_report {
&FILE_MIGRATION_CERT
FILE_MIGRATION_CERT
} else {
&FILE_CERT_COMBINED
FILE_CERT_COMBINED
});

let mut f_out = match File::create(out_path.as_str()) {
Expand Down Expand Up @@ -500,7 +500,7 @@ pub unsafe extern "C" fn ecall_get_attestation_report(
let kp = KEY_MANAGER.get_registration_key().unwrap();
trace!(
"ecall_get_attestation_report key pk: {:?}",
hex::encode(&kp.get_pubkey().to_vec())
hex::encode(kp.get_pubkey())
);

let mut f_out = match File::create(PUBKEY_PATH.as_str()) {
Expand Down Expand Up @@ -560,10 +560,7 @@ pub unsafe extern "C" fn ecall_key_gen(

let pubkey = reg_key.unwrap().get_pubkey();
public_key.clone_from_slice(&pubkey);
trace!(
"ecall_key_gen key pk: {:?}",
hex::encode(public_key.to_vec())
);
trace!("ecall_key_gen key pk: {:?}", hex::encode(&public_key));
sgx_status_t::SGX_SUCCESS
}

Expand Down Expand Up @@ -897,7 +894,7 @@ fn export_sealing_kdk() -> sgx_status_t {
.encrypt_siv(&SEALING_KDK as &sgx_types::sgx_key_128bit_t, None)
.unwrap();

let mut f_out = match File::create(&make_sgx_secret_path(FILE_MIGRATION_KDK)) {
let mut f_out = match File::create(make_sgx_secret_path(FILE_MIGRATION_KDK)) {
Ok(f) => f,
Err(e) => {
error!("failed to create file {}", e);
Expand All @@ -913,7 +910,7 @@ fn export_sealing_kdk() -> sgx_status_t {
}

fn import_sealing_kdk() -> sgx_status_t {
let mut f_in = match File::open(&make_sgx_secret_path(FILE_MIGRATION_KDK)) {
let mut f_in = match File::open(make_sgx_secret_path(FILE_MIGRATION_KDK)) {
Ok(f) => f,
Err(e) => {
error!("failed to open file {}", e);
Expand Down
14 changes: 7 additions & 7 deletions cosmwasm/enclaves/shared/utils/src/key_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ lazy_static! {
impl Keychain {
fn serialize(&self, writer: &mut dyn Write) -> std::io::Result<()> {
if let Some(seeds) = self.consensus_seed {
writer.write_all(&[1 as u8])?;
writer.write_all(&[1_u8])?;
writer.write_all(seeds.genesis.as_slice())?;
writer.write_all(seeds.current.as_slice())?;
} else {
writer.write_all(&[0 as u8])?;
writer.write_all(&[0_u8])?;
}

if let Some(kp) = self.registration_key {
writer.write_all(&[1 as u8])?;
writer.write_all(&[1_u8])?;
writer.write_all(kp.get_privkey())?;
} else {
writer.write_all(&[0 as u8])?;
writer.write_all(&[0_u8])?;
}

writer.write_all(&self.validator_set_for_height.height.to_le_bytes())?;
Expand All @@ -86,10 +86,10 @@ impl Keychain {
writer.write_all(&self.validator_set_for_height.validator_set)?;

if let Some(val) = self.next_mr_enclave {
writer.write_all(&[1 as u8])?;
writer.write_all(&[1_u8])?;
writer.write_all(&val.m)?;
} else {
writer.write_all(&[0 as u8])?;
writer.write_all(&[0_u8])?;
}

Ok(())
Expand Down Expand Up @@ -147,7 +147,7 @@ impl Keychain {

fn load_ex(&mut self, key: &sgx_key_128bit_t) -> bool {
let path: &str = &SEALED_DATA_PATH;
match SgxFile::open_ex(path, &key) {
match SgxFile::open_ex(path, key) {
Ok(mut file) => {
println!("Sealed data opened");
self.deserialize(&mut file).unwrap();
Expand Down
14 changes: 7 additions & 7 deletions cosmwasm/enclaves/shared/utils/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,25 +469,25 @@ fn migrate_file_from_2_17_safe(
}

pub fn migrate_all_from_2_17() -> sgx_types::sgx_status_t {
if let Err(e) = migrate_file_from_2_17_safe(&SEALED_FILE_REGISTRATION_KEY, true) {
if let Err(e) = migrate_file_from_2_17_safe(SEALED_FILE_REGISTRATION_KEY, true) {
return e;
}
if let Err(e) = migrate_file_from_2_17_safe(&SEALED_FILE_ENCRYPTED_SEED_KEY_GENESIS, true) {
if let Err(e) = migrate_file_from_2_17_safe(SEALED_FILE_ENCRYPTED_SEED_KEY_GENESIS, true) {
return e;
}
if let Err(e) = migrate_file_from_2_17_safe(&SEALED_FILE_ENCRYPTED_SEED_KEY_CURRENT, true) {
if let Err(e) = migrate_file_from_2_17_safe(SEALED_FILE_ENCRYPTED_SEED_KEY_CURRENT, true) {
return e;
}
if let Err(e) = migrate_file_from_2_17_safe(&SEALED_FILE_REK, true) {
if let Err(e) = migrate_file_from_2_17_safe(SEALED_FILE_REK, true) {
return e;
}
if let Err(e) = migrate_file_from_2_17_safe(&SEALED_FILE_IRS, true) {
if let Err(e) = migrate_file_from_2_17_safe(SEALED_FILE_IRS, true) {
return e;
}
if let Err(e) = migrate_file_from_2_17_safe(&SEALED_FILE_VALIDATOR_SET, true) {
if let Err(e) = migrate_file_from_2_17_safe(SEALED_FILE_VALIDATOR_SET, true) {
return e;
}
if let Err(e) = migrate_file_from_2_17_safe(&SEALED_FILE_TX_BYTES, true) {
if let Err(e) = migrate_file_from_2_17_safe(SEALED_FILE_TX_BYTES, true) {
return e;
}
sgx_status_t::SGX_SUCCESS
Expand Down

0 comments on commit b672182

Please sign in to comment.