From 5ad4addc43740644832bab1fc0f7c4ec97c99edd Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Wed, 30 Oct 2019 08:45:11 +0000 Subject: [PATCH] adding protobuf --- parse_proto.php | 17 +++++++ src/protobuf/gradido/BasicTypes.proto | 44 +++++++++++++++++++ src/protobuf/gradido/StateCreateGroup.proto | 15 +++++++ .../gradido/StateGroupChangeParent.proto | 12 +++++ src/protobuf/gradido/Transaction.proto | 19 ++++++++ src/protobuf/gradido/TransactionBody.proto | 18 ++++++++ .../gradido/TransactionCreation.proto | 13 ++++++ src/protobuf/gradido/Transfer.proto | 10 +++++ 8 files changed, 148 insertions(+) create mode 100755 parse_proto.php create mode 100644 src/protobuf/gradido/BasicTypes.proto create mode 100644 src/protobuf/gradido/StateCreateGroup.proto create mode 100644 src/protobuf/gradido/StateGroupChangeParent.proto create mode 100644 src/protobuf/gradido/Transaction.proto create mode 100644 src/protobuf/gradido/TransactionBody.proto create mode 100644 src/protobuf/gradido/TransactionCreation.proto create mode 100644 src/protobuf/gradido/Transfer.proto diff --git a/parse_proto.php b/parse_proto.php new file mode 100755 index 000000000..7e88098c5 --- /dev/null +++ b/parse_proto.php @@ -0,0 +1,17 @@ +#!/bin/bash +# Copyright 2015 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +PHP_PLUGIN="$(which grpc_php_plugin)" +protoc --proto_path=./src/protobuf/gradido --php_out=./src/ --grpc_out=./src/ --plugin=protoc-gen-grpc=$PHP_PLUGIN ./src/protobuf/gradido/*.proto + diff --git a/src/protobuf/gradido/BasicTypes.proto b/src/protobuf/gradido/BasicTypes.proto new file mode 100644 index 000000000..62494b52a --- /dev/null +++ b/src/protobuf/gradido/BasicTypes.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +package model.messages.gradido; + +message Key { + oneof key { + bytes ed25519 = 2; // ed25519 signature (libsodium default) + bytes ed25519_ref10 = 3; // ed25519 ref10 signature + } +} + +message SignaturePair { + bytes pubKey = 1; + oneof signature { + bytes ed25519 = 2; // ed25519 signature (libsodium default) + bytes ed25519_ref10 = 3; // ed25519 ref10 signature + } +} + +message SignatureMap { + repeated SignaturePair sigPair = 1; // Each signature pair corresponds to a unique Key required to sign the transaction. +} + +/* An exact date and time. This is the same data structure as the protobuf Timestamp.proto (see the comments in https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto) */ +message Timestamp { + int64 seconds = 1; // Number of complete seconds since the start of the epoch + int32 nanos = 2; // Number of nanoseconds since the start of the last second +} + +/* An exact date and time, with a resolution of one second (no nanoseconds). */ +message TimestampSeconds { + int64 seconds = 1; // Number of complete seconds since the start of the epoch +} + +message SenderAmount { + bytes ed25519_sender_pubkey = 1; + sint64 amount = 2; + sint64 senderFinalBalance = 3; // sender balance after transaction, including perishability +} + +message ReceiverAmount { + bytes ed25519_receiver_pubkey = 1; + sint64 amount = 2; +} diff --git a/src/protobuf/gradido/StateCreateGroup.proto b/src/protobuf/gradido/StateCreateGroup.proto new file mode 100644 index 000000000..37d5fbaad --- /dev/null +++ b/src/protobuf/gradido/StateCreateGroup.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package model.messages.gradido; + +import "BasicTypes.proto"; + +// need signature from this group and from parent (if it isn't zero) +message StateCreateGroup { + string name = 1; + Key groupPublicKey = 2; + Key parentGroupPublicKey = 3; + reserved "hederaConsensusId"; + reserved 4; + +} diff --git a/src/protobuf/gradido/StateGroupChangeParent.proto b/src/protobuf/gradido/StateGroupChangeParent.proto new file mode 100644 index 000000000..f87631942 --- /dev/null +++ b/src/protobuf/gradido/StateGroupChangeParent.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package model.messages.gradido; + +import "BasicTypes.proto"; + +// need signature from this group and from both parents (if it isn't zero) +message StateGroupChangeParent { + Key groupPublicKey = 1; + Key newParentGroupPublicKey = 2; + Key oldParentGroupPublicKey = 3; +} diff --git a/src/protobuf/gradido/Transaction.proto b/src/protobuf/gradido/Transaction.proto new file mode 100644 index 000000000..a5d3a41d9 --- /dev/null +++ b/src/protobuf/gradido/Transaction.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package model.messages.gradido; + +import "BasicTypes.proto"; + +/* + id will be set by Node server + txHash will be also set by Node server, + calculated from previous transaction txHash and this id, sigMap and received; +*/ + +message Transaction { + uint64 id = 1; + TimestampSeconds received = 2; + SignatureMap sigMap = 3; + bytes txHash = 4; + bytes bodyBytes = 5; +} diff --git a/src/protobuf/gradido/TransactionBody.proto b/src/protobuf/gradido/TransactionBody.proto new file mode 100644 index 000000000..b45475e85 --- /dev/null +++ b/src/protobuf/gradido/TransactionBody.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package model.messages.gradido; + +import "Transfer.proto"; +import "StateCreateGroup.proto"; +import "StateGroupChangeParent.proto"; +import "TransactionCreation.proto"; + +message TransactionBody { + string memo = 1; // max 150 chars + oneof data { + StateCreateGroup createGroup = 2; + StateGroupChangeParent groupChangeParent = 3; + Transfer transfer = 4; + TransactionCreation creation = 5; + } +} diff --git a/src/protobuf/gradido/TransactionCreation.proto b/src/protobuf/gradido/TransactionCreation.proto new file mode 100644 index 000000000..79455fa94 --- /dev/null +++ b/src/protobuf/gradido/TransactionCreation.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package model.messages.gradido; + +import "BasicTypes.proto"; + +// need signature from group admin or +// percent of group users another than the receiver +message TransactionCreation { + ReceiverAmount receiverAmount = 1; + sint32 ident_hash = 2; + +} diff --git a/src/protobuf/gradido/Transfer.proto b/src/protobuf/gradido/Transfer.proto new file mode 100644 index 000000000..afde70308 --- /dev/null +++ b/src/protobuf/gradido/Transfer.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package model.messages.gradido; + +import "BasicTypes.proto"; + +message Transfer { + repeated SenderAmount senderAmounts = 1; + repeated ReceiverAmount receiverAmounts = 2; +}