Skip to content

Commit

Permalink
In production, generate TDX quote using configfs-tsm
Browse files Browse the repository at this point in the history
  • Loading branch information
ameba23 committed Sep 7, 2024
1 parent 837aa55 commit 559d015
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/threshold-signature-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ sha2 ="0.10.8"
hkdf ="0.12.4"
project-root ={ version="0.2.2", optional=true }
tdx-quote ={ git="https://github.com/entropyxyz/tdx-quote", optional=true, features=["mock"] }
configfs-tsm ={ git="https://github.com/entropyxyz/configfs-tsm" }

[dev-dependencies]
serial_test ="3.1.1"
Expand Down
24 changes: 17 additions & 7 deletions crates/threshold-signature-server/src/attestation/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,24 @@ pub async fn create_quote(
Ok(quote)
}

/// Once implemented, this will create a TDX quote in production
/// Create a TDX quote in production
#[cfg(not(any(test, feature = "unsafe")))]
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)?)
// // Non-mock attestation (the real thing) will go here
// Err(AttestationErr::NotImplemented)
}
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(not(any(test, feature = "unsafe")))]
#[error("Quote generation: {0}")]
QuoteGeneration(#[from] std::io::Error),
}

impl IntoResponse for AttestationErr {
Expand Down

0 comments on commit 559d015

Please sign in to comment.