Skip to content

Commit

Permalink
Use generic reveal
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleiserson committed Aug 19, 2024
1 parent 403cf27 commit e3396bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
7 changes: 5 additions & 2 deletions ipa-core/src/protocol/ipa_prf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
ff::{
boolean::Boolean,
boolean_array::{BooleanArray, BA5, BA64, BA8},
curve_points::RP25519,
ec_prime_field::Fp25519,
Serializable, U128Conversions,
},
Expand All @@ -18,7 +19,7 @@ use crate::{
TotalRecords,
},
protocol::{
basics::{BooleanArrayMul, BooleanProtocols},
basics::{BooleanArrayMul, BooleanProtocols, Reveal},
context::{
Context, DZKPUpgraded, DZKPUpgradedSemiHonestContext, MacUpgraded, SemiHonestContext,
UpgradableContext, UpgradedSemiHonestContext,
Expand All @@ -35,7 +36,7 @@ use crate::{
},
secret_sharing::{
replicated::semi_honest::AdditiveShare as Replicated, BitDecomposed, FieldSimd,
SharedValue, TransposeFrom,
SharedValue, TransposeFrom, Vectorizable,
},
seq_join::seq_join,
sharding::NotSharded,
Expand Down Expand Up @@ -303,6 +304,8 @@ where
Replicated<Boolean, CONV_CHUNK>: BooleanProtocols<DZKPUpgraded<C>, CONV_CHUNK>,
Replicated<Fp25519, PRF_CHUNK>:
PrfSharing<MacUpgraded<C, Fp25519>, PRF_CHUNK, Field = Fp25519> + FromPrss,
Replicated<RP25519, PRF_CHUNK>:
Reveal<MacUpgraded<C, Fp25519>, Output = <RP25519 as Vectorizable<PRF_CHUNK>>::Array>,
{
let conv_records =
TotalRecords::specified(div_round_up(input_rows.len(), Const::<CONV_CHUNK>))?;
Expand Down
19 changes: 9 additions & 10 deletions ipa-core/src/protocol/ipa_prf/prf_eval.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::iter::zip;

use futures::future::try_join;
use futures_util::FutureExt;

use crate::{
error::Error,
ff::{curve_points::RP25519, ec_prime_field::Fp25519},
protocol::{
basics::{malicious_reveal, reveal, SecureMul},
basics::{reveal, Reveal, SecureMul},
context::{
upgrade::Upgradable, UpgradableContext, UpgradedContext, UpgradedMaliciousContext,
UpgradedSemiHonestContext,
Expand Down Expand Up @@ -103,6 +102,7 @@ pub async fn eval_dy_prf<C, const N: usize>(
where
C: UpgradedContext<Field = Fp25519>,
AdditiveShare<Fp25519, N>: PrfSharing<C, N, Field = Fp25519>,
AdditiveShare<RP25519, N>: Reveal<C, Output = <RP25519 as Vectorizable<N>>::Array>,
Fp25519: FieldSimd<N>,
RP25519: Vectorizable<N>,
{
Expand All @@ -129,10 +129,7 @@ where
<RP25519 as Vectorizable<N>>::Array,
<Fp25519 as Vectorizable<N>>::Array,
) = try_join(
// TODO: these should invoke reveal via the trait when this function
// takes a context of an appropriate type.
malicious_reveal(ctx.narrow(&Step::RevealR), record_id, None, &sh_gr)
.map(|v| v.map(|arr| arr.unwrap())),
reveal(ctx.narrow(&Step::RevealR), record_id, &sh_gr),
reveal(ctx.narrow(&Step::Revealz), record_id, &y),
)
.await?;
Expand All @@ -155,13 +152,14 @@ mod test {
ff::{curve_points::RP25519, ec_prime_field::Fp25519},
helpers::{in_memory_config::MaliciousHelper, Role},
protocol::{
context::{Context, UpgradableContext, Validator},
basics::Reveal,
context::{Context, MacUpgraded, UpgradableContext, Validator},
ipa_prf::{
prf_eval::{eval_dy_prf, PrfSharing},
step::PrfStep,
},
},
secret_sharing::{replicated::semi_honest::AdditiveShare, IntoShares},
secret_sharing::{replicated::semi_honest::AdditiveShare, IntoShares, Vectorizable},
test_executor::run,
test_fixture::{Reconstruct, Runner, TestWorld, TestWorldConfig},
};
Expand All @@ -179,8 +177,9 @@ mod test {
) -> Result<Vec<u64>, Error>
where
C: UpgradableContext,
AdditiveShare<Fp25519>:
PrfSharing<<C::Validator<Fp25519> as Validator<Fp25519>>::Context, 1, Field = Fp25519>,
AdditiveShare<Fp25519>: PrfSharing<MacUpgraded<C, Fp25519>, 1, Field = Fp25519>,
AdditiveShare<RP25519>:
Reveal<MacUpgraded<C, Fp25519>, Output = <RP25519 as Vectorizable<1>>::Array>,
{
let ctx = ctx.set_total_records(input_match_keys.len());
let validator = ctx.validator::<Fp25519>();
Expand Down

0 comments on commit e3396bd

Please sign in to comment.