Skip to content

Commit

Permalink
address review
Browse files Browse the repository at this point in the history
  • Loading branch information
albertpl committed Oct 10, 2023
1 parent 7342b68 commit 3b28f0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 deletions.
6 changes: 3 additions & 3 deletions poc/flp_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,9 @@ def test_encode_truncate_decode(flp, measurements):


def test_encode_truncate_decode_with_fft_fields(cls, measurements, *args):
for _field in [field.Field64, field.Field96, field.Field128]:
cls_with_field = cls.with_field(_field)
assert cls_with_field.Field == _field
for f in [field.Field64, field.Field96, field.Field128]:
cls_with_field = cls.with_field(f)
assert cls_with_field.Field == f
obj = cls_with_field(*args)
assert isinstance(obj, cls)
test_encode_truncate_decode(FlpGeneric(obj), measurements)
Expand Down
37 changes: 12 additions & 25 deletions poc/vdaf_prio3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xof
from common import (ERR_INPUT, ERR_VERIFY, TEST_VECTOR, Unsigned, byte, concat,
front, vec_add, vec_sub, zeros)
from field import FftField, Field64, Field96, Field128
from field import FftField, Field64
from vdaf import Vdaf, test_vdaf

USAGE_MEAS_SHARE = 1
Expand All @@ -32,7 +32,7 @@ class Prio3(Vdaf):
RAND_SIZE = None # Computed from `Xof.SEED_SIZE` and `SHARES`
ROUNDS = 1
SHARES = None # A number between `[2, 256)` set later
PROOFS = 1 # Number of proofs
PROOFS = 1 # Number of proofs, default to 1, otherwise see `Prio3SumVecWithMultiproof.is_recommended`

# Types required by `Vdaf`
Measurement = Flp.Measurement
Expand Down Expand Up @@ -520,24 +520,13 @@ class Prio3SumVecWithMultiproof(Prio3SumVec):
def is_recommended(valid_cls,
num_proofs: Unsigned,
field: FftField) -> bool:
if num_proofs >= 0x100:
# We encode this as one byte while deriving joing rands
return False
# TODO(issue#177) Decide how many proofs to use for each field type.
# TODO(issue#177) Decide how many proofs to use.
if field == Field64:
return num_proofs >= 2
elif field == Field96:
return num_proofs >= 2
elif field == Field128:
return num_proofs >= 1
# the upper bound is due to the fact
# we encode it using one byteb in `joint_rands`
return 2 <= num_proofs < 0x100
return False

@staticmethod
def algorithm_id_from(num_proofs: Unsigned,
field: FftField) -> Unsigned:
# To be confirmed
return 0xFFFFFFFF

@classmethod
def with_params(cls,
length: Unsigned,
Expand All @@ -549,10 +538,9 @@ def with_params(cls,
if not cls.is_recommended(valid_cls, num_proofs, field):
raise ValueError("parameters not recommended")

algorithm_id = cls.algorithm_id_from(num_proofs, field)

class Prio3SumVecWithMultiproofAndParams(cls):
ID = algorithm_id
# Associated parameters.
ID = 0xFFFFFFFF
PROOFS = num_proofs
Flp = flp_generic.FlpGeneric(valid_cls(length, bits, chunk_length))
return Prio3SumVecWithMultiproofAndParams
Expand Down Expand Up @@ -583,8 +571,8 @@ class TestPrio3AverageWithBits(TestPrio3Average):

def _test_prio3sumvec(num_proofs: Unsigned, field: FftField):
valid_cls = flp_generic.SumVec.with_field(field)
if not Prio3SumVecWithMultiproof.is_recommended(valid_cls, num_proofs, field):
return
assert Prio3SumVecWithMultiproof.is_recommended(
valid_cls, num_proofs, field)

cls = Prio3SumVecWithMultiproof \
.with_params(10, 8, 9, num_proofs=num_proofs, field=field) \
Expand Down Expand Up @@ -626,9 +614,8 @@ def _test_prio3sumvec(num_proofs: Unsigned, field: FftField):


def test_prio3sumvec_with_multiproof():
for n in range(1, 5):
for f in [Field64, Field96, Field128]:
_test_prio3sumvec(num_proofs=n, field=f)
for n in range(2, 5):
_test_prio3sumvec(num_proofs=n, field=Field64)


if __name__ == '__main__':
Expand Down

0 comments on commit 3b28f0f

Please sign in to comment.