oarust 0.14.0

GPU-first semantic computing engine written in Rust
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
// @generated by tool/gen/fn/generate.py; DO NOT EDIT.
// schema=crypto_pqc.json schema_version=1 generator_version=64
// schema_sha256=8f189e5eb316e76fc2971de4cd6f5852eb7011a1e6fcaeebaba92903ca0214ed
//! Experimental device-secret PQC operations. No private value is a Matrix.
//! The originating Engine owns execution; Drop never submits or waits.
use crate::crypto::entropy::Entropy;
use crate::crypto::pqc::MlDsaParameters;
use crate::runtime::{MlDsaDeviceKey, MlKemDeviceKey, MlKemSharedSecret, SecretErasure};
use crate::{Engine, Error, Matrix, Result};

/// FIPS 203 device-key parameter set.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum MlKemParameters {
	/// ML-KEM-512.
	MlKem512,
	/// ML-KEM-768.
	MlKem768,
	/// ML-KEM-1024.
	MlKem1024,
}

impl MlKemParameters {
	/// Private polynomial-vector width.
	#[must_use]
	pub(crate) const fn k(self) -> u32 {
		match self {
			Self::MlKem512 => 2,
			Self::MlKem768 => 3,
			Self::MlKem1024 => 4,
		}
	}
	/// Encoded encapsulation-key bytes.
	#[must_use]
	pub const fn public_key_size(self) -> usize {
		match self {
			Self::MlKem512 => 800,
			Self::MlKem768 => 1184,
			Self::MlKem1024 => 1568,
		}
	}
	/// Encoded ciphertext bytes.
	#[must_use]
	pub const fn ciphertext_size(self) -> usize {
		match self {
			Self::MlKem512 => 768,
			Self::MlKem768 => 1088,
			Self::MlKem1024 => 1568,
		}
	}
}

/// FIPS 204 HashML-DSA identity and exact digest extent.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum MlDsaPrehash {
	/// SHA2-256, 32 digest bytes.
	Sha256,
	/// SHA2-384, 48 digest bytes.
	Sha384,
	/// SHA2-512, 64 digest bytes.
	Sha512,
	/// SHA2-224, 28 digest bytes.
	Sha224,
	/// SHA2-512/224, 28 digest bytes.
	Sha512Truncated224,
	/// SHA2-512/256, 32 digest bytes.
	Sha512Truncated256,
	/// SHA3-224, 28 digest bytes.
	Sha3_224,
	/// SHA3-256, 32 digest bytes.
	Sha3_256,
	/// SHA3-384, 48 digest bytes.
	Sha3_384,
	/// SHA3-512, 64 digest bytes.
	Sha3_512,
	/// SHAKE-128, 32 digest bytes.
	Shake128,
	/// SHAKE-256, 64 digest bytes.
	Shake256,
}

impl MlDsaPrehash {
	/// Private NIST OID suffix.
	#[must_use]
	pub(crate) const fn id(self) -> u32 {
		match self {
			Self::Sha256 => 1,
			Self::Sha384 => 2,
			Self::Sha512 => 3,
			Self::Sha224 => 4,
			Self::Sha512Truncated224 => 5,
			Self::Sha512Truncated256 => 6,
			Self::Sha3_224 => 7,
			Self::Sha3_256 => 8,
			Self::Sha3_384 => 9,
			Self::Sha3_512 => 10,
			Self::Shake128 => 11,
			Self::Shake256 => 12,
		}
	}
	/// Exact encoded digest bytes.
	#[must_use]
	pub const fn digest_bytes(self) -> usize {
		match self {
			Self::Sha256 => 32,
			Self::Sha384 => 48,
			Self::Sha512 => 64,
			Self::Sha224 => 28,
			Self::Sha512Truncated224 => 28,
			Self::Sha512Truncated256 => 32,
			Self::Sha3_224 => 28,
			Self::Sha3_256 => 32,
			Self::Sha3_384 => 48,
			Self::Sha3_512 => 64,
			Self::Shake128 => 32,
			Self::Shake256 => 64,
		}
	}
}

/// Signing randomness policy. Deterministic signing uses FIPS 204's zero rnd.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SigningMode {
	/// Fresh operating-system entropy for every signature.
	#[default]
	Randomized,
	/// Reproducible signatures for a fixed key, message, and context.
	Deterministic,
}

/// Exact completion of explicit secret or transient-workspace erasure.
/// Dropping the ticket neither waits nor cancels the retained command.
#[must_use = "observe erasure completion before treating memory as erased"]
pub struct DeviceErasure {
	inner: SecretErasure,
}

impl DeviceErasure {
	/// Check exact completion without submitting or waiting.
	/// # Errors
	/// Returns failure if execution or erasure could not be confirmed.
	pub fn try_is_complete(&self) -> Result<bool> {
		self.inner.try_is_complete()
	}

	/// Wait for this submission and confirm all included overwrites.
	/// # Errors
	/// Returns failure if execution or erasure could not be confirmed.
	pub fn wait(&self) -> Result<()> {
		self.inner.wait()
	}
}

/// Unique retained ML-DSA key. No mapping, serialization, Clone, or Debug.
/// Abandonment quarantines its secret allocation; use consuming `erase`.
#[must_use = "explicitly erase the device key when its final consumer is recorded"]
pub struct DeviceMlDsaKey {
	inner: MlDsaDeviceKey,
	parameters: MlDsaParameters,
	public_key: Matrix,
	cleanup: DeviceErasure,
}

impl DeviceMlDsaKey {
	/// Parameter set retained with the generated key.
	#[must_use]
	pub const fn parameters(&self) -> MlDsaParameters {
		self.parameters
	}

	/// Public encoded key, ready through the exact key-generation submission.
	#[must_use]
	pub const fn public_key(&self) -> &Matrix {
		&self.public_key
	}

	/// Erasure of generation entropy and transient workspace, excluding the key.
	#[must_use = "observe completion before reusing erased storage"]
	pub const fn cleanup(&self) -> &DeviceErasure {
		&self.cleanup
	}

	/// Consume the key and record erasure after all preceding consumers.
	/// # Errors
	/// Rejects capture or submission failure; unconfirmed memory stays quarantined.
	pub fn erase(self) -> Result<DeviceErasure> {
		Ok(DeviceErasure {
			inner: self.inner.erase()?,
		})
	}
}

/// Unique retained ML-KEM decapsulation key; secret bytes never enter Matrix.
#[must_use = "explicitly erase the device key after its final consumer"]
pub struct DeviceMlKemKey {
	inner: MlKemDeviceKey,
	parameters: MlKemParameters,
	public_key: Matrix,
	cleanup: DeviceErasure,
}

impl DeviceMlKemKey {
	/// Parameter set retained with the key.
	#[must_use]
	pub const fn parameters(&self) -> MlKemParameters {
		self.parameters
	}

	/// Public encapsulation key, with exact generation readiness.
	#[must_use]
	pub const fn public_key(&self) -> &Matrix {
		&self.public_key
	}

	/// Erasure of generation entropy/workspace, excluding the retained key.
	#[must_use = "observe completion before reusing erased storage"]
	pub const fn cleanup(&self) -> &DeviceErasure {
		&self.cleanup
	}

	/// Consume the key and record ordered erasure.
	/// # Errors
	/// Rejects capture or submission failure; unconfirmed memory stays quarantined.
	pub fn erase(self) -> Result<DeviceErasure> {
		Ok(DeviceErasure {
			inner: self.inner.erase()?,
		})
	}
}

/// Unique ML-KEM shared secret. No host read, export, or Matrix conversion.
#[must_use = "explicitly erase the device shared secret after its final consumer"]
pub struct DeviceSharedSecret {
	inner: MlKemSharedSecret,
}

impl DeviceSharedSecret {
	/// Consume the shared secret and record ordered erasure.
	/// # Errors
	/// Rejects capture or submission failure; unconfirmed memory stays quarantined.
	pub fn erase(self) -> Result<DeviceErasure> {
		Ok(DeviceErasure {
			inner: self.inner.erase()?,
		})
	}
}

/// Public signing outcome. Status `U32[1]` is one on success, zero on failure.
/// Signature bytes are zero on failure; observe status before using them.
#[must_use]
pub struct DeviceSignature {
	/// Encoded public signature, U8[1, signature_size].
	pub signature: Matrix,
	/// Public success status, with no rejection-loop count.
	pub status: Matrix,
	/// Exact transient entropy/workspace erasure completion.
	pub cleanup: DeviceErasure,
}

/// Public ciphertext plus an opaque shared secret and public-key validity.
/// A zero status rejects the encapsulation key; it is not a ciphertext oracle.
#[must_use]
pub struct DeviceEncapsulation {
	/// Opaque shared secret. Usable only when public-key status is one.
	pub shared_secret: DeviceSharedSecret,
	/// Public ciphertext, U8[1, ciphertext_size].
	pub ciphertext: Matrix,
	/// `U32[1]` canonical encapsulation-key status.
	pub status: Matrix,
	/// Transient entropy/workspace erasure completion, excluding shared_secret.
	pub cleanup: DeviceErasure,
}

/// Deferred secret-execution batch owned by one Engine.
///
/// While a scope is active, every engine submission — secret or ordinary —
/// records without queueing; `commit` submits the ordered batch once.
/// Operation events and erasure tickets issued inside the scope stay pending
/// until commit and fail on abandonment. The batch carries only secret
/// classification metadata, never secret bytes.
#[must_use = "commit submits the deferred batch; abandoning fails its completions"]
pub struct PqcSecretScope {
	inner: crate::runtime::SecretLoweringScope,
}

/// Begin a deferred secret-execution batch on `engine`.
/// # Errors
/// Rejects an active capture or a second concurrent scope.
pub fn begin_secret_scope(engine: &Engine) -> Result<PqcSecretScope> {
	Ok(PqcSecretScope {
		inner: engine.handle().begin_secret_lowering()?,
	})
}

/// Classification snapshot of one deferred scope node. Diagnostics observe
/// flags and order only; no secret bytes or native handles are exposed.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct PqcSecretScopeNode {
	/// The recorded submission consumes non-mappable secret storage.
	pub uses_secret: bool,
	/// The recorded submission schedules secret-erasure work.
	pub records_erasure: bool,
	/// The recorded submission retains ordinary public resources.
	pub retains_public: bool,
}

impl PqcSecretScope {
	/// Classification snapshot of the deferred nodes in recorded order.
	pub fn nodes(&self) -> Vec<PqcSecretScopeNode> {
		self
			.inner
			.nodes()
			.into_iter()
			.map(|node| PqcSecretScopeNode {
				uses_secret: node.uses_secret,
				records_erasure: node.records_erasure,
				retains_public: node.retains_public,
			})
			.collect()
	}

	/// Submit the deferred batch in recorded order.
	/// # Errors
	/// Rejects an empty scope, submission, or retirement failure. Unsubmitted
	/// nodes are freed and their completions fail; submitted nodes retire.
	pub fn commit(self) -> Result<()> {
		self.inner.commit().map(|_| ())
	}
}

/// Opaque decapsulation result. Correct-size malformed ciphertexts follow
/// implicit rejection entirely on device; no validity flag is exposed.
#[must_use]
pub struct DeviceDecapsulation {
	/// Retained secret selected by the implicit-rejection algorithm.
	pub shared_secret: DeviceSharedSecret,
	/// Secret-derived workspace erasure completion, excluding shared_secret.
	pub cleanup: DeviceErasure,
}

/// Public derivation outcome. `derived` is the only public value produced
/// from the opaque shared secret inside the keyed-hash boundary.
#[must_use]
pub struct DeviceDerivation {
	/// Public derived bytes, U8[1, length].
	pub derived: Matrix,
	/// Exact derivation-submission completion evidence.
	pub cleanup: DeviceErasure,
}

/// Generate a retained ML-DSA-44/65/87 key from fresh OS entropy.
/// # Errors
/// Rejects unsupported kernels, capture, allocation, entropy, or submission errors.
pub fn mldsa_keygen(engine: &Engine, parameters: MlDsaParameters) -> Result<DeviceMlDsaKey> {
	let parameter = match parameters {
		MlDsaParameters::MlDsa44 => 44,
		MlDsaParameters::MlDsa65 => 65,
		MlDsaParameters::MlDsa87 => 87,
	};
	let (inner, public_key, cleanup) = engine
		.handle()
		.pqc_mldsa_keygen(parameter, Entropy::generate()?)?;
	Ok(DeviceMlDsaKey {
		inner,
		parameters,
		public_key,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Generate a retained ML-KEM-512/768/1024 key from fresh OS entropy.
/// # Errors
/// Rejects unsupported kernels, capture, allocation, entropy, or submission errors.
pub fn mlkem_keygen(engine: &Engine, parameters: MlKemParameters) -> Result<DeviceMlKemKey> {
	let (inner, public_key, cleanup) = engine
		.handle()
		.pqc_mlkem_keygen(parameters.k(), Entropy::generate()?)?;
	Ok(DeviceMlKemKey {
		inner,
		parameters,
		public_key,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Import FIPS 204 signing-key bytes with their encoded public U8 key.
/// The secret input range is locked best-effort and erased before return; its
/// upload becomes the retained device secret. Importing does not prove that the
/// secret and public halves form a consistent key pair.
/// # Errors
/// Rejects extent/ownership mismatches, capture, or submission errors.
pub fn mldsa_import_key(
	engine: &Engine,
	parameters: MlDsaParameters,
	secret_key: &mut [u8],
	public_key: &Matrix,
) -> Result<DeviceMlDsaKey> {
	let parameter = match parameters {
		MlDsaParameters::MlDsa44 => 44,
		MlDsaParameters::MlDsa65 => 65,
		MlDsaParameters::MlDsa87 => 87,
	};
	let secret = crate::crypto::SecureBuffer::new(secret_key);
	let (inner, public_key, cleanup) =
		engine
			.handle()
			.pqc_mldsa_import(parameter, secret.as_slice(), public_key)?;
	Ok(DeviceMlDsaKey {
		inner,
		parameters,
		public_key,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Import FIPS 203 decapsulation-key bytes. The embedded encapsulation key
/// supplies the retained public value; the secret input range is locked
/// best-effort and erased before return. Importing does not prove that the
/// decapsulation key is well-formed.
/// # Errors
/// Rejects extent mismatches, capture, or submission errors.
pub fn mlkem_import_key(
	engine: &Engine,
	parameters: MlKemParameters,
	decapsulation_key: &mut [u8],
) -> Result<DeviceMlKemKey> {
	let secret = crate::crypto::SecureBuffer::new(decapsulation_key);
	let (inner, public_key, cleanup) = engine
		.handle()
		.pqc_mlkem_import(parameters.k(), secret.as_slice())?;
	Ok(DeviceMlKemKey {
		inner,
		parameters,
		public_key,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Sign public U8 message bytes with the FIPS 204 context (at most 255 bytes).
/// Inputs retain the key's Engine; neither input is copied to host.
/// # Errors
/// Rejects dtype/ownership/alias/context errors, capture, or execution failure.
pub fn mldsa_sign(
	key: &DeviceMlDsaKey,
	message: &Matrix,
	context: &Matrix,
	mode: SigningMode,
) -> Result<DeviceSignature> {
	if context.num_elements() > 255 {
		return Err(Error::invalid_argument("ML-DSA context exceeds 255 bytes"));
	}
	let entropy = match mode {
		SigningMode::Randomized => Entropy::generate()?,
		SigningMode::Deterministic => Entropy::deterministic_signing()?,
	};
	let (signature, status, cleanup) = key
		.inner
		.engine()
		.pqc_mldsa_sign(&key.inner, message, context, None, entropy)?;
	Ok(DeviceSignature {
		signature,
		status,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Hash and sign original public U8 message bytes on device (HashML-DSA).
/// # Errors
/// Rejects dtype/ownership/alias/context errors, capture, or execution failure.
pub fn mldsa_sign_hash_message(
	key: &DeviceMlDsaKey,
	message: &Matrix,
	context: &Matrix,
	algorithm: MlDsaPrehash,
	mode: SigningMode,
) -> Result<DeviceSignature> {
	if context.num_elements() > 255 {
		return Err(Error::invalid_argument("ML-DSA context exceeds 255 bytes"));
	}
	let entropy = match mode {
		SigningMode::Randomized => Entropy::generate()?,
		SigningMode::Deterministic => Entropy::deterministic_signing()?,
	};
	let (signature, status, cleanup) = key.inner.engine().pqc_mldsa_sign(
		&key.inner,
		message,
		context,
		Some(algorithm.id()),
		entropy,
	)?;
	Ok(DeviceSignature {
		signature,
		status,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Sign an exact-length public digest with FIPS HashML-DSA OID framing.
/// # Errors
/// Rejects digest/context metadata, owner/alias mismatch, capture, or execution errors.
pub fn mldsa_sign_prehashed(
	key: &DeviceMlDsaKey,
	digest: &Matrix,
	context: &Matrix,
	algorithm: MlDsaPrehash,
	mode: SigningMode,
) -> Result<DeviceSignature> {
	if digest.num_elements() != algorithm.digest_bytes() || context.num_elements() > 255 {
		return Err(Error::invalid_argument(
			"HashML-DSA digest or context extent mismatch",
		));
	}
	let entropy = match mode {
		SigningMode::Randomized => Entropy::generate()?,
		SigningMode::Deterministic => Entropy::deterministic_signing()?,
	};
	let (signature, status, cleanup) = key.inner.engine().pqc_mldsa_sign_prehashed(
		&key.inner,
		digest,
		context,
		algorithm.id(),
		entropy,
	)?;
	Ok(DeviceSignature {
		signature,
		status,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Encapsulate to a public U8 key. Canonicality is checked on device.
/// # Errors
/// Rejects key dtype/owner/extent, capture, entropy, or execution errors.
pub fn mlkem_encapsulate(
	public_key: &Matrix,
	parameters: MlKemParameters,
) -> Result<DeviceEncapsulation> {
	if public_key.num_elements() != parameters.public_key_size() {
		return Err(Error::invalid_argument("ML-KEM public key extent mismatch"));
	}
	let (inner, ciphertext, status, cleanup) = public_key.engine_handle().pqc_mlkem_encapsulate(
		parameters.k(),
		public_key,
		Entropy::generate()?,
	)?;
	Ok(DeviceEncapsulation {
		shared_secret: DeviceSharedSecret { inner },
		ciphertext,
		status,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Decapsulate a correct-size public ciphertext using a retained device key.
/// # Errors
/// Rejects dtype/owner/extent, capture, or execution errors. Ciphertext content
/// rejection produces an opaque replacement secret, never an error or flag.
pub fn mlkem_decapsulate(key: &DeviceMlKemKey, ciphertext: &Matrix) -> Result<DeviceDecapsulation> {
	if ciphertext.num_elements() != key.parameters.ciphertext_size() {
		return Err(Error::invalid_argument("ML-KEM ciphertext extent mismatch"));
	}
	let (inner, cleanup) = key
		.inner
		.engine()
		.pqc_mlkem_decapsulate(&key.inner, ciphertext)?;
	Ok(DeviceDecapsulation {
		shared_secret: DeviceSharedSecret { inner },
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Declassify public bytes derived from a device shared secret. The secret
/// never leaves private storage; keyed SHAKE-256 output is the only result.
/// `info` is public customization data absorbed after the secret; `length`
/// must be a nonzero multiple of four within 4096 bytes.
/// # Errors
/// Rejects dtype/owner/extent errors, capture, or execution failure.
pub fn mlkem_shared_derive(
	secret: &DeviceSharedSecret,
	info: &Matrix,
	length: usize,
) -> Result<DeviceDerivation> {
	let output_len = u32::try_from(length)
		.map_err(|_| Error::invalid_argument("shared-secret derivation extent exceeds u32"))?;
	let (derived, cleanup) =
		secret
			.inner
			.engine()
			.pqc_mlkem_derive(&secret.inner, info, output_len)?;
	Ok(DeviceDerivation {
		derived,
		cleanup: DeviceErasure { inner: cleanup },
	})
}

/// Verify HashML-DSA original-message batches with a typed hash identity.
/// # Errors
/// Rejects incompatible metadata; malformed signature rows produce zero status.
#[expect(
	clippy::too_many_arguments,
	reason = "batch verifier preserves explicit zero-copy byte ranges"
)]
pub fn mldsa_verify_hash_message(
	parameters: MlDsaParameters,
	algorithm: MlDsaPrehash,
	messages: &Matrix,
	offsets: &Matrix,
	lengths: &Matrix,
	signatures: &Matrix,
	public_keys: &Matrix,
	context: std::ops::Range<usize>,
) -> Result<Matrix> {
	super::super::verification::verify_hash_message_batch(
		parameters,
		algorithm.id(),
		messages,
		offsets,
		lengths,
		signatures,
		public_keys,
		context,
	)
}

/// Verify precomputed-digest batches with exact typed FIPS hash extents.
/// # Errors
/// Rejects incompatible metadata; invalid digest/signature rows produce zero.
#[expect(
	clippy::too_many_arguments,
	reason = "batch verifier preserves explicit zero-copy byte ranges"
)]
pub fn mldsa_verify_prehashed(
	parameters: MlDsaParameters,
	algorithm: MlDsaPrehash,
	digests: &Matrix,
	offsets: &Matrix,
	lengths: &Matrix,
	signatures: &Matrix,
	public_keys: &Matrix,
	context: std::ops::Range<usize>,
) -> Result<Matrix> {
	super::super::verification::verify_prehashed_batch(
		parameters,
		algorithm.id(),
		digests,
		offsets,
		lengths,
		signatures,
		public_keys,
		context,
	)
}