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

DCAP cert validation tests #6

Merged
merged 11 commits into from
Jun 20, 2024
Prev Previous commit
Fix Cargo.toml deps after rebase
hu55a1n1 committed Jun 20, 2024
commit 7ddb328e565069b1e9bd06aaaa93a811fd1d4630
10 changes: 0 additions & 10 deletions cosmwasm/packages/quartz-tee-ra/Cargo.toml
Original file line number Diff line number Diff line change
@@ -32,15 +32,5 @@ mc-sgx-dcap-sys-types.workspace = true
cosmwasm-schema.workspace = true
cosmwasm-std.workspace = true

der = { version = "0.7.9", default-features = false }
displaydoc = { version = "0.2.4", default-features = false }
mc-sgx-core-types = { git = "https://github.com/informalsystems/sgx" }
mc-sgx-dcap-types = { git = "https://github.com/informalsystems/sgx" }
mc-sgx-dcap-sys-types = { git = "https://github.com/informalsystems/sgx" }
mc-attestation-verifier = { git = "https://github.com/informalsystems/attestation" }
serde = { version = "1.0.198", default-features = false }
x509-cert = { version = "0.2.5", default-features = false }
zeroize = { version = "1.7.0", default-features = false }

[dev-dependencies]
hex = "0.4.3"

Unchanged files with check annotations Beta

SigningKey::from_bytes(GenericArray::from_slice(&sk))?
};
let ciphertext = hex::decode(obligation).unwrap();

Check warning on line 252 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:252:30 | 252 | let ciphertext = hex::decode(obligation).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used note: the lint level is defined here --> utils/mtcs-intent/src/main.rs:6:5 | 6 | clippy::unwrap_used, | ^^^^^^^^^^^^^^^^^^^

Check warning on line 252 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:252:30 | 252 | let ciphertext = hex::decode(obligation).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used note: the lint level is defined here --> utils/mtcs-intent/src/main.rs:6:5 | 6 | clippy::unwrap_used, | ^^^^^^^^^^^^^^^^^^^
let obligation = {
let o = decrypt(&sk.to_bytes(), &ciphertext).unwrap();

Check warning on line 255 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:255:25 | 255 | let o = decrypt(&sk.to_bytes(), &ciphertext).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used

Check warning on line 255 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:255:25 | 255 | let o = decrypt(&sk.to_bytes(), &ciphertext).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
serde_json::from_slice::<RawObligation>(&o)?
};
println!("{obligation:?}");
let digest: [u8; 32] = {
let d = hex::decode(obligation_digest)?;
d.try_into().unwrap()

Check warning on line 276 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:276:17 | 276 | d.try_into().unwrap() | ^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used

Check warning on line 276 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:276:17 | 276 | d.try_into().unwrap() | ^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
};
let setoff_enc = EncryptedIntent {
SigningKey::from_bytes(GenericArray::from_slice(&sk))?
};
let ciphertext = hex::decode(setoff).unwrap();

Check warning on line 296 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:296:30 | 296 | let ciphertext = hex::decode(setoff).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used

Check warning on line 296 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:296:30 | 296 | let ciphertext = hex::decode(setoff).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
let setoff = decrypt(&sk.to_bytes(), &ciphertext).unwrap();

Check warning on line 298 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:298:26 | 298 | let setoff = decrypt(&sk.to_bytes(), &ciphertext).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used

Check warning on line 298 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:298:26 | 298 | let setoff = decrypt(&sk.to_bytes(), &ciphertext).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
serde_json::from_slice(&setoff)?;
}
Command::PrintAddress { pk } => {
VerifyingKey::from_sec1_bytes(&pk)?
};
let tm_pk = TmAccountId::from(pk);
println!("{}", AccountId::new("wasm", tm_pk.as_bytes()).unwrap());

Check warning on line 307 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:307:28 | 307 | println!("{}", AccountId::new("wasm", tm_pk.as_bytes()).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used

Check warning on line 307 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:307:28 | 307 | println!("{}", AccountId::new("wasm", tm_pk.as_bytes()).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
}
Command::PrintAddressFromPriv { sk_str } => {
let sk = XPrv::from_str(&sk_str).unwrap();

Check warning on line 310 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:310:22 | 310 | let sk = XPrv::from_str(&sk_str).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used

Check warning on line 310 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:310:22 | 310 | let sk = XPrv::from_str(&sk_str).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
let pk_b = sk.public_key().public_key().to_sec1_bytes();
let pk = VerifyingKey::from_sec1_bytes(&pk_b)?;
println!("{}", pk_bytes);
let tm_pk = TmAccountId::from(pk);
println!("{}", AccountId::new("wasm", tm_pk.as_bytes()).unwrap());

Check warning on line 320 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:320:28 | 320 | println!("{}", AccountId::new("wasm", tm_pk.as_bytes()).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used

Check warning on line 320 in utils/mtcs-intent/src/main.rs

GitHub Actions / clippy

used `unwrap()` on a `Result` value

warning: used `unwrap()` on a `Result` value --> utils/mtcs-intent/src/main.rs:320:28 | 320 | println!("{}", AccountId::new("wasm", tm_pk.as_bytes()).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if this value is an `Err`, it will panic = help: consider using `expect()` to provide a better panic message = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
}
}
.flat_map(|(obligation_digest, so)| match so {
RawSetOff::SetOff(sos_enc) => {
let so_enc = sos_enc.first().unwrap();
let (debtor_id, creditor_id) = obligation_user_map
.get(obligation_digest)
.map(Clone::clone)

Check warning on line 117 in utils/cycles-sync/src/main.rs

GitHub Actions / clippy

you are explicitly cloning with `.map()`

warning: you are explicitly cloning with `.map()` --> utils/cycles-sync/src/main.rs:115:48 | 115 | let (debtor_id, creditor_id) = obligation_user_map | ________________________________________________^ 116 | | .get(obligation_digest) 117 | | .map(Clone::clone) | |______________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone = note: `#[warn(clippy::map_clone)]` on by default help: consider calling the dedicated `copied` method | 115 ~ let (debtor_id, creditor_id) = obligation_user_map 116 + .get(obligation_digest).copied() |

Check warning on line 117 in utils/cycles-sync/src/main.rs

GitHub Actions / clippy

you are explicitly cloning with `.map()`

warning: you are explicitly cloning with `.map()` --> utils/cycles-sync/src/main.rs:115:48 | 115 | let (debtor_id, creditor_id) = obligation_user_map | ________________________________________________^ 116 | | .get(obligation_digest) 117 | | .map(Clone::clone) | |______________________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone = note: `#[warn(clippy::map_clone)]` on by default help: consider calling the dedicated `copied` method | 115 ~ let (debtor_id, creditor_id) = obligation_user_map 116 + .get(obligation_digest).copied() |
.unwrap();
let sk = |id| keys[&id].private_key().to_bytes();
#[test]
fn test_create_mnemonic() {
// Generate random Mnemonic using the default language (English)
let mnemonic = Mnemonic::random(&mut OsRng, Default::default());

Check warning on line 380 in utils/cycles-sync/src/main.rs

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> utils/cycles-sync/src/main.rs:380:41 | 380 | let mnemonic = Mnemonic::random(&mut OsRng, Default::default()); | ^^^^^^^^^^ help: change this to: `OsRng` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default
println!("{}", mnemonic.phrase());
}