Skip to content

Commit b67c929

Browse files
committed
feat(kms): enhance onboard page with site name, chain info, and k256 pubkey
Add configurable site_name, eth_rpc_url, and kms_contract_address to the onboard config, displayed on the onboard page for operator visibility. Return k256_pubkey in OnboardResponse so it can be compared with the on-chain kmsInfo.k256Pubkey after onboarding.
1 parent 05d77bd commit b67c929

5 files changed

Lines changed: 39 additions & 3 deletions

File tree

kms/kms.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@ gateway_app_id = "any"
4646
enabled = true
4747
auto_bootstrap_domain = ""
4848
quote_enabled = true
49+
site_name = ""
50+
eth_rpc_url = ""
51+
kms_contract_address = ""
4952
address = "0.0.0.0"
5053
port = 8000

kms/rpc/proto/kms_rpc.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ message OnboardRequest {
131131
}
132132

133133
message OnboardResponse {
134+
// k256 public key (secp256k1) inherited from source KMS
135+
bytes k256_pubkey = 1;
134136
}
135137

136138
// Attestation info needed for on-chain KMS authorization.
@@ -143,6 +145,12 @@ message AttestationInfoResponse {
143145
bytes os_image_hash = 3;
144146
// Attestation mode (e.g. "dstack-tdx", "dstack-gcp-tdx")
145147
string attestation_mode = 4;
148+
// Custom site name for display
149+
string site_name = 5;
150+
// Ethereum RPC URL from auth API
151+
string eth_rpc_url = 6;
152+
// KMS contract address from auth API
153+
string kms_contract_address = 7;
146154
}
147155

148156
// The Onboard RPC service.

kms/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,10 @@ pub(crate) struct OnboardConfig {
120120
pub enabled: bool,
121121
pub quote_enabled: bool,
122122
pub auto_bootstrap_domain: String,
123+
#[serde(default)]
124+
pub site_name: String,
125+
#[serde(default)]
126+
pub eth_rpc_url: String,
127+
#[serde(default)]
128+
pub kms_contract_address: String,
123129
}

kms/src/onboard_service.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ impl OnboardRpc for OnboardHandler {
9292
)
9393
.await
9494
.context("Failed to onboard")?;
95+
let k256_pubkey = keys.k256_key.verifying_key().to_sec1_bytes().to_vec();
9596
keys.store(&self.state.config)
9697
.context("Failed to store keys")?;
97-
Ok(OnboardResponse {})
98+
Ok(OnboardResponse { k256_pubkey })
9899
}
99100

100101
async fn get_attestation_info(self) -> Result<AttestationInfoResponse> {
@@ -135,6 +136,9 @@ impl OnboardRpc for OnboardHandler {
135136
mr_aggregated: app_info.mr_aggregated.to_vec(),
136137
os_image_hash: app_info.os_image_hash,
137138
attestation_mode,
139+
site_name: self.state.config.onboard.site_name.clone(),
140+
eth_rpc_url: self.state.config.onboard.eth_rpc_url.clone(),
141+
kms_contract_address: self.state.config.onboard.kms_contract_address.clone(),
138142
})
139143
}
140144

kms/src/www/onboard.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154

155155
<body>
156156
<div id="app" class="container">
157-
<h1>dstack KMS Setup</h1>
157+
<h1>{{ siteName || 'dstack KMS Setup' }}</h1>
158158

159159
<div v-if="attestationLoading" class="loading">Loading attestation info...</div>
160160
<div v-else-if="attestationError" class="error">Attestation info: {{ attestationError }}</div>
@@ -176,6 +176,14 @@ <h3>Attestation Info (for on-chain registration)</h3>
176176
<span class="info-label">OS Image Hash:</span>
177177
<span class="info-value">0x{{ attestationInfo.os_image_hash }}</span>
178178
</div>
179+
<div v-if="attestationInfo.eth_rpc_url" class="info-row">
180+
<span class="info-label">ETH RPC URL:</span>
181+
<span class="info-value">{{ attestationInfo.eth_rpc_url }}</span>
182+
</div>
183+
<div v-if="attestationInfo.kms_contract_address" class="info-row">
184+
<span class="info-label">KMS Contract:</span>
185+
<span class="info-value">{{ attestationInfo.kms_contract_address }}</span>
186+
</div>
179187
</div>
180188

181189
<div v-if="!setupFinished">
@@ -261,7 +269,8 @@ <h2>Onboard from an Existing KMS Instance</h2>
261269
setupFinished: false,
262270
attestationInfo: null,
263271
attestationLoading: true,
264-
attestationError: ''
272+
attestationError: '',
273+
siteName: ''
265274
}
266275
},
267276
async mounted() {
@@ -271,6 +280,9 @@ <h2>Onboard from an Existing KMS Instance</h2>
271280
this.attestationError = data.error;
272281
} else {
273282
this.attestationInfo = data;
283+
if (data.site_name) {
284+
this.siteName = data.site_name;
285+
}
274286
}
275287
} catch (err) {
276288
this.attestationError = err.message;
@@ -310,6 +322,9 @@ <h2>Onboard from an Existing KMS Instance</h2>
310322
if (data.error) throw new Error(data.error);
311323

312324
this.success = 'Onboarding successful!';
325+
this.result = JSON.stringify({
326+
k256Pubkey: '0x' + data.k256_pubkey,
327+
}, null, 2);
313328
this.error = '';
314329
} catch (err) {
315330
this.error = err.message;

0 commit comments

Comments
 (0)