Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions polyfuzzy/src/fmd2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
DetectionKey, FmdKeyGen, FmdSecretKey, MultiFmdScheme,
};

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
/// γ public subkeys (points). The basepoint is hardcoded to the Ristretto basepoint.
pub struct FmdPublicKey {
Expand All @@ -31,7 +31,7 @@ impl From<GenericFmdPublicKey> for FmdPublicKey {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
/// A point `u`, a scalar `y`, and γ ciphertext bits `c`.
pub struct FlagCiphertexts {
Expand Down Expand Up @@ -59,7 +59,7 @@ impl From<GenericFlagCiphertexts> for FlagCiphertexts {
}

/// The multi-key scheme.
#[derive(Debug, Clone)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Fmd2MultikeyScheme {
gamma: usize,
}
Expand Down
13 changes: 7 additions & 6 deletions polyfuzzy/src/fmd2_compact/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
};

/// A polynomial over the scalar field of Ristretto of degree = `t` (the threshold parameter).
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct CompactSecretKey(Polynomial);

Expand All @@ -33,7 +34,7 @@ impl CompactSecretKey {
/// An encoded polynomial over Ristretto. t+2 points.
/// The first point is the basepoint, the remaining
/// t+1 points the encoded coefficients.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CompactPublicKey {
fingerprint: [u8; 20],
polynomial: EncodedPolynomial,
Expand Down Expand Up @@ -73,7 +74,7 @@ impl CompactPublicKey {

/// A compressed representation that drops the basepoint.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CompressedCompactPublicKey {
coeffs: Vec<RistrettoPoint>,
}
Expand All @@ -90,13 +91,13 @@ impl CompressedCompactPublicKey {

/// The evaluations of the secret polynomial
/// encoded using an arbitrary basepoint.
#[derive(PartialEq, Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FmdPublicKey(PointEvaluations);

/// The basepoint for the chamaleon hash,
/// and `u`, `y`, `c`.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FlagCiphertexts(GenericFlagCiphertexts);

impl FlagCiphertexts {
Expand All @@ -108,7 +109,7 @@ impl FlagCiphertexts {
}

/// Cache of expanded FMD public keys.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
struct ExpandedKeyCache {
/// Fingerprint of the [`CompactPublicKey`].
fingerprint: [u8; 20],
Expand All @@ -134,7 +135,7 @@ impl ExpandedKeyCache {
}

/// The multi-key FMD scheme supporting key expansion and key randomization.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MultiFmd2CompactScheme {
/// The threshold parameter
threshold: usize,
Expand Down
6 changes: 4 additions & 2 deletions polyfuzzy/src/fmd2_compact/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,30 @@ use curve25519_dalek::{RistrettoPoint, Scalar};
use serde::{Deserialize, Serialize};

/// A degree `t` polynomial p(X) in Z_q[X] given by its t+1 coefficients.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub(crate) struct Polynomial {
coeffs: Vec<Scalar>,
}

/// A degree t polynomial encoded in the exponent of a Ristretto point
/// given by its t+1 points.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct EncodedPolynomial {
pub(crate) basepoint: RistrettoPoint,
pub(crate) coeffs: Vec<RistrettoPoint>,
}

/// γ scalar evaluations of the polynomial p(X) at public scalars.
/// result[i] = p(public_scalar[i])
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub(crate) struct ScalarEvaluations {
pub(crate) results: Vec<Scalar>,
}

/// γ point evaluations of the polynomial p(X) at public scalars.
/// result[i] = p(public_scalar[i]) * basepoint
#[derive(PartialEq, Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct PointEvaluations {
pub(crate) basepoint: RistrettoPoint,
pub(crate) results: Vec<RistrettoPoint>,
Expand Down
13 changes: 7 additions & 6 deletions polyfuzzy/src/fmd2_generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256, Sha512};

/// Compressed representation of the γ bit-ciphertexts of a [`GenericFlagCiphertexts`].
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub(crate) struct CompressedCiphertextBits(pub(crate) Vec<u8>);

Expand All @@ -31,7 +31,7 @@ impl CompressedCiphertextBits {
}

/// Decompressed inner bit-ciphertexts of a [`GenericFlagCiphertexts`].
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub(crate) struct CiphertextBits(pub(crate) Vec<bool>);

Expand All @@ -55,7 +55,7 @@ impl CiphertextBits {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
/// γ secret subkeys (scalars). For minimum false-positive rate p:=2^{-γ}.
pub struct FmdSecretKey(pub(crate) Vec<Scalar>);
Expand Down Expand Up @@ -135,7 +135,7 @@ impl FmdSecretKey {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
/// A subset of n-out-γ secret subkeys, and the positions
/// they occupy in [FmdSecretKey].
Expand Down Expand Up @@ -193,12 +193,13 @@ impl DetectionKey {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct GenericFmdPublicKey {
pub(crate) basepoint_eg: RistrettoPoint, // Basepoint to generate the DDH mask (for ElGamal).
pub(crate) keys: Vec<RistrettoPoint>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ChamaleonHashBasepoint {
base: RistrettoPoint, // Basepoint for the Chamaleon Hash.
dlog: Scalar, // Discrete log of `basepoint_ch` in base `GenericPublicKey.basepoint_eg`.
Expand All @@ -222,7 +223,7 @@ impl Default for ChamaleonHashBasepoint {
}
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub(crate) struct GenericFlagCiphertexts {
pub(crate) basepoint_ch: RistrettoPoint, // Basepoint for the Chamaleon Hash.
Expand Down