Skip to content

Commit fc02f48

Browse files
authored
Merge pull request #360 from scrtlabs/vms
Add Verifiable Message Signing
2 parents cc51d0a + 42f17b0 commit fc02f48

20 files changed

Lines changed: 1589 additions & 36 deletions

File tree

Cargo.lock

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ blake2 = "0.10.6"
171171
tokio-rustls = { version = "0.26.2", features = ["ring"] }
172172
x25519-dalek = { version = "2.0.1", features = ["static_secrets"] }
173173
k256 = "0.13.4"
174+
ed25519-dalek = { version = "2.2.0", features = ["rand_core"] }
174175
# Additional RustCrypto dependencies for sealed box
175176
xsalsa20poly1305 = "0.9.0"
176177
salsa20 = "0.10"

guest-agent/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ sha3.workspace = true
4747
strip-ansi-escapes.workspace = true
4848
cert-client.workspace = true
4949
ring.workspace = true
50+
ed25519-dalek.workspace = true
51+
tempfile.workspace = true
52+
rand.workspace = true

guest-agent/rpc/proto/agent_rpc.proto

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ service DstackGuest {
3737
// Returns the derived key along with its TLS certificate chain.
3838
rpc GetTlsKey(GetTlsKeyArgs) returns (GetTlsKeyResponse) {}
3939

40-
// Derives a new ECDSA key with k256 EC curve.
40+
// Derives a new key.
4141
rpc GetKey(GetKeyArgs) returns (GetKeyResponse) {}
4242

4343
// Generates a TDX quote with given report data.
@@ -48,6 +48,12 @@ service DstackGuest {
4848

4949
// Get app info
5050
rpc Info(google.protobuf.Empty) returns (AppInfo) {}
51+
52+
// Sign a payload
53+
rpc Sign(SignRequest) returns (SignResponse) {}
54+
55+
// Verify a signature
56+
rpc Verify(VerifyRequest) returns (VerifyResponse) {}
5157
}
5258

5359
// The request to derive a key
@@ -91,12 +97,14 @@ message GetTlsKeyResponse {
9197
repeated string certificate_chain = 2;
9298
}
9399

94-
// The request to derive a new ECDSA key with k256 EC curve
100+
// The request to derive a new key
95101
message GetKeyArgs {
96102
// Path to the key to derive
97103
string path = 1;
98104
// Purpose of the key
99105
string purpose = 2;
106+
// Algorithm of the key. Either `secp256k1` or `ed25519`. Defaults to `secp256k1`
107+
string algorithm = 3;
100108
}
101109

102110
// The response to a DeriveK256Key request
@@ -109,9 +117,11 @@ message DeriveK256KeyResponse {
109117

110118
// The response to a GetEthKey request
111119
message GetKeyResponse {
112-
// Derived k256 key
120+
// Derived key
113121
bytes key = 1;
114-
// Derived k256 signature chain
122+
// The signature chain consists of the following signatures:
123+
// [0] - the k256 signature of the derived pK signed by the app root key
124+
// [1] - the k256 signature of the app root pK signed by the KMS root key
115125
repeated bytes signature_chain = 2;
116126
}
117127

@@ -216,4 +226,38 @@ service Worker {
216226
rpc Info(google.protobuf.Empty) returns (AppInfo) {}
217227
// Get the guest agent version
218228
rpc Version(google.protobuf.Empty) returns (WorkerVersion) {}
229+
// Get attestation
230+
rpc GetAttestationForAppKey(GetAttestationForAppKeyRequest) returns (GetQuoteResponse) {}
231+
}
232+
233+
message SignRequest {
234+
string algorithm = 1;
235+
bytes data = 2;
236+
}
237+
238+
message SignResponse {
239+
// the signature of the data
240+
bytes signature = 1;
241+
// The signature chain consists of the following signatures:
242+
// [0] - the signature of the data
243+
// [1] - the k256 signature of the message signing pubkey signed by the app root key
244+
// [2] - the k256 signature of the app root pubkey signed by the KMS root key
245+
repeated bytes signature_chain = 2;
246+
// The public key signing the data
247+
bytes public_key = 3;
248+
}
249+
250+
message VerifyRequest {
251+
string algorithm = 1;
252+
bytes data = 2;
253+
bytes signature = 3;
254+
bytes public_key = 4;
255+
}
256+
257+
message VerifyResponse {
258+
bool valid = 1;
259+
}
260+
261+
message GetAttestationForAppKeyRequest {
262+
string algorithm = 1;
219263
}

0 commit comments

Comments
 (0)