Module chain

Source
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 from EntryPointC using the ChainedSplit implementation provided by the protocol author;
  • RA1 is executed;
  • RA2 is executed, producing ResultA;
  • Internally, EntryPointB is created from ResultA and the data created in ChainedSplit::make_entry_point1 using the ChainedJoin implementation provided by the protocol author;
  • RB1 is executed;
  • RB2 is executed, producing ResultB (which is also the result of ProtocolC).

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:

  1. 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.

  2. Implement the marker trait ChainedMarker for this type. This will activate the blanket implementation of Protocol for it. The marker trait is needed to disambiguate different generic blanket implementations.

  3. 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.

  4. Implement ChainedSplit and ChainedJoin for the new entry point.

  5. Implement the marker trait ChainedMarker for this type. Same as with the protocol, this is needed to disambiguate different generic blanket implementations.

  6. ChainedAssociatedData is the structure used to supply associated data when verifying evidence from the chained protocol.

Structs§

ChainedAssociatedData
Associated data for verification of malicious behavior evidence in the chained protocol.

Enums§

ChainedProtocolError
The protocol error type for the chained protocol.

Traits§

ChainedJoin
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.
ChainedMarker
A marker trait that is used to disambiguate blanket trait implementations for Protocol and EntryPoint.
ChainedProtocol
A trait defining two protocols executed sequentially.
ChainedSplit
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.