This is an automated email from the ASF dual-hosted git repository.
cmorris pushed a commit to branch splitroles-blockchain
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-dta.git
The following commit(s) were added to refs/heads/splitroles-blockchain by this
push:
new fc1327d Permit SenderID=RecipientID
fc1327d is described below
commit fc1327d2fbc2fe23315fe0b1951cc533e62c3599
Author: Christopher Morris <[email protected]>
AuthorDate: Mon Sep 30 18:51:33 2019 +0100
Permit SenderID=RecipientID
---
pkg/api/proto.go | 13 +++++++------
pkg/common/common.go | 7 -------
pkg/defaultservice/fulfillTX.go | 25 ++++++++++++++-----------
pkg/defaultservice/order.go | 34 +++++++++++++---------------------
pkg/defaultservice/orderTX.go | 22 ++++++++++++----------
pkg/tendermint/tendermint.go | 2 +-
pkg/tendermint/websockets.go | 15 ++-------------
r | 5 +++++
8 files changed, 54 insertions(+), 69 deletions(-)
diff --git a/pkg/api/proto.go b/pkg/api/proto.go
index d59ffd7..aedcd2c 100644
--- a/pkg/api/proto.go
+++ b/pkg/api/proto.go
@@ -42,12 +42,13 @@ const (
//BlockChainTX - struct for on chain req/resp
type BlockChainTX struct {
- Processor string
- SenderID string
- RecipientID []string
- Payload []byte
- TXhash []byte
- Tags map[string]string
+ Processor string
+ SenderID string
+ RecipientID string
+ AdditionalRecipientIDs []string
+ Payload []byte
+ TXhash []byte
+ Tags map[string]string
}
//CreateIdentityRequest -
diff --git a/pkg/common/common.go b/pkg/common/common.go
index 0ce6ff0..38db9dd 100644
--- a/pkg/common/common.go
+++ b/pkg/common/common.go
@@ -136,22 +136,18 @@ func InitECKeys(seed []byte) ([]byte, error) {
// RetrieveIdentitySecrets gets the secrets for the node ID
func RetrieveIdentitySecrets(store *datastore.Store, nodeID string) (name
string, seed []byte, blsSK []byte, sikeSK []byte, err error) {
-
var idSecrets = &IdentitySecrets{}
if err := store.Get("id-doc", nodeID, idSecrets); err != nil {
return "", nil, nil, nil, err
}
-
seed, err = hex.DecodeString(idSecrets.Seed)
if err != nil {
return "", nil, nil, nil, err
}
-
blsSK, err = hex.DecodeString(idSecrets.BLSSecretKey)
if err != nil {
return "", nil, nil, nil, err
}
-
sikeSK, err = hex.DecodeString(idSecrets.SikeSecretKey)
if err != nil {
return "", nil, nil, nil, err
@@ -161,9 +157,7 @@ func RetrieveIdentitySecrets(store *datastore.Store, nodeID
string) (name string
// BuildRecipientList builds a list of recipients who are able to decrypt the
encrypted envelope
func BuildRecipientList(ipfs ipfs.Connector, IDDocs ...string)
(map[string]documents.IDDoc, error) {
-
recipients := make(map[string]documents.IDDoc)
-
for _, v := range IDDocs {
iddoc, err := RetrieveIDDocFromIPFS(ipfs, v)
if err != nil {
@@ -171,6 +165,5 @@ func BuildRecipientList(ipfs ipfs.Connector, IDDocs
...string) (map[string]docum
}
recipients[v] = iddoc
}
-
return recipients, nil
}
diff --git a/pkg/defaultservice/fulfillTX.go b/pkg/defaultservice/fulfillTX.go
index 37748c2..b0c1025 100644
--- a/pkg/defaultservice/fulfillTX.go
+++ b/pkg/defaultservice/fulfillTX.go
@@ -87,12 +87,13 @@ func (s *Service) FulfillOrder(tx *api.BlockChainTX)
(string, error) {
//Write the requests to the chain
chainTX := &api.BlockChainTX{
- Processor: api.TXFulfillResponse,
- SenderID: nodeID,
- RecipientID: []string{order.PrincipalCID, nodeID},
- Payload: payload,
- TXhash: txHash,
- Tags: map[string]string{"reference": order.Reference,
"txhash": hex.EncodeToString(txHash)},
+ Processor: api.TXFulfillResponse,
+ SenderID: nodeID,
+ RecipientID: order.PrincipalCID,
+ AdditionalRecipientIDs: []string{},
+ Payload: payload,
+ TXhash: txHash,
+ Tags: map[string]string{"reference":
order.Reference, "txhash": hex.EncodeToString(txHash)},
}
return tendermint.PostToChain(chainTX, "FulfillOrder")
@@ -158,11 +159,13 @@ func (s *Service) FulfillOrderSecret(tx
*api.BlockChainTX) (string, error) {
//Write the requests to the chain
chainTX := &api.BlockChainTX{
- Processor: api.TXFulfillOrderSecretResponse,
- SenderID: nodeID,
- RecipientID: []string{s.MasterFiduciaryNodeID(),
order.BeneficiaryCID},
- Payload: payload,
- Tags: map[string]string{"reference": order.Reference,
"txhash": hex.EncodeToString(txHash)},
+ Processor: api.TXFulfillOrderSecretResponse,
+ SenderID: nodeID,
+ RecipientID: order.BeneficiaryCID,
+ AdditionalRecipientIDs: []string{},
+
+ Payload: payload,
+ Tags: map[string]string{"reference": order.Reference,
"txhash": hex.EncodeToString(txHash)},
}
return tendermint.PostToChain(chainTX, "FulfillOrderSecret")
}
diff --git a/pkg/defaultservice/order.go b/pkg/defaultservice/order.go
index eff406a..ac8a60f 100644
--- a/pkg/defaultservice/order.go
+++ b/pkg/defaultservice/order.go
@@ -152,12 +152,13 @@ func (s *Service) Order1(req *api.OrderRequest) (string,
error) {
//Write the requests to the chain
chainTX := &api.BlockChainTX{
- Processor: api.TXFulfillRequest,
- SenderID: nodeID,
- RecipientID: []string{s.MasterFiduciaryNodeID(), nodeID},
- Payload: payload, //marshaledRequest,
- TXhash: txHash,
- Tags: map[string]string{"reference": order.Reference,
"txhash": hex.EncodeToString(txHash)},
+ Processor: api.TXFulfillRequest,
+ SenderID: nodeID,
+ RecipientID: s.MasterFiduciaryNodeID(),
+ AdditionalRecipientIDs: []string{},
+ Payload: payload, //marshaledRequest,
+ TXhash: txHash,
+ Tags: map[string]string{"reference":
order.Reference, "txhash": hex.EncodeToString(txHash)},
}
tendermint.PostToChain(chainTX, "Order1")
return order.Reference, nil
@@ -207,16 +208,6 @@ func (s *Service) OrderSecret1(req
*api.OrderSecretRequest) (string, error) {
}
}
- //If we already did a transfer the Order doc is self signed so, check
with own Key so we can re-process the transfer
- // order, err := common.RetrieveOrderFromIPFS(s.Ipfs,
previousOrderHash, sikeSK, nodeID, remoteIDDoc.BLSPublicKey)
- // if err != nil {
- // //check if we are re-trying the call, so the OrderDoc is
locally signed
- // order, err = common.RetrieveOrderFromIPFS(s.Ipfs,
previousOrderHash, sikeSK, nodeID, localIDDoc.BLSPublicKey)
- // if err != nil {
- // return "", errors.Wrap(err, "Fail to retrieve Order
from IPFS")
- // }
- // }
-
if err := s.Plugin.ValidateOrderSecretRequest(req, *order); err != nil {
return "", err
}
@@ -243,11 +234,12 @@ func (s *Service) OrderSecret1(req
*api.OrderSecretRequest) (string, error) {
//Write the requests to the chain
chainTX := &api.BlockChainTX{
- Processor: api.TXFulfillOrderSecretRequest,
- SenderID: nodeID,
- RecipientID: []string{s.MasterFiduciaryNodeID()},
- Payload: payload,
- Tags: map[string]string{"reference": order.Reference,
"txhash": hex.EncodeToString(txHash)},
+ Processor: api.TXFulfillOrderSecretRequest,
+ SenderID: nodeID,
+ RecipientID: s.MasterFiduciaryNodeID(),
+ AdditionalRecipientIDs: []string{},
+ Payload: payload,
+ Tags: map[string]string{"reference":
order.Reference, "txhash": hex.EncodeToString(txHash)},
}
return tendermint.PostToChain(chainTX, "OrderSecret1")
}
diff --git a/pkg/defaultservice/orderTX.go b/pkg/defaultservice/orderTX.go
index 95fa883..8a9b9ea 100644
--- a/pkg/defaultservice/orderTX.go
+++ b/pkg/defaultservice/orderTX.go
@@ -77,11 +77,12 @@ func (s *Service) Order2(tx *api.BlockChainTX) (string,
error) {
//Write the Order2 results to the chain
chainTX := &api.BlockChainTX{
- Processor: api.TXOrderResponse,
- SenderID: "",
- RecipientID: []string{nodeID},
- Payload: payload,
- Tags: map[string]string{"reference": order.Reference,
"txhash": hex.EncodeToString(txHash)},
+ Processor: api.TXOrderResponse,
+ SenderID: "",
+ RecipientID: nodeID,
+ AdditionalRecipientIDs: []string{},
+ Payload: payload,
+ Tags: map[string]string{"reference":
order.Reference, "txhash": hex.EncodeToString(txHash)},
}
return tendermint.PostToChain(chainTX, "Order2")
@@ -143,11 +144,12 @@ func (s *Service) OrderSecret2(tx *api.BlockChainTX)
(string, error) {
//Write the requests to the chain
chainTX := &api.BlockChainTX{
- Processor: api.TXOrderSecretResponse, //NONE
- SenderID: nodeID,
- RecipientID: []string{nodeID}, //don't send this to chain, seed
compromise becomes fatal, sent just debugging
- Payload: payload,
- Tags: map[string]string{"reference": order.Reference,
"txhash": hex.EncodeToString(txHash)},
+ Processor: api.TXOrderSecretResponse, //NONE
+ SenderID: "",
+ RecipientID: nodeID,
+ AdditionalRecipientIDs: []string{},
+ Payload: payload,
+ Tags: map[string]string{"reference":
order.Reference, "txhash": hex.EncodeToString(txHash)},
}
return tendermint.PostToChain(chainTX, "OrderSecret2")
}
diff --git a/pkg/tendermint/tendermint.go b/pkg/tendermint/tendermint.go
index d732dab..1ea19f6 100644
--- a/pkg/tendermint/tendermint.go
+++ b/pkg/tendermint/tendermint.go
@@ -43,7 +43,7 @@ func QueryChain(index string) (string, string) {
func PostToChain(tx *api.BlockChainTX, method string) (string, error) {
//Create TX Hash
- tx.RecipientID = unique(tx.RecipientID)
+ tx.RecipientID = tx.RecipientID
TXID := sha256.Sum256(tx.Payload)
TXIDhex := hex.EncodeToString(TXID[:])
diff --git a/pkg/tendermint/websockets.go b/pkg/tendermint/websockets.go
index c55cbc9..2a75ae6 100644
--- a/pkg/tendermint/websockets.go
+++ b/pkg/tendermint/websockets.go
@@ -63,23 +63,12 @@ func subscribeAndQueue(queueWaiting chan api.BlockChainTX,
logger *logger.Logger
}
//check if this node is Sender - if so we don't need to
process it
- if payload.SenderID == nodeID {
- break
- }
//check if this node is in receipient list
- isRecipient := false
- for _, v := range payload.RecipientID {
- if v == nodeID {
- isRecipient = true
- break
- }
- }
-
- //If not in recipient list do nothing
- if isRecipient == false {
+ if payload.RecipientID != nodeID {
logger.Info("******** Invalid Recipient - why
are we receiving this TX?")
break
+
}
//Add into the waitingQueue for later processing
diff --git a/r b/r
new file mode 100755
index 0000000..edc2605
--- /dev/null
+++ b/r
@@ -0,0 +1,5 @@
+GO111MODULE=on go build -o target/milagro
github.com/apache/incubator-milagro-dta/cmd/service
+export MILAGRO_HOME=~/.milagro
+target/milagro daemon
+
+