pub enum KeyResult {
AllValid,
PartialFailure {
failed_indices: Vec<usize>,
},
AllFailed,
}Expand description
Result of ML-DSA multi-key challenge verification
After verifying all key proofs in a response, the server sends back this result indicating which proofs succeeded or failed. This allows the client to understand their verification status.
§Success Criteria
The handshake is considered successful if at least one key proof is valid. Even if some proofs fail, the connection can continue with the successfully verified keys.
§Error Handling
If all proofs fail, the server should close the connection. Clients can use the failure information to:
- Log which specific keys were rejected
- Retry the connection with different keys
- Debug key or signature generation issues
Variants§
AllValid
All key proofs were successfully verified
This is the ideal case where every key the client attempted to prove was successfully verified. All provided keys are now available for use in message authentication on this connection.
PartialFailure
Some key proofs failed verification
Contains the indices (into the original key_proofs vector) of proofs
that failed verification. The connection continues with the successfully
verified keys.
Common failure reasons:
- Invalid signature (wrong private key used)
- Malformed public key encoding
- Signature over wrong data (incorrect nonce/server key)
- Expired challenge (client took too long to respond)
Fields
AllFailed
All key proofs failed verification
No keys were successfully verified. The server will typically close the connection after sending this result. Clients should not attempt to establish service streams after receiving this result.
Implementations§
Source§impl KeyResult
impl KeyResult
Sourcepub fn is_successful(&self) -> bool
pub fn is_successful(&self) -> bool
Check if the handshake was successful (at least one key verified)
Returns true if at least one key was successfully verified,
false if all keys failed verification.
§Example
use zoe_wire_protocol::KeyResult;
let result = KeyResult::PartialFailure {
failed_indices: vec![1, 3]
};
assert!(result.is_successful());
let result = KeyResult::AllFailed;
assert!(!result.is_successful());Sourcepub fn failed_count(&self, total_keys: usize) -> usize
pub fn failed_count(&self, total_keys: usize) -> usize
Get the number of failed key proofs
Returns the count of key proofs that failed verification.
For AllValid, returns 0. For AllFailed, the count depends
on how many keys were originally submitted.
§Parameters
total_keys- Total number of keys that were submitted (needed for AllFailed case)
§Example
use zoe_wire_protocol::KeyResult;
let result = KeyResult::PartialFailure {
failed_indices: vec![1, 3]
};
assert_eq!(result.failed_count(5), 2);
let result = KeyResult::AllFailed;
assert_eq!(result.failed_count(3), 3);Sourcepub fn success_count(&self, total_keys: usize) -> usize
pub fn success_count(&self, total_keys: usize) -> usize
Get the number of successfully verified keys
Returns the count of key proofs that passed verification.
§Parameters
total_keys- Total number of keys that were submitted
§Example
use zoe_wire_protocol::KeyResult;
let result = KeyResult::PartialFailure {
failed_indices: vec![1]
};
assert_eq!(result.success_count(3), 2);
let result = KeyResult::AllValid;
assert_eq!(result.success_count(5), 5);