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

In production, generate TDX quote using configfs-tsm #1041

Merged
merged 8 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crates/threshold-signature-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ project-root={ version="0.2.2", optional=true }
tdx-quote={ git="https://github.com/entropyxyz/tdx-quote", rev="f7968ff", optional=true, features=[
"mock",
] }
configfs-tsm={ git="https://github.com/entropyxyz/configfs-tsm", rev="f32c166", optional=true }

[dev-dependencies]
serial_test ="3.1.1"
Expand Down Expand Up @@ -104,10 +105,11 @@ entropy-testing-utils={ path="../testing-utils" }
vergen={ version="8.3.2", features=["build", "git", "gitcl"] }

[features]
default =['std']
default =["std", "dep:tdx-quote"]
std =["sp-core/std"]
test_helpers=["dep:project-root"]
unsafe =["dep:tdx-quote"]
unsafe =[]
production =["std", "dep:configfs-tsm"]
alice =[]
bob =[]
# Enable this feature to run the integration tests for the wasm API of entropy-protocol
Expand Down
26 changes: 17 additions & 9 deletions crates/threshold-signature-server/src/attestation/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub async fn attest(
}

/// Create a mock quote for testing on non-TDX hardware
#[cfg(any(test, feature = "unsafe"))]
#[cfg(not(feature = "production"))]
pub async fn create_quote(
block_number: u32,
nonce: [u8; 32],
Expand All @@ -97,14 +97,22 @@ pub async fn create_quote(
Ok(quote)
}

/// Once implemented, this will create a TDX quote in production
#[cfg(not(any(test, feature = "unsafe")))]
/// Create a TDX quote in production
#[cfg(feature = "production")]
pub async fn create_quote(
_block_number: u32,
_nonce: [u8; 32],
_signer: &PairSigner<EntropyConfig, sp_core::sr25519::Pair>,
_x25519_secret: &StaticSecret,
block_number: u32,
nonce: [u8; 32],
signer: &PairSigner<EntropyConfig, sp_core::sr25519::Pair>,
x25519_secret: &StaticSecret,
) -> Result<Vec<u8>, AttestationErr> {
// Non-mock attestation (the real thing) will go here
Err(AttestationErr::NotImplemented)
let public_key = x25519_dalek::PublicKey::from(x25519_secret);

let input_data = entropy_shared::QuoteInputData::new(
signer.signer().public(),
*public_key.as_bytes(),
nonce,
block_number,
);

Ok(configfs_tsm::create_quote(input_data.0)?)
}
6 changes: 3 additions & 3 deletions crates/threshold-signature-server/src/attestation/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ pub enum AttestationErr {
GenericSubstrate(#[from] subxt::error::Error),
#[error("User Error: {0}")]
UserErr(#[from] crate::user::UserErr),
#[cfg(not(any(test, feature = "unsafe")))]
#[error("Not yet implemented")]
NotImplemented,
#[error("Input must be 32 bytes: {0}")]
TryFromSlice(#[from] TryFromSliceError),
#[error("Could not get block number")]
Expand All @@ -40,6 +37,9 @@ pub enum AttestationErr {
Unexpected,
#[error("Could not decode message: {0}")]
Codec(#[from] parity_scale_codec::Error),
#[cfg(feature = "production")]
#[error("Quote generation: {0}")]
QuoteGeneration(#[from] std::io::Error),
}

impl IntoResponse for AttestationErr {
Expand Down
1 change: 1 addition & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ exceptions=[
{ allow=["AGPL-3.0"], name="entropy-programs-runtime" },
{ allow=["AGPL-3.0"], name="synedrion" },
{ allow=["AGPL-3.0"], name="tdx-quote" },
{ allow=["AGPL-3.0"], name="configfs-tsm" },

# These are the only crates using these licenses, put them here instead of globally allowing
# them
Expand Down
Loading