flamingo-verifier-client 0.4.0

Attestation-verifying client for the Flamingo verifier
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
//! HTTP client for the Flamingo Verifier host.

use base64::{Engine as _, engine::general_purpose::STANDARD};

use flamingo_verifier_api_types::{
    ApiErrorResponse, EnclaveAssignmentResponse, MATCH_CONTENT_TYPE, MAX_MATCH_BODY_BYTES,
    MAX_MATCH_RESPONSE_BYTES,
};
use flamingo_verifier_protocol::match_token::{self, EdDSAPublicKey, MatchClaims};
use flamingo_verifier_sealed_types::{MATCH_CHANNEL_DOMAIN, MatchInputs, MatchResult};
use pontifex::attestation::{VerifiedAttestation, Verifier};
use pontifex::{ChannelConsumer, ChannelDomain};

use crate::config::Config;
use crate::error::Error;

/// Error code the host uses for a request that did not open.
const REASSIGN_REQUIRED: &str = "reassign_required";

/// An assignment whose attestation verified and whose encryption key is ready for sealing.
#[derive(Debug, Clone)]
pub struct VerifiedAssignment {
    /// Metadata read from the signed attestation document.
    attestation: VerifiedAttestation,
    consumer: ChannelConsumer,
}

impl VerifiedAssignment {
    /// Metadata from the verified channel-key attestation.
    #[must_use]
    pub const fn attestation(&self) -> &VerifiedAttestation {
        &self.attestation
    }

    /// The channel consumer bound to this assignment's verified key.
    #[must_use]
    pub const fn consumer(&self) -> &ChannelConsumer {
        &self.consumer
    }
}

/// Calls the Flamingo Verifier host and verifies the attestation documents it relays.
///
/// Nothing is returned until the enclave that produced it has been verified, so callers
/// cannot accidentally use an unattested key.
#[derive(Debug)]
pub struct FlamingoVerifierClient {
    config: Config,
    http: reqwest::Client,
    verifier: Verifier,
}

impl FlamingoVerifierClient {
    /// Builds a client from `config`.
    ///
    /// # Errors
    ///
    /// Returns [`Error`] if the configuration is invalid or the HTTP client cannot be built.
    pub fn new(config: Config) -> Result<Self, Error> {
        Self::with_http_client_builder(config, reqwest::Client::builder())
    }

    /// Builds a client using an externally configured HTTP client builder.
    ///
    /// The configured cookie store, connection timeout, and request timeout are applied to the
    /// supplied builder.
    ///
    /// # Errors
    ///
    /// Returns [`Error`] if the configuration is invalid or the HTTP client cannot be built.
    pub fn with_http_client_builder(
        config: Config,
        http: reqwest::ClientBuilder,
    ) -> Result<Self, Error> {
        let http = http
            // Replays the ALB's affinity cookie, so the match reaches the enclave that was assigned.
            .cookie_store(true)
            .connect_timeout(config.connect_timeout())
            .timeout(config.request_timeout())
            .build()
            .map_err(Error::Transport)?;

        Ok(Self {
            verifier: config.verifier()?,
            http,
            config,
        })
    }

    /// Creates the assignment request without sending it.
    ///
    /// Callers may customize the returned builder before passing it to
    /// [`Self::request_assignment_with`].
    pub fn build_assignment_request(&self) -> reqwest::RequestBuilder {
        let url = format!(
            "{}/v1/enclave-assignment",
            self.config.host_url().as_str().trim_end_matches('/')
        );
        self.http.post(url)
    }

    /// Requests an assignment and returns it only if its attestation verifies.
    ///
    /// # Errors
    ///
    /// Returns [`Error`] if the request fails, the host answers with an error status,
    /// or the attestation document does not verify.
    pub async fn request_assignment(&self) -> Result<VerifiedAssignment, Error> {
        self.request_assignment_with(self.build_assignment_request())
            .await
    }

    /// Sends a caller-customizable assignment request and verifies its response.
    ///
    /// The `request` should be created from [`Self::build_assignment_request`] so it uses this
    /// client's configured cookie store and timeouts.
    ///
    /// # Errors
    ///
    /// Returns [`Error`] if the request fails, the host answers with an error status,
    /// or the attestation document does not verify.
    pub async fn request_assignment_with(
        &self,
        request: reqwest::RequestBuilder,
    ) -> Result<VerifiedAssignment, Error> {
        let response = request.send().await.map_err(Error::Request)?;

        let status = response.status();
        if !status.is_success() {
            return Err(Error::Status(status.as_u16()));
        }

        let assignment: EnclaveAssignmentResponse =
            response.json().await.map_err(Error::MalformedResponse)?;

        let document = STANDARD
            .decode(&assignment.attestation)
            .map_err(|_| Error::MalformedAssignment)?;
        let public_key = STANDARD
            .decode(&assignment.public_key)
            .map_err(|_| Error::MalformedAssignment)?;
        let (consumer, attestation) = ChannelConsumer::from_attestation(
            ChannelDomain::new(MATCH_CHANNEL_DOMAIN),
            &self.verifier,
            &document,
            &public_key,
        )
        .map_err(Error::Channel)?;

        Ok(VerifiedAssignment {
            attestation,
            consumer,
        })
    }

    /// Creates a sealed match request without sending it.
    ///
    /// Callers may customize the returned builder before passing it to
    /// [`Self::request_match_with`]. The returned opener must be passed alongside that builder.
    ///
    /// # Errors
    ///
    /// Returns [`Error`] if serializing or sealing the request fails.
    pub fn build_match_request(
        &self,
        assignment: &VerifiedAssignment,
        inputs: &MatchInputs,
    ) -> Result<(reqwest::RequestBuilder, pontifex::ResponseOpener), Error> {
        let plaintext = inputs.to_cbor().map_err(|_| Error::MalformedResult)?;
        let (sealed, opener) = assignment
            .consumer()
            .seal_to_enclave(&plaintext)
            .map_err(Error::Channel)?;
        let url = format!(
            "{}/v1/matches",
            self.config.host_url().as_str().trim_end_matches('/')
        );
        if sealed.len() > MAX_MATCH_BODY_BYTES {
            return Err(Error::MalformedResult);
        }
        let request = self
            .http
            .post(url)
            .header(reqwest::header::CONTENT_TYPE, MATCH_CONTENT_TYPE)
            .header(reqwest::header::ACCEPT, MATCH_CONTENT_TYPE)
            .body(sealed);

        Ok((request, opener))
    }

    /// Runs a match against the enclave `assignment` names.
    ///
    /// [`VerifiedMatchResult::Failed`] is a normal return, not an error. A statement and its claims are verified against the
    /// attested signing key once, then returned together.
    ///
    /// The caller supplies the operation's frames, including the downloaded challenge.
    ///
    /// # Errors
    ///
    /// [`Error::ReassignRequired`] on a stale assignment — retry once with a fresh one.
    pub async fn request_match(
        &self,
        assignment: &VerifiedAssignment,
        inputs: &MatchInputs,
    ) -> Result<VerifiedMatchResult, Error> {
        let (request, opener) = self.build_match_request(assignment, inputs)?;
        let result = self.request_match_with(request, opener).await?;
        if let VerifiedMatchResult::Success(verified) = &result
            && !inputs.matches_claims(&verified.claims)
        {
            return Err(Error::StatementInvalid);
        }
        Ok(result)
    }

    /// Execute a typed `DeepFace` request and return verified claims or a sealed rejection.
    /// # Errors
    /// Returns transport, attestation or contract errors.
    pub async fn deep_face(
        &self,
        assignment: &VerifiedAssignment,
        inputs: flamingo_verifier_sealed_types::DeepFaceInputs,
    ) -> Result<VerifiedMatchResult, Error> {
        self.request_match(assignment, &MatchInputs::DeepFace(inputs))
            .await
    }

    /// Submit a typed `GrayBadge` request without credential fields.
    /// Currently returns `UnsupportedOperation` until its token contract is agreed.
    /// # Errors
    /// Returns transport, attestation or contract errors.
    pub async fn gray_badge(
        &self,
        assignment: &VerifiedAssignment,
        inputs: flamingo_verifier_sealed_types::GrayBadgeInputs,
    ) -> Result<VerifiedMatchResult, Error> {
        self.request_match(assignment, &MatchInputs::GrayBadge(inputs))
            .await
    }

    /// Sends a caller-customizable match request and verifies its response.
    ///
    /// The `request` and `opener` must come from the same call to [`Self::build_match_request`].
    ///
    /// # Errors
    ///
    /// Returns [`Error`] if the request fails or its response cannot be verified.
    pub async fn request_match_with(
        &self,
        request: reqwest::RequestBuilder,
        opener: pontifex::ResponseOpener,
    ) -> Result<VerifiedMatchResult, Error> {
        let mut response = request.send().await.map_err(Error::Request)?;

        let status = response.status();
        if !status.is_success() {
            let bytes = bounded_response(&mut response).await?;
            let body = std::str::from_utf8(&bytes).ok();
            return Err(Self::api_error(status.as_u16(), body));
        }

        if response
            .headers()
            .get(reqwest::header::CONTENT_TYPE)
            .and_then(|h| h.to_str().ok())
            != Some(MATCH_CONTENT_TYPE)
        {
            return Err(Error::MalformedResult);
        }
        let ciphertext = bounded_response(&mut response).await?;
        let plaintext = opener
            .open_from_enclave(&ciphertext)
            .map_err(Error::Channel)?;
        let result =
            MatchResult::from_padded_cbor(&plaintext).map_err(|_| Error::MalformedResult)?;

        // Only a statement needs the key, so a rejection skips the attestation entirely.
        if let MatchResult::Success(statement) = result {
            // Response encryption alone does not authenticate the signing key.
            let attested = self
                .verifier
                .verify_attestation_document(&statement.signing_key_attestation)?;
            let signing_key = <[u8; 32]>::try_from(
                attested
                    .document()
                    .public_key
                    .as_ref()
                    .ok_or(Error::InvalidSigningKey)?
                    .as_slice(),
            )
            .map_err(|_| Error::InvalidSigningKey)
            .and_then(|bytes| {
                EdDSAPublicKey::from_compressed_bytes(bytes).map_err(|_| Error::InvalidSigningKey)
            })?;

            let claims = match_token::verify(&statement.token, &signing_key)
                .map_err(|_| Error::StatementInvalid)?;
            return Ok(VerifiedMatchResult::Success(Box::new(VerifiedMatch {
                statement,
                claims,
            })));
        }

        match result {
            MatchResult::Failed(reason) => Ok(VerifiedMatchResult::Failed(reason)),
            MatchResult::Success(_) => unreachable!("success was verified above"),
        }
    }

    /// Classifies a non-success response, reading the error envelope when there is one.
    fn api_error(status: u16, body: Option<&str>) -> Error {
        let Some(envelope) =
            body.and_then(|body| serde_json::from_str::<ApiErrorResponse>(body).ok())
        else {
            return Error::Status(status);
        };

        if envelope.error.code == REASSIGN_REQUIRED {
            return Error::ReassignRequired;
        }

        Error::Api {
            status,
            code: envelope.error.code,
            allow_retry: envelope.allow_retry,
        }
    }
}

async fn bounded_response(response: &mut reqwest::Response) -> Result<Vec<u8>, Error> {
    if response
        .content_length()
        .is_some_and(|length| length > MAX_MATCH_RESPONSE_BYTES as u64)
    {
        return Err(Error::MalformedResult);
    }
    let mut bytes = Vec::new();
    while let Some(chunk) = response.chunk().await.map_err(Error::MalformedResponse)? {
        if bytes.len() + chunk.len() > MAX_MATCH_RESPONSE_BYTES {
            return Err(Error::MalformedResult);
        }
        bytes.extend_from_slice(&chunk);
    }
    Ok(bytes)
}

/// A statement whose attestation and signature have been verified by the client.
#[derive(Debug, Clone, PartialEq)]
pub struct VerifiedMatch {
    /// Encoded statement and attestation for proof consumers.
    pub statement: flamingo_verifier_sealed_types::AttestedStatement,
    /// Already-verified operation-specific claims.
    pub claims: MatchClaims,
}
/// Verified success or an encrypted unsigned rejection.
#[derive(Debug, Clone, PartialEq)]
pub enum VerifiedMatchResult {
    /// Attested signed result and parsed claims.
    Success(Box<VerifiedMatch>),
    /// No statement issued.
    Failed(flamingo_verifier_sealed_types::FailureReason),
}
#[cfg(test)]
mod tests {
    use std::net::{Ipv4Addr, SocketAddr};
    use std::sync::{Arc, Mutex};

    use axum::extract::State;
    use axum::http::StatusCode;
    use axum::routing::post;
    use axum::{Json, Router};
    use flamingo_verifier_protocol::match_token::MatchToken;
    use flamingo_verifier_sealed_types::{
        AttestedStatement, FailureReason, MATCH_CHANNEL_DOMAIN, MatchInputs, MatchResult,
    };
    use hex_literal::hex;
    use pontifex::{ChannelConsumer, ChannelDomain, ChannelEnclave};
    use serde_json::json;

    use super::{FlamingoVerifierClient, VerifiedMatchResult};
    use crate::{Config, Error, PcrMeasurement};
    use axum::body::Bytes;
    use flamingo_verifier_api_types::MATCH_CONTENT_TYPE;

    fn config(base_url: &str) -> Config {
        let pcrs = vec![PcrMeasurement::new(
            0,
            hex!(
                "108b32466f5dc0a9971e0bc8e3e4074e7821bb2dcad3841bdec9a08b30f173386f0394a01486df181f316b39443dab34"
            ),
        )];

        Config::new(base_url, vec![pcrs]).expect("config should be valid")
    }

    fn inputs() -> MatchInputs {
        MatchInputs::GrayBadge(flamingo_verifier_sealed_types::GrayBadgeInputs {
            live: flamingo_verifier_sealed_types::LiveCapture::Vanilla(b"live".to_vec().into()),
            rtms_challenge: b"challenge".to_vec().into(),
            match_threshold: 0.5,
        })
    }

    async fn serve(router: Router) -> String {
        let listener = tokio::net::TcpListener::bind(SocketAddr::from((Ipv4Addr::LOCALHOST, 0)))
            .await
            .expect("should bind an ephemeral port");
        let address = listener
            .local_addr()
            .expect("listener should have an address");

        tokio::spawn(async move {
            axum::serve(listener, router)
                .await
                .expect("stub should run");
        });

        format!("http://{address}")
    }

    #[derive(Clone)]
    struct Enclave {
        responder: Arc<ChannelEnclave>,
        answer: MatchResult,
        seen: Arc<Mutex<Option<Vec<u8>>>>,
        foreign_reply: bool,
    }

    fn consumer_for(enclave: &ChannelEnclave) -> ChannelConsumer {
        ChannelConsumer::from_unverified_public_key(
            ChannelDomain::new(MATCH_CHANNEL_DOMAIN),
            &enclave.public_key(),
        )
        .expect("valid key")
    }

    async fn request_match_with_consumer(
        client: &FlamingoVerifierClient,
        consumer: &ChannelConsumer,
        inputs: &MatchInputs,
    ) -> Result<VerifiedMatchResult, Error> {
        let plaintext = inputs.to_cbor().map_err(|_| Error::MalformedResult)?;
        let (sealed, opener) = consumer
            .seal_to_enclave(&plaintext)
            .map_err(Error::Channel)?;
        let url = format!(
            "{}/v1/matches",
            client.config.host_url().as_str().trim_end_matches('/')
        );
        let request = client
            .http
            .post(url)
            .header("content-type", MATCH_CONTENT_TYPE)
            .body(sealed);

        client.request_match_with(request, opener).await
    }

    async fn serve_enclave(
        answer: MatchResult,
        foreign_reply: bool,
    ) -> (String, Arc<ChannelEnclave>, Arc<Mutex<Option<Vec<u8>>>>) {
        let responder = Arc::new(
            ChannelEnclave::generate(ChannelDomain::new(MATCH_CHANNEL_DOMAIN))
                .expect("channel key"),
        );
        let seen = Arc::new(Mutex::new(None));
        let state = Enclave {
            responder: Arc::clone(&responder),
            answer,
            seen: Arc::clone(&seen),
            foreign_reply,
        };

        let router =
            Router::new()
                .route(
                    "/v1/matches",
                    post(
                        |State(state): State<Enclave>,
                         headers: axum::http::HeaderMap,
                         body: Bytes| async move {
                            assert_eq!(headers["content-type"], MATCH_CONTENT_TYPE);
                            *state.seen.lock().expect("lock") = Some(body.to_vec());
                            let ciphertext = body;
                            let (_, own_sealer) = state
                                .responder
                                .open(&ciphertext)
                                .expect("the enclave should open a request sealed to its own key");

                            let sealer = if state.foreign_reply {
                                let stranger = ChannelConsumer::from_unverified_public_key(
                                    ChannelDomain::new(MATCH_CHANNEL_DOMAIN),
                                    &state.responder.public_key(),
                                )
                                .expect("key should decode");
                                let (other, _) = stranger
                                    .seal_to_enclave(b"unrelated")
                                    .expect("sealing should succeed");
                                state
                                    .responder
                                    .open(&other)
                                    .expect("the enclave opens its own")
                                    .1
                            } else {
                                own_sealer
                            };

                            let encoded = state
                                .answer
                                .to_padded_cbor()
                                .expect("result should fit the envelope");
                            let response = sealer.seal(&encoded).expect("sealing should succeed");

                            ([("content-type", MATCH_CONTENT_TYPE)], response)
                        },
                    ),
                )
                .with_state(state);

        (serve(router).await, responder, seen)
    }

    async fn serve_error(status: StatusCode, code: &'static str, allow_retry: bool) -> String {
        let router = Router::new().route(
            "/v1/matches",
            post(move || async move {
                (
                    status,
                    Json(json!({
                        "allowRetry": allow_retry,
                        "error": { "code": code, "message": "stub" },
                    })),
                )
            }),
        );

        serve(router).await
    }

    #[tokio::test]
    async fn a_sealed_rejection_round_trips() {
        let answer = MatchResult::Failed(FailureReason::MatchBelowThreshold(
            flamingo_verifier_sealed_types::ComparisonRole::SelfieChallenge,
        ));
        let (base_url, responder, seen) = serve_enclave(answer.clone(), false).await;
        let client = FlamingoVerifierClient::new(config(&base_url)).expect("client should build");

        let result = request_match_with_consumer(&client, &consumer_for(&responder), &inputs())
            .await
            .expect("a rejection is a normal return");

        assert!(matches!(
            result,
            VerifiedMatchResult::Failed(FailureReason::MatchBelowThreshold(_))
        ));

        let body = seen.lock().expect("lock should be held").clone().unwrap();
        let (plaintext, _) = responder.open(&body).unwrap();
        assert!(matches!(
            MatchInputs::from_cbor(&plaintext),
            Ok(MatchInputs::GrayBadge(_))
        ));
    }

    #[tokio::test]
    async fn a_reply_from_another_exchange_cannot_be_opened() {
        let (base_url, responder, _) =
            serve_enclave(MatchResult::Failed(FailureReason::MalformedInputs), true).await;
        let client = FlamingoVerifierClient::new(config(&base_url)).expect("client should build");

        let error = request_match_with_consumer(&client, &consumer_for(&responder), &inputs())
            .await
            .expect_err("a reply sealed on another exchange must not open");

        assert!(matches!(error, Error::Channel(_)), "got {error:?}");
    }

    #[tokio::test]
    async fn a_stale_assignment_asks_for_a_reassignment() {
        let base_url = serve_error(StatusCode::CONFLICT, "reassign_required", true).await;
        let client = FlamingoVerifierClient::new(config(&base_url)).expect("client should build");
        let responder = ChannelEnclave::generate(ChannelDomain::new(MATCH_CHANNEL_DOMAIN))
            .expect("channel key");

        let error = request_match_with_consumer(&client, &consumer_for(&responder), &inputs())
            .await
            .expect_err("a 409 is an error, not a result");

        assert!(
            matches!(error, Error::ReassignRequired),
            "a 409 must be distinguishable so the caller can retry once, got {error:?}"
        );
    }

    #[tokio::test]
    async fn other_envelopes_keep_their_code_and_retry_flag() {
        let base_url = serve_error(StatusCode::PAYLOAD_TOO_LARGE, "request_too_large", false).await;
        let client = FlamingoVerifierClient::new(config(&base_url)).expect("client should build");
        let responder = ChannelEnclave::generate(ChannelDomain::new(MATCH_CHANNEL_DOMAIN))
            .expect("channel key");

        let error = request_match_with_consumer(&client, &consumer_for(&responder), &inputs())
            .await
            .expect_err("a 413 is an error");

        match error {
            Error::Api {
                status,
                code,
                allow_retry,
            } => {
                assert_eq!(status, 413);
                assert_eq!(code, "request_too_large");
                assert!(!allow_retry);
            }
            other => panic!("expected an envelope, got {other:?}"),
        }
    }

    #[tokio::test]
    async fn a_status_without_an_envelope_still_surfaces() {
        let router = Router::new().route(
            "/v1/matches",
            post(|| async { (StatusCode::BAD_GATEWAY, "not json") }),
        );
        let base_url = serve(router).await;
        let client = FlamingoVerifierClient::new(config(&base_url)).expect("client should build");
        let responder = ChannelEnclave::generate(ChannelDomain::new(MATCH_CHANNEL_DOMAIN))
            .expect("channel key");

        let error = request_match_with_consumer(&client, &consumer_for(&responder), &inputs())
            .await
            .expect_err("a 502 is an error");

        assert!(matches!(error, Error::Status(502)), "got {error:?}");
    }

    #[tokio::test]
    async fn a_statement_whose_attestation_does_not_verify_is_rejected() {
        for attestation in [Vec::new(), b"not a COSE attestation document".to_vec()] {
            let answer = MatchResult::Success(AttestedStatement {
                token: MatchToken::from_bytes(b"cose-sign1".to_vec()),
                signing_key_attestation: attestation,
            });
            let (base_url, responder, _) = serve_enclave(answer, false).await;
            let client =
                FlamingoVerifierClient::new(config(&base_url)).expect("client should build");

            let error = request_match_with_consumer(&client, &consumer_for(&responder), &inputs())
                .await
                .expect_err("an unverifiable attestation must not yield a statement");

            assert!(
                matches!(error, Error::Attestation(_)),
                "expected an attestation failure, got {error:?}"
            );
        }
    }
}