Expand description
A combinator representing two protocols as a new protocol that, when executed, executes the two inner protocols in sequence, feeding the result of the first protocol into the inputs of the second protocol.
For the session level users (that is, the ones executing the protocols)
the new protocol is a single entity with its own Protocol
-implementing type
and an EntryPoint
-implementing type.
For example, imagine we have a ProtocolA
with an entry point EntryPointA
,
two rounds, RA1
and RA2
, and the result ResultA
;
and similarly a ProtocolB
with an entry point EntryPointB
,
two rounds, RB1
and RB2
, and the result ResultB
.
Then the chained protocol will have a ProtocolC: Protocol
type and an EntryPointC: EntryPoint
type,
and the execution will look like:
EntryPointC
is initialized by the user with whatever constructor it may have;- Internally,
EntryPointA
is created fromEntryPointC
using theChainedSplit
implementation provided by the protocol author; RA1
is executed;RA2
is executed, producingResultA
;- Internally,
EntryPointB
is created fromResultA
and the data created inChainedSplit::make_entry_point1
using theChainedJoin
implementation provided by the protocol author; RB1
is executed;RB2
is executed, producingResultB
(which is also the result ofProtocolC
).
If the execution happens in a Session
, and there is an error at any point,
a regular evidence or correctness proof are created using the corresponding types from the new ProtocolC
.
Usage:
-
Implement
ChainedProtocol
for a type of your choice. Usually it will be a ZST. You will have to specify the two protocol types you want to chain. -
Implement the marker trait
ChainedMarker
for this type. This will activate the blanket implementation ofProtocol
for it. The marker trait is needed to disambiguate different generic blanket implementations. -
Define an entry point type for the new joined protocol. Most likely it will contain a union between the required data for the entry point of the first and the second protocol.
-
Implement
ChainedSplit
andChainedJoin
for the new entry point. -
Implement the marker trait
ChainedMarker
for this type. Same as with the protocol, this is needed to disambiguate different generic blanket implementations. -
ChainedAssociatedData
is the structure used to supply associated data when verifying evidence from the chained protocol.
Structs§
- Chained
Associated Data - Associated data for verification of malicious behavior evidence in the chained protocol.
Enums§
- Chained
Protocol Error - The protocol error type for the chained protocol.
Traits§
- Chained
Join - A trait defining how the data created in
ChainedSplit::make_entry_point1
will be joined with the result of the first protocol to create an entry point for the second protocol. - Chained
Marker - A marker trait that is used to disambiguate blanket trait implementations for
Protocol
andEntryPoint
. - Chained
Protocol - A trait defining two protocols executed sequentially.
- Chained
Split - A trait defining how the entry point for the whole chained protocol will be split into the entry point for the first protocol, and a piece of data that, along with the first protocol’s result, will be used to create the entry point for the second protocol.