Skip to content

Commit

Permalink
Validation tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Aug 24, 2023
1 parent 84481da commit dc8eefb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 16 additions & 1 deletion utils/src/owned_pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ark_ec::{AffineRepr, VariableBaseMSM};
use ark_ff::PrimeField;
use ark_serialize::*;

use serde::{de::Error, Deserializer, Serializer};
use serde::{de::Error, Deserialize, Deserializer, Serializer};
use serde_with::{DeserializeAs, SerializeAs};
use zeroize::Zeroize;

Expand Down Expand Up @@ -265,6 +265,21 @@ where
}
}

impl<'de, Left, Right> Deserialize<'de> for OwnedPairs<Left, Right>
where
Left: Deserialize<'de>,
Right: Deserialize<'de>,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let (left, right) = <(Vec<Left>, Vec<Right>)>::deserialize(deserializer)?;

Self::new(left, right).ok_or(serde::de::Error::custom("Invalid length"))
}
}

impl<'de, LeftAs, RightAs, Left, Right> DeserializeAs<'de, OwnedPairs<LeftAs, RightAs>>
for OwnedPairs<Left, Right>
where
Expand Down
2 changes: 0 additions & 2 deletions utils/src/pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ impl<'left, 'right, Left, Right> Clone for Pairs<'left, 'right, Left, Right> {
}
}

#[allow(dead_code)]
impl<'left, 'right, Left, Right> Pairs<'left, 'right, Left, Right> {
/// Combines two slices together if they have equal length.
pub fn new(left: &'left [Left], right: &'right [Right]) -> Option<Self> {
Expand Down Expand Up @@ -150,7 +149,6 @@ impl<'left, 'right, G: AffineRepr> Pairs<'left, 'right, G, G::ScalarField> {
}

/// Extension for `OwnedPairs` for cases when left is an `AffineRepr` implementer, and right is a `ScalarField::BigInt` implementer.
#[allow(dead_code)]
impl<G: AffineRepr> Pairs<'_, '_, G, <G::ScalarField as PrimeField>::BigInt> {
/// `G::Group::msm_bigint(left, right)`
pub fn msm_bigint(&self) -> G::Group {
Expand Down

0 comments on commit dc8eefb

Please sign in to comment.