Using voprf as a dependency (#248)

* Using voprf as a dependency

* Adding back x25519 and KeGroup

* Addressing comments
This commit is contained in:
Kevin Lewi
2021-10-25 02:54:32 -07:00
committed by GitHub
parent f1f4184400
commit 29b2ebef1b
34 changed files with 1638 additions and 2452 deletions
+20
View File
@@ -45,6 +45,10 @@ pub enum InternalError<T = Infallible> {
IncompatibleEnvelopeModeError,
/// This error occurs when the inner envelope is malformed
InvalidInnerEnvelopeError,
/// Error from the OPRF evaluation
OprfError(voprf::errors::InternalError),
/// Error encountered when attempting to produce a keypair
InvalidKeypairError,
}
impl<T: Debug> Debug for InternalError<T> {
@@ -72,6 +76,8 @@ impl<T: Debug> Debug for InternalError<T> {
f.debug_tuple("IncompatibleEnvelopeModeError").finish()
}
Self::InvalidInnerEnvelopeError => f.debug_tuple("InvalidInnerEnvelopeError").finish(),
Self::OprfError(error) => f.debug_tuple("OprfError").field(error).finish(),
Self::InvalidKeypairError => f.debug_tuple("InvalidKeypairError").finish(),
}
}
}
@@ -102,10 +108,24 @@ impl InternalError {
Self::SealOpenHmacError => InternalError::SealOpenHmacError,
Self::IncompatibleEnvelopeModeError => InternalError::IncompatibleEnvelopeModeError,
Self::InvalidInnerEnvelopeError => InternalError::InvalidInnerEnvelopeError,
Self::OprfError(error) => InternalError::OprfError(error),
Self::InvalidKeypairError => InternalError::InvalidKeypairError,
}
}
}
impl From<voprf::errors::InternalError> for InternalError {
fn from(voprf_error: voprf::errors::InternalError) -> Self {
Self::OprfError(voprf_error)
}
}
impl From<voprf::errors::InternalError> for ProtocolError {
fn from(voprf_error: voprf::errors::InternalError) -> Self {
Self::LibraryError(InternalError::OprfError(voprf_error))
}
}
/// Represents an error in protocol handling
#[derive(Clone, Display, Eq, Hash, PartialEq)]
pub enum ProtocolError<T = Infallible> {