Skip to content

Commit

Permalink
Ping-pong topology fixes
Browse files Browse the repository at this point in the history
A handful of fixes to the specification of the ping-pong aggregator
communication topology encountered during implementation.

 - Explicitly describe Python objects for ping-pong State
 - `ping_pong_leader_init` and `_helper_init` return `Message`, not `bytes`
 - `ping_pong_transition` always returns a `Message`
 - typo in `ping_pong_transition`
 - `ping_pong_continued` fails if `state` is not `Continued`
 - remove unused `is_leader` parameter from `ping_pong_transition`
  • Loading branch information
tgeoghegan committed Aug 18, 2023
1 parent e4478dd commit ac50c50
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions draft-irtf-cfrg-vdaf.md
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,29 @@ struct {
} Message;
~~~

These messages are used to transition between the states described in
{{vdaf-prep-comm}, more specifically structured as follows:

~~~
class State:
pass

class Continued(State):
def __init__(self, prep_state):
self.prep_state = prep_state

class Finished(State):
def __init__(self, output_share):
self.output_share = output_share

class Rejected(State):
def __init__(self):
pass
~~~

Note that there is no representation of the `Start` state as it is never
instantiated in the ping-pong topology.

The Leader's initial transition is computed with the following procedure:

~~~ transition
Expand All @@ -1332,7 +1355,7 @@ def ping_pong_leader_init(
nonce: bytes[Vdaf.NONCE_SIZE],
public_share: bytes,
input_share: bytes,
) -> tuple[State, bytes]:
) -> tuple[State, Message]:
try:
(prep_state, prep_share) = Vdaf.prep_init(
vdaf_verify_key,
Expand Down Expand Up @@ -1364,7 +1387,7 @@ def ping_pong_helper_init(
public_share: bytes,
input_share: bytes,
inbound: Message,
) -> tuple[State, bytes]:
) -> tuple[State, Message]:
try:
(prep_state, prep_share) = Vdaf.prep_init(
vdaf_verify_key,
Expand Down Expand Up @@ -1400,7 +1423,7 @@ def ping_pong_transition(
agg_param: Vdaf.AggParam,
prep_shares: list[Vdaf.PrepShare],
prep_state: Vdaf.PrepState,
) -> (State, Optional[Message]):
) -> (State, Message):
prep_msg = Vdaf.prep_shares_to_prep(agg_param,
prep_shares)
out = Vdaf.prep_next(prep_state, prep_msg)
Expand All @@ -1410,7 +1433,7 @@ def ping_pong_transition(
(prep_state, prep_share) = out
outbound = Message.continue(
Vdaf.encode_prep_msg(prep_msg),
Vdaf.encdoe_prep_share(prep_share),
Vdaf.encode_prep_share(prep_share),
)
return (Continued(prep_state), outbound)
~~~
Expand All @@ -1434,6 +1457,9 @@ def ping_pong_continued(
if inbound.type == 0: # initialize
return (Rejected(), None)

if !isinstance(state, Continued):
return (Rejected(), None)

prep_msg = Vdaf.decode_prep_msg(state.prep_state, inbound.prep_msg)
out = Vdaf.prep_next(state.prep_state, prep_msg)
if type(out) == tuple[Vdaf.PrepState, Vdaf.PrepShare] \
Expand All @@ -1447,9 +1473,8 @@ def ping_pong_continued(
if is_leader:
prep_shares.reverse()
return Vdaf.ping_pong_transition(
is_leader,
agg_param,
prep_shares
prep_shares,
prep_state,
)
elif type(out) == Vdaf.OutShare and inbound.type == 2:
Expand Down

0 comments on commit ac50c50

Please sign in to comment.