pub struct StatisticalPrivacyEngine { /* private fields */ }Expand description
Statistical privacy engine
Implementations§
Source§impl StatisticalPrivacyEngine
impl StatisticalPrivacyEngine
pub fn new() -> Self
pub fn initialize(&mut self) -> Result<(), StatisticalError>
pub fn add_laplace_noise( &mut self, value: f64, sensitivity: f64, ) -> Result<(f64, f64), StatisticalError>
pub fn add_histogram_noise( &mut self, counts: &[u32], ) -> Result<(Vec<u32>, f64), StatisticalError>
Sourcepub fn encrypt_result(&self, data: &[u8]) -> Result<Vec<u8>, StatisticalError>
pub fn encrypt_result(&self, data: &[u8]) -> Result<Vec<u8>, StatisticalError>
Encrypt (seal) a statistical result using the fiduciary crypto system.
FiduciaryCrypto exposes ML-DSA (FIPS-204) signing rather than symmetric
encryption, so “encryption” here means producing an authenticated
signature over the result bytes. The returned bytes are the ML-DSA
signature; a holder of the public key can verify that the result was
produced by this engine and has not been tampered with. A default
signing key is generated lazily on first use.
Sourcepub fn verify_result(
&self,
data: &[u8],
signature: &[u8],
) -> Result<bool, StatisticalError>
pub fn verify_result( &self, data: &[u8], signature: &[u8], ) -> Result<bool, StatisticalError>
Verify (open) a statistical result sealed by encrypt_result.
Returns Ok(true) when the signature is valid for data under the
engine’s statistical-results key.
Sourcepub fn prove_computation(
&self,
computation_id: &str,
inputs: &[Vec<u8>],
outputs: &[Vec<u8>],
) -> Result<Vec<u8>, StatisticalError>
pub fn prove_computation( &self, computation_id: &str, inputs: &[Vec<u8>], outputs: &[Vec<u8>], ) -> Result<Vec<u8>, StatisticalError>
Generate a zero-knowledge proof that a statistical computation was performed correctly.
The proof binds the private inputs and public outputs together: a
SHA-256 commitment over all inputs/outputs becomes a private witness,
and the same commitment is exposed as the single public input. The
circuit enforces one * commitment = commitment, so a verifying party
learns only that the prover knows the commitment bound to the published
outputs — not the inputs themselves. The returned bytes are a
serde_json-serialised ZkProof (which carries its own public inputs),
so it can be verified by verify_computation without extra state.
Sourcepub fn verify_computation(
&self,
proof: &[u8],
public_inputs: &[Vec<u8>],
) -> Result<bool, StatisticalError>
pub fn verify_computation( &self, proof: &[u8], public_inputs: &[Vec<u8>], ) -> Result<bool, StatisticalError>
Verify a zero-knowledge computation proof produced by prove_computation.
proof is the serialised ZkProof bytes. When public_inputs is
non-empty, each entry is interpreted as a 32-byte little-endian field
element and checked against the public inputs embedded in the proof, so
callers can confirm the proof binds to the outputs they expect.
Auto Trait Implementations§
impl Freeze for StatisticalPrivacyEngine
impl RefUnwindSafe for StatisticalPrivacyEngine
impl Send for StatisticalPrivacyEngine
impl Sync for StatisticalPrivacyEngine
impl Unpin for StatisticalPrivacyEngine
impl UnsafeUnpin for StatisticalPrivacyEngine
impl UnwindSafe for StatisticalPrivacyEngine
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more