-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MiscellaneousSelectVerifier
for ReportBody
verification
#22
Conversation
Codecov Report
@@ Coverage Diff @@
## nick/isv_version #22 +/- ##
====================================================
+ Coverage 91.86% 92.44% +0.58%
====================================================
Files 2 2
Lines 295 331 +36
====================================================
+ Hits 271 306 +35
- Misses 24 25 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
94494e0
to
aafd838
Compare
860bdcc
to
c31d9e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, but reading through all these, can they be collapsed into either a macro or a blanket impl over generics?
e.g. the blanket impls version would look something like:
/// A marker trait supporting objects which should be verified with ct_eq()
trait IntoVerificationError {
fn into_verification_error(expected: Self, actual: Self) -> VerificationError;
}
trait VerifiedWithCtEq: ConstantTimeEq + IntoVerificationError {}
// this can be macro-ized.
impl IntoVerificationError for MiscellaneousSelect {
fn into_verification_error(expected, Self, actual: Self) -> VerificationError {
VerificationError::MiscellaneousSelectMismatch {
expected,
actual
}
}
}
impl VerifiedWithCtEq for MiscellaneousSelect {}
// etc.
impl VerifiedWithCtEq for ConfigId {}
impl VerifiedWithCtEq for ExtProdId {}
/// Equality verifier
pub struct EqualityVerifier<T: VerifiedWithEq + Clone> {
expected: T
}
impl<T: VerifiedWithCtEq, E: Accessor<T>> Verifier<E> for EqualityVerifier<T> {
type Error = VerificationError;
fn verify(&self, evidence: &E) -> CtOption<Self::Error> {
let expected = self.expected.clone();
let actual = evidence.get();
let is_eq = expected.ct_eq(actual);
CtOption::new(
T::into_verification_error(expected, actual),
!is_eq
)
}
}
Whereas a macro would just macroize the Verifier
impl at the end, but would require having everything be visible from the macro.
aafd838
to
f430127
Compare
c31d9e6
to
2a492d8
Compare
bump @varsha888 due to restack |
No description provided.