Skip to content

Conversation

@netrome
Copy link
Collaborator

@netrome netrome commented Dec 13, 2025

Closes #1634

This is an alternative solution to the one proposed in #1646. Instead of relying on a custom build script to generate a rust module containing a hard-coded constant for the expected measurements, this PR introduces a procedural macro to generate the needed literals to statically instantiate the expected measurements. This allows us to load expected measurements at compile time simply by doing:

let expected_measurements = include_measurements!("path/to/tcb_info.json")

Side note: I noticed we didn't have a nice TcbInfo struct to deserialize the JSON so a significant part of this PR is introducing that struct.

@netrome netrome self-assigned this Dec 13, 2025
@netrome netrome force-pushed the netrome/parse_tcb_info_at_compile_time branch from 585cba7 to a5ca4e6 Compare December 13, 2025 23:53
@netrome netrome force-pushed the netrome/parse_tcb_info_at_compile_time branch 2 times, most recently from 5c395a1 to 191eb6d Compare December 14, 2025 00:05
derive_more::Deref,
)]
#[serde(transparent)]
pub struct HexBytes<const N: usize>(#[serde_as(as = "Hex")] [u8; N]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: I was surprised we didn't have this somewhere already. I think we could make use of this type in many more places if we break it out as a shared utility later.

@netrome netrome force-pushed the netrome/parse_tcb_info_at_compile_time branch 2 times, most recently from 5e3c4e6 to 0e8604f Compare December 14, 2025 00:14
@netrome netrome force-pushed the netrome/parse_tcb_info_at_compile_time branch from 0e8604f to e2518aa Compare December 14, 2025 00:17
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.

Avoid parsing tcb_info.json inside contract to reduce TEE verification gas costs

2 participants