Skip to content

Commit

Permalink
chore(all): format
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeul-zama committed Oct 4, 2024
1 parent a537fb6 commit 39e3291
Show file tree
Hide file tree
Showing 38 changed files with 342 additions and 135 deletions.
2 changes: 1 addition & 1 deletion tfhe-zk-pok/src/curve_api/msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn make_digits(a: &impl BigInteger, w: usize, num_bits: usize) -> impl Iterator<
} else {
num_bits
};
let digits_count = num_bits.div_ceil(w) ;
let digits_count = num_bits.div_ceil(w);

(0..digits_count).map(move |i| {
// Construct a buffer of bits of the scalar, starting at `bit_offset`.
Expand Down
6 changes: 3 additions & 3 deletions tfhe-zk-pok/src/proofs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pub(crate) struct OneBased<T: ?Sized>(T);

// TODO: these impl could be removed by adding support for `repr(transparent)` in tfhe-versionable
impl<T: Versionize> Versionize for OneBased<T> {
type Versioned<'vers> = T::Versioned<'vers>
type Versioned<'vers>
= T::Versioned<'vers>
where
T: 'vers,
;
T: 'vers;

fn versionize(&self) -> Self::Versioned<'_> {
self.0.versionize()
Expand Down
10 changes: 6 additions & 4 deletions tfhe-zk-pok/src/proofs/pke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ where
SerializablePKEv1PublicParamsVersions: VersionsDispatch<SerializablePKEv1PublicParams>,
GroupElements<G>: Into<SerializableGroupElements>,
{
type Versioned<'vers> =
<SerializablePKEv1PublicParamsVersions as VersionsDispatch<
SerializablePKEv1PublicParams,
>>::Owned where G:'vers;
type Versioned<'vers>
= <SerializablePKEv1PublicParamsVersions as VersionsDispatch<
SerializablePKEv1PublicParams,
>>::Owned
where
G: 'vers;
fn versionize(&self) -> Self::Versioned<'_> {
VersionizeOwned::versionize_owned(SerializablePKEv1PublicParams::from(self.to_owned()))
}
Expand Down
10 changes: 6 additions & 4 deletions tfhe-zk-pok/src/proofs/pke_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ where
SerializablePKEv2PublicParamsVersions: VersionsDispatch<SerializablePKEv2PublicParams>,
GroupElements<G>: Into<SerializableGroupElements>,
{
type Versioned<'vers> =
<SerializablePKEv2PublicParamsVersions as VersionsDispatch<
SerializablePKEv2PublicParams,
>>::Owned where G:'vers;
type Versioned<'vers>
= <SerializablePKEv2PublicParamsVersions as VersionsDispatch<
SerializablePKEv2PublicParams,
>>::Owned
where
G: 'vers;
fn versionize(&self) -> Self::Versioned<'_> {
VersionizeOwned::versionize_owned(SerializablePKEv2PublicParams::from(self.to_owned()))
}
Expand Down
12 changes: 8 additions & 4 deletions tfhe/src/core_crypto/entities/ggsw_ciphertext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = GgswLevelMatrixCreationMetadata<Self::Element>;

type EntityView<'this> = GgswLevelMatrix<&'this [Self::Element]>
type EntityView<'this>
= GgswLevelMatrix<&'this [Self::Element]>
where
Self: 'this;

type SelfViewMetadata = ();

type SelfView<'this> = DummyCreateFrom
type SelfView<'this>
= DummyCreateFrom
where
Self: 'this;

Expand Down Expand Up @@ -815,11 +817,13 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for GgswCiphertext<C>
{
type EntityMutView<'this> = GgswLevelMatrix<&'this mut [Self::Element]>
type EntityMutView<'this>
= GgswLevelMatrix<&'this mut [Self::Element]>
where
Self: 'this;

type SelfMutView<'this> = DummyCreateFrom
type SelfMutView<'this>
= DummyCreateFrom
where
Self: 'this;
}
12 changes: 8 additions & 4 deletions tfhe/src/core_crypto/entities/ggsw_ciphertext_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = GgswCiphertextCreationMetadata<Self::Element>;

type EntityView<'this> = GgswCiphertextView<'this, Self::Element>
type EntityView<'this>
= GgswCiphertextView<'this, Self::Element>
where
Self: 'this;

type SelfViewMetadata = GgswCiphertextListCreationMetadata<Self::Element>;

type SelfView<'this> = GgswCiphertextListView<'this, Self::Element>
type SelfView<'this>
= GgswCiphertextListView<'this, Self::Element>
where
Self: 'this;

Expand Down Expand Up @@ -400,11 +402,13 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for GgswCiphertextList<C>
{
type EntityMutView<'this> = GgswCiphertextMutView<'this, Self::Element>
type EntityMutView<'this>
= GgswCiphertextMutView<'this, Self::Element>
where
Self: 'this;

type SelfMutView<'this> = GgswCiphertextListMutView<'this, Self::Element>
type SelfMutView<'this>
= GgswCiphertextListMutView<'this, Self::Element>
where
Self: 'this;
}
12 changes: 8 additions & 4 deletions tfhe/src/core_crypto/entities/glwe_ciphertext_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = GlweCiphertextCreationMetadata<Self::Element>;

type EntityView<'this> = GlweCiphertextView<'this, Self::Element>
type EntityView<'this>
= GlweCiphertextView<'this, Self::Element>
where
Self: 'this;

type SelfViewMetadata = GlweCiphertextListCreationMetadata<Self::Element>;

type SelfView<'this> = GlweCiphertextListView<'this, Self::Element>
type SelfView<'this>
= GlweCiphertextListView<'this, Self::Element>
where
Self: 'this;

Expand All @@ -295,11 +297,13 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for GlweCiphertextList<C>
{
type EntityMutView<'this> = GlweCiphertextMutView<'this, Self::Element>
type EntityMutView<'this>
= GlweCiphertextMutView<'this, Self::Element>
where
Self: 'this;

type SelfMutView<'this> = GlweCiphertextListMutView<'this, Self::Element>
type SelfMutView<'this>
= GlweCiphertextListMutView<'this, Self::Element>
where
Self: 'this;
}
24 changes: 16 additions & 8 deletions tfhe/src/core_crypto/entities/lwe_ciphertext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = LweBodyCreationMetadata<Self::Element>;

type EntityView<'this> = LweBodyRef<'this, Self::Element>
type EntityView<'this>
= LweBodyRef<'this, Self::Element>
where
Self: 'this;

type SelfViewMetadata = LweBodyListCreationMetadata<Self::Element>;

type SelfView<'this> = LweBodyListView<'this,Self::Element>
type SelfView<'this>
= LweBodyListView<'this, Self::Element>
where
Self: 'this;

Expand All @@ -208,11 +210,13 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for LweBodyList<C>
{
type EntityMutView<'this> = LweBodyRefMut<'this, Self::Element>
type EntityMutView<'this>
= LweBodyRefMut<'this, Self::Element>
where
Self: 'this;

type SelfMutView<'this> = LweBodyListMutView<'this, Self::Element>
type SelfMutView<'this>
= LweBodyListMutView<'this, Self::Element>
where
Self: 'this;
}
Expand Down Expand Up @@ -429,13 +433,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = LweMaskCreationMetadata<Self::Element>;

type EntityView<'this> = LweMask<&'this [Self::Element]>
type EntityView<'this>
= LweMask<&'this [Self::Element]>
where
Self: 'this;

type SelfViewMetadata = LweMaskListCreationMetadata<Self::Element>;

type SelfView<'this> = LweMaskListView<'this, Self::Element>
type SelfView<'this>
= LweMaskListView<'this, Self::Element>
where
Self: 'this;

Expand All @@ -460,11 +466,13 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for LweMaskList<C>
{
type EntityMutView<'this> = LweMask<&'this mut [Self::Element]>
type EntityMutView<'this>
= LweMask<&'this mut [Self::Element]>
where
Self: 'this;

type SelfMutView<'this> = LweMaskListMutView<'this,Self::Element>
type SelfMutView<'this>
= LweMaskListMutView<'this, Self::Element>
where
Self: 'this;
}
Expand Down
12 changes: 8 additions & 4 deletions tfhe/src/core_crypto/entities/lwe_ciphertext_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = LweCiphertextCreationMetadata<Self::Element>;

type EntityView<'this> = LweCiphertextView<'this, Self::Element>
type EntityView<'this>
= LweCiphertextView<'this, Self::Element>
where
Self: 'this;

type SelfViewMetadata = LweCiphertextListCreationMetadata<Self::Element>;

type SelfView<'this> = LweCiphertextListView<'this, Self::Element>
type SelfView<'this>
= LweCiphertextListView<'this, Self::Element>
where
Self: 'this;

Expand All @@ -346,11 +348,13 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for LweCiphertextList<C>
{
type EntityMutView<'this> = LweCiphertextMutView<'this, Self::Element>
type EntityMutView<'this>
= LweCiphertextMutView<'this, Self::Element>
where
Self: 'this;

type SelfMutView<'this> = LweCiphertextListMutView<'this, Self::Element>
type SelfMutView<'this>
= LweCiphertextListMutView<'this, Self::Element>
where
Self: 'this;
}
12 changes: 8 additions & 4 deletions tfhe/src/core_crypto/entities/lwe_keyswitch_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = LweCiphertextListCreationMetadata<Self::Element>;

type EntityView<'this> = LweCiphertextListView<'this, Self::Element>
type EntityView<'this>
= LweCiphertextListView<'this, Self::Element>
where
Self: 'this;

type SelfViewMetadata = LweKeyswitchKeyCreationMetadata<Self::Element>;

type SelfView<'this> = LweKeyswitchKeyView<'this, Self::Element>
type SelfView<'this>
= LweKeyswitchKeyView<'this, Self::Element>
where
Self: 'this;

Expand Down Expand Up @@ -422,11 +424,13 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for LweKeyswitchKey<C>
{
type EntityMutView<'this> = LweCiphertextListMutView<'this, Self::Element>
type EntityMutView<'this>
= LweCiphertextListMutView<'this, Self::Element>
where
Self: 'this;

type SelfMutView<'this> = LweKeyswitchKeyMutView<'this, Self::Element>
type SelfMutView<'this>
= LweKeyswitchKeyMutView<'this, Self::Element>
where
Self: 'this;
}
Expand Down
5 changes: 4 additions & 1 deletion tfhe/src/core_crypto/entities/lwe_multi_bit_bootstrap_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@ impl<C: IntoContainerOwned<Element = c64>> TryFrom<FourierLweMultiBitBootstrapKe
}

impl<C: Container<Element = c64>> Versionize for FourierLweMultiBitBootstrapKey<C> {
type Versioned<'vers> = FourierLweMultiBitBootstrapKeyVersioned<'vers> where C: 'vers;
type Versioned<'vers>
= FourierLweMultiBitBootstrapKeyVersioned<'vers>
where
C: 'vers;

fn versionize(&self) -> Self::Versioned<'_> {
self.into()
Expand Down
12 changes: 8 additions & 4 deletions tfhe/src/core_crypto/entities/lwe_packing_keyswitch_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,17 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = GlweCiphertextListCreationMetadata<Self::Element>;

type EntityView<'this> = GlweCiphertextListView<'this, Self::Element>
type EntityView<'this>
= GlweCiphertextListView<'this, Self::Element>
where
Self: 'this;

type SelfViewMetadata = ();

// At the moment it does not make sense to return "sub" keyswitch keys. So we use a dummy
// placeholder type here.
type SelfView<'this> = DummyCreateFrom
type SelfView<'this>
= DummyCreateFrom
where
Self: 'this;

Expand Down Expand Up @@ -387,13 +389,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for LwePackingKeyswitchKey<C>
{
type EntityMutView<'this> = GlweCiphertextListMutView<'this, Self::Element>
type EntityMutView<'this>
= GlweCiphertextListMutView<'this, Self::Element>
where
Self: 'this;

// At the moment it does not make sense to return "sub" keyswitch keys. So we use a dummy
// placeholder type here.
type SelfMutView<'this> = DummyCreateFrom
type SelfMutView<'this>
= DummyCreateFrom
where
Self: 'this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,15 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo

type EntityViewMetadata = GlweCiphertextListCreationMetadata<Self::Element>;

type EntityView<'this> = GlweCiphertextListView<'this, Self::Element>
type EntityView<'this>
= GlweCiphertextListView<'this, Self::Element>
where
Self: 'this;

type SelfViewMetadata = LwePrivateFunctionalPackingKeyswitchKeyCreationMetadata<Self::Element>;

type SelfView<'this> = LwePrivateFunctionalPackingKeyswitchKeyView<'this, Self::Element>
type SelfView<'this>
= LwePrivateFunctionalPackingKeyswitchKeyView<'this, Self::Element>
where
Self: 'this;

Expand Down Expand Up @@ -473,11 +475,13 @@ impl<Scalar: UnsignedInteger, C: Container<Element = Scalar>> ContiguousEntityCo
impl<Scalar: UnsignedInteger, C: ContainerMut<Element = Scalar>> ContiguousEntityContainerMut
for LwePrivateFunctionalPackingKeyswitchKey<C>
{
type EntityMutView<'this> = GlweCiphertextListMutView<'this, Self::Element>
type EntityMutView<'this>
= GlweCiphertextListMutView<'this, Self::Element>
where
Self: 'this;

type SelfMutView<'this> = LwePrivateFunctionalPackingKeyswitchKeyMutView<'this, Self::Element>
type SelfMutView<'this>
= LwePrivateFunctionalPackingKeyswitchKeyMutView<'this, Self::Element>
where
Self: 'this;
}
Expand Down
Loading

0 comments on commit 39e3291

Please sign in to comment.