Proto commits in xaya/libxayagame

These 23 commits are when the Protocol Buffers files have changed:

Commit:2f78088
Author:Daniel Kraft
Committer:Daniel Kraft

Abstract message signing in game channels. This introduces two interfaces (SignatureVerifier and SignatureSigner), which abstract message signing done in the game-channel code away from directly using the Xaya Core RPCs. This allows for making the underlying game-channel code "more pure", and also e.g. to implement other signing schemes and wallets, for instance for Ethereum-based chains. With this change, we introduce implementations of those interfaces still based on the Xaya Core RPC endpoints with verifymessage/signmessage, so that functionality is not changed. But now the direct use of the RPC connection is pushed up from "basically all code" to just the top-level class (ChannelGame for the GSP and Daemon for the channel-daemon), where the RPC-based implementations are instantiated. The design choice made for the signer is that it is aware of a particular address that it can sign for (as it is tied to a particular participant). This means that now the participant's signing address needs to be passed when starting the channel daemon in addition to just the player name (as the channel may not yet be on-chain initially so it can't be taken from there), but this is a minor issue.

The documentation is generated from this commit.

Commit:e78cff1
Author:Daniel Kraft

Remove now unused proto imports. Now that the winner-statement has been removed from the ships game flow, we don't need signatures in the board state/move protos anymore.

Commit:a2efa92
Author:Daniel Kraft
Committer:Daniel Kraft

Remove winner statement completely. This removes all traces of the winner statement from Xayaships, including from the board rules, auto moves and on-chain move processing (for closing a channel with a winner statement). The board game concludes now (switches to a no-turn situation) as soon as the winner has been determined. At this step, it is expected (and implemented in the default auto-move rules) that the loser declares loss on-chain to close the channel. If they don't, then the winner can use the dispute/resolution mechanism to force-close. (The latter does not work 100% right now, but will be fixed soon.)

Commit:c8bffda
Author:Daniel Kraft

Implement HasAnyUnknownFields. Add a utility function that checks recursively if a protocol buffer message contains any unknown fields (directly or in a nested submessage). This will be used to enforce that protos parsed from external input do not have any, in order to avoid issues with bad data in the blockchcain that prevents future proto upgrades. For more details, see https://github.com/xaya/libxayagame/issues/49.

Commit:0c79562
Author:Daniel Kraft

Rename protoboardtests to testprotos. We will have more protocol buffer definitions for the unit tests in the future, for instance to test handling of unknown fields when parsing protocol buffers. Having one file defining all protocol buffers needed for unit tests only makes sense, rather than multiple files. But then it should be named in a suitable way to avoid confusion.

Commit:9e5a711
Author:Daniel Kraft
Committer:Daniel Kraft

Functions to version game-channel protos. This adds functions to explicitly check game-channel protocol buffer messages (in particular, SignedData and StateProof) against well-defined versions. Games can use those after obtaining such a proto e.g. from a move to ensure that the upgrade path (i.e. forks in the consensus code) is well defined for them.

Commit:8ad7f12
Author:Daniel Kraft

Add custom field to channel metadata. The new field "custom" can be used by games to hold their own data needed to determine channel details. For instance, they can store what participants agreed upon when opening the channel, e.g. the amount of money the game is for, or some special rules / "parameters". It can also be used in case of forks in the game logic to determine what rules (pre- / post-fork) should be applied for this particular channel (so it is fixed during creation). This will be useful to tackle https://github.com/xaya/libxayagame/issues/49 for board state protos.

Commit:1b2be8c
Author:Daniel Kraft
Committer:Daniel Kraft

Use bytes for reinit in RPC broadcast. The reinit field in an RPC broadcast message will hold arbitrary bytes, so we should use the proto "bytes" type instead of "string".

Commit:d4b1b2d
Author:Daniel Kraft
Committer:Daniel Kraft

General logic for broadcast system. This replaces the OffChainBroadcast interface with a class that will be the basis for real broadcast implementations. It has general logic that is shared, and defines the interface that concrete implementations of a broadcast system have to implement. This is the main step for https://github.com/xaya/libxayagame/issues/59 (with the remaining piece being implementing a concrete broadcast system based on a server).

Commit:75a3e37
Author:Daniel Kraft

Use reinit state as basis for state proofs. Instead of using the latest on-chain state as "basis" for verifying state proofs, use the channel's reinit state. These states are fixed, so that state proofs cannot be invalidated easily (for more details, see also https://github.com/xaya/libxayagame/issues/54). Note that this also means that "most" state proofs will need to be fully signed, and only proofs for the very first states in a game can ever have fewer signatures because of being based on the initial state.

Commit:67b0e08
Author:Daniel Kraft

Hash reinit ID into signatures. When constructing and verifying signatures made for a channel, also hash the current reinit ID into the message. This is further protection against potential replay attacks and ensures that signatures are only valid in the channel's state for which they were intended.

Commit:abd8515
Author:Daniel Kraft

Add reinitialisation ID to channel metadata. This introduces the concept of a "reinitialisation ID", which is added to the metadata of a channel. Whenever the channel's metadata changes through some on-chain action (e.g. someone joins the channel) and thus the channel game is reinitialised, this ID should be updated. In a follow-up, we will make sure this ID gets hashed into signatures (like the channel ID itself) to prevent potential replay attacks. The ID can also be used to verify for what "revision" of a channel some state proof is and thus apply it correctly when managing off-chain data relayed for a channel.

Commit:00558c0
Author:Daniel Kraft
Committer:Daniel Kraft

Add TurnCount implementation for ships. Implement TurnCount in the ships board rules. The tests that apply moves are extended to verify that the turn count always increments by exactly one for each turn. (This is not strictly necessary to be the case, but we can do it for ships easily and thus it simplifies things.)

Commit:9d7e425
Author:Daniel Kraft
Committer:Daniel Kraft

Detailed definition of xayaships board rules. This defines the board rules and state format for the Xayaships game in detail. The exact sequence of moves is described in the README (in addition to the game overview description), and the protocol buffers for the board state and moves are defined.

Commit:aadab7a
Author:Daniel Kraft
Committer:Daniel Kraft

Utility templates for board states as protos. This introduces two utility template classes, ProtoBoardState and ProtoBoardRules. They are implementations of ParsedBoardState and BoardRules, respectively, for situations where the encoded states and moves are serialised protocol buffers. The serialisation/deserialisation is handled by the classes, so that concrete games only have to implement their logic for the actual protocol buffer instances.

Commit:dd14c8c
Author:Daniel Kraft

Include channel ID and topic in data signatures. When verifying signatures of channel participants for certain data, include also the channel ID and a "topic" (describing what the data is) in the hash that gets signed. By doing that, we make sure that no replay attacks against other channels can be made, and also not e.g. signed states can be mistaken as signed winner statements or something like that.

Commit:d5f7018
Author:Daniel Kraft
Committer:Daniel Kraft

Structure gamechannel proto files correctly. Make sure that the canonical names of the gamechannel protocol buffer files are correct, so that they can be used from other directories as well (as they are intended to be). See: https://stackoverflow.com/questions/38390260/import-and-usage-of-different-package-files-in-protobuf

Commit:56feba2
Author:Daniel Kraft

Move gamechannel protos to "proto" namespace. Define the gamechannel protocol buffers in package "xaya.proto", so that they are in the xaya::proto C++ namespace. This separates them off from the "real" C++ classes, so that it is immediately apparent what is a protocol buffer. This is also consistent now with the protocol buffers for mover.

Commit:f10bb57
Author:Daniel Kraft

Move gamechannel protos to subdirectory. Move the .proto files as well as the generated code for them to gamechannel/proto. This separates the code more cleanly, especially with respect to e.g. signatures.hpp vs signatures.pb.h.

Commit:d9834fb
Author:Daniel Kraft
Committer:Daniel Kraft

Implement (verification of) state proofs. This adds another set of protocol buffers, for holding the data needed for a state proof (by means of signed, successive states). Together with this format definition, we also add methods for validating that a state transition and a full state proof are valid.

Commit:7e012f6
Author:Daniel Kraft
Committer:Daniel Kraft

Define format for signed data in channels. This adds a new protocol buffer definition of the SignedData message, which will be the main data format for signed information in the context of game channels (board states, moves, changes in agreement).

Commit:debe520
Author:Daniel Kraft
Committer:Daniel Kraft

Protocol buffer for channel metadata. Add a protocol buffer definition for the metadata of a game channel, namely the list of participants and their signing addresses.

Commit:2a4e0ee
Author:Daniel Kraft
Committer:Daniel Kraft

Implement game logic for Mover. Add the ProcessForward and ProcessBackwards methods to the GameLogic interface, but they are still unused by the main xayagame logic. However, the Mover example game already implements them, which finishes the game logic for that game and makes it ready to use in testing of the main implementation for game-state updates in xayagame.