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

feat: minor tweaks on verify function #21549

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: minor tweaks on verify function #21549

wants to merge 2 commits into from

Conversation

joyqvq
Copy link
Contributor

@joyqvq joyqvq commented Mar 20, 2025

Description

Describe the changes or additions included in this PR.

Test plan

How did you test the new or updated feature?


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

@joyqvq joyqvq requested review from bmwill, mystenmark and benr-ml March 20, 2025 04:31
Copy link

vercel bot commented Mar 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 20, 2025 4:31am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Mar 20, 2025 4:31am
sui-kiosk ⬜️ Ignored (Inspect) Mar 20, 2025 4:31am

@@ -366,7 +375,7 @@ impl CoseSign1 {
Value::Bytes(vec![]),
Value::Bytes(self.payload.as_slice().to_vec()),
]);
let mut bytes = Vec::with_capacity(self.protected.len() + self.payload.len());
let mut bytes = Vec::with_capacity(self.protected.len() + self.payload.len() + 17);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls document why 17

"timestamp not found".to_string(),
))?
.as_integer()
.and_then(|integer| u64::try_from(integer).ok())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it safe?

)
})?;

for i in [0, 1, 2, 3, 4, 8] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return error if we see, e.g., pcr 5?

}
let mut certs = Vec::with_capacity(arr.len());
for cert in arr.iter() {
let cert_bytes = cert.as_bytes().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use except with a description

.ok_or(NitroAttestationVerifyError::InvalidAttestationDoc(
"cabundle not found".to_string(),
))?
.as_array()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can there be more than one cert chain?


let document_map = match document_data {
ciborium::value::Value::Map(map) => map,
let document_map: HashMap<String, Value> = match document_data {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reasonable length limit on payload we can use?

document_map: &HashMap<String, Value>,
) -> Result<AttestationDocument, NitroAttestationVerifyError> {
let module_id = document_map
.get("module_id")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just making sure it's the case - .get() is implemented as a map in O(1) query time, and not using a linear search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants