Skip to content

Commit c4eac86

Browse files
committed
fix(guest-agent): normalize algorithm before passing to GetKey in Sign
Sign internally calls GetKey to derive the signing key. After removing secp256k1_prehashed from GetKey's accepted algorithms, Sign must map secp256k1_prehashed to secp256k1 when requesting the key.
1 parent 762a3a1 commit c4eac86

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

guest-agent/src/rpc_service.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,19 @@ impl DstackGuestRpc for InternalRpcHandler {
340340
}
341341

342342
async fn sign(self, request: SignRequest) -> Result<SignResponse> {
343+
let algorithm = normalize_algorithm(&request.algorithm);
344+
// Use the base algorithm for key derivation (e.g. secp256k1_prehashed -> secp256k1)
345+
let key_algorithm = match algorithm {
346+
"secp256k1_prehashed" => "secp256k1",
347+
other => other,
348+
};
343349
let key_response = self
344350
.get_key(GetKeyArgs {
345351
path: "vms".to_string(),
346352
purpose: "signing".to_string(),
347-
algorithm: request.algorithm.clone(),
353+
algorithm: key_algorithm.to_string(),
348354
})
349355
.await?;
350-
let algorithm = normalize_algorithm(&request.algorithm);
351356
let (signature, public_key) = match algorithm {
352357
"ed25519" => {
353358
let key_bytes: [u8; 32] = key_response

0 commit comments

Comments
 (0)