This is an automated email from the ASF dual-hosted git repository.
cmorris pushed a commit to branch tendermint
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-dta.git
The following commit(s) were added to refs/heads/tendermint by this push:
new d27bb4e Use CipherText not CypherText, fix end to end tests
d27bb4e is described below
commit d27bb4eed40c080c50bd819a827eeaf9ca674d16
Author: Christopher Morris <[email protected]>
AuthorDate: Fri Oct 11 12:46:43 2019 +0100
Use CipherText not CypherText, fix end to end tests
---
cmd/servicetester/Manual_Tests.txt | 18 ---
cmd/servicetester/block_test.sh | 248 ----------------------------------
cmd/servicetester/e2e_test.sh | 12 +-
cmd/servicetester/e2e_test.sh.old | 267 -------------------------------------
cmd/servicetester/fishhook | Bin 29288396 -> 29289172 bytes
cmd/servicetester/fulltest.sh | 8 +-
cmd/servicetester/go.mod | 8 --
cmd/servicetester/main.go | 93 -------------
cmd/servicetester/tendertest1.sh | 39 ------
libs/crypto/bench_test.go | 2 +-
libs/crypto/pqnist.go | 4 +-
libs/crypto/pqnist_test.go | 6 +-
libs/crypto/secp256k1.go | 4 +-
libs/crypto/secp256k1_test.go | 4 +-
libs/documents/docs.go | 6 +-
libs/documents/docs.pb.go | 3 +-
libs/documents/docs_test.go | 2 +-
pkg/safeguardsecret/README.md | 2 +-
pkg/safeguardsecret/open-api.yaml | 4 +-
pkg/safeguardsecret/service.go | 12 +-
pkg/tendermint/connector.go | 2 +-
pkg/tendermint/fishhook/build | 1 +
pkg/tendermint/fishhook/fishhook | Bin 29288396 -> 29289172 bytes
23 files changed, 36 insertions(+), 709 deletions(-)
diff --git a/cmd/servicetester/Manual_Tests.txt
b/cmd/servicetester/Manual_Tests.txt
deleted file mode 100644
index 61c172a..0000000
--- a/cmd/servicetester/Manual_Tests.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-Run
- service: safeguardsecret
-
-
-beneficiaryIDDocumentCID="QmNpPp9wbBFUfBYCABrmKcaxd3eVxd2bGHfVQsEhRJPHjD"
-curl -s -X POST http://localhost:5556/v1/order1 -H "accept: */*"" -H
Content-Type: application/json -d
"{\"beneficiaryIDDocumentCID\":\"$beneficiaryIDDocumentCID\",\"extension\":{\"plainText\":\"This
is some random test text 1234567890\"}}"
-curl -s -X POST http://localhost:5556/v1/order/secret1 -H "accept: */*"" -H
Content-Type: application/json -d
"{\"orderReference\":\"05aca4ec-e43d-11e9-b3d3-acde48001122\",\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"cypherText\":\"e4cbcbd24933ae36bb0be94d:04c9ac09595636acc109910634e632e278ba44ad752d4792d4b22a43a6ed9aa95b378878e803511dfc76d9a9b746488faab07d601befa25a58ea1323bc0d53e2fb:0dc02c50c8fbfafa27ddcdf469c191c2ff7e20f0e04edc815b79418d2ed366234c90c303cf7122b7210fc81b3ce9bbf4\"}}"
-
-
-Run:
-service : bitcoinwallet
-curl -s -X POST "127.0.0.1:5556/v1/order1" -H "accept: */*" -H "Content-Type:
application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}"
-curl -X POST "127.0.0.1:5556/v1/order/secret1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"orderReference\":\"0cbdf024-e442-11e9-90cc-acde48001122\",\"beneficiaryIDDocumentCID\":\"QmNpPp9wbBFUfBYCABrmKcaxd3eVxd2bGHfVQsEhRJPHjD\"}"
-
-
-service: Milagro
-curl -s -X POST http://localhost:5556/v1/order1 -H "accept: */*" -H
Content-Type: application/json -d
"{\"beneficiaryIDDocumentCID\":\"$beneficiaryIDDocumentCID\"}"
-curl -s -X POST http://localhost:5556/v1/order/secret1 -H "accept: */*" -H
Content-Type: application/json -d
"{\"orderReference\":\"380b8704-e443-11e9-969f-acde48001122\",\"beneficiaryIDDocumentCID\":\"QmNpPp9wbBFUfBYCABrmKcaxd3eVxd2bGHfVQsEhRJPHjD\"}"
diff --git a/cmd/servicetester/block_test.sh b/cmd/servicetester/block_test.sh
deleted file mode 100755
index c6674e8..0000000
--- a/cmd/servicetester/block_test.sh
+++ /dev/null
@@ -1,248 +0,0 @@
-#!/bin/bash
-#End to End Test of Services using curl/bash
-
-apiVersion="v1"
-defaultURL="http://localhost:5556"
-apiURL="${1:-$defaultURL}"
-
-
-status () {
- #Determine if an extension is running
- statusOutput=$(curl -s -X GET "$apiURL/$apiVersion/status" -H "accept: */*"
-H "Content-Type: application/json")
-
-echo "$apiURL/$apiVersion/status"
-
- identity=$(echo $statusOutput | jq .nodeCID)
- extensionVendor=$(echo $statusOutput | jq -r .extensionVendor)
- plugin=$(echo $statusOutput | jq -r .plugin)
- echo "Plugin $plugin"
-
- if [ -z "${extensionVendor}" ]; then
- echo "Server Not Running"
- exit 1
- fi
-}
-
-###############################################################################################################################
-
-execute_bitcoin () {
- # #Run 4 Tests against the Bitcoin Extension
- echo "Bitcoin Plugin Tests [4 Tests]"
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
- #echo $output1
- op1=$(echo $output1 | jq .orderReference)
- commitment1=$(echo $output1 | jq .commitment)
- address1=$(echo $output1 | jq .extension.address)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity}")
- address2=$(echo $output2 | jq .extension.address)
- commitment2=$(echo $output2 | jq .commitment)
-
- echo "Committment1 $commitment1 $address1"
- echo "Committment2 $commitment2 $address2"
-
- if [ -z $commitment2 ]; then
- echo "Failed Commitment is empty"
- exit 1
- fi
-
- if [ $commitment1 == $commitment2 ]; then
- echo "Pass - Id, Order & OrderSecret(Beneficiary)"
- else
- echo "Fail"
- exit 1
- fi
-
-
- output3=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"coin\":\"0\"}}")
-
- op3=$(echo $output3 | jq .orderReference)
- commitment3=$(echo $output3 | jq .commitment)
- address3=$(echo $output3 | jq .extension.address)
- output4=$(curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d "{\"orderReference\":$op3}")
- commitment4=$(echo $output4 | jq .commitment)
- address4=$(echo $output4 | jq .extension.address)
- orderReference=$(echo $output4 | jq .orderReference)
- orderIndex=1
-
- echo "Committment3 $commitment3 $address3"
- echo "Committment4 $commitment4 $address4"
-
- if [ -z $commitment4 ]; then
- echo "Failed Commitment is empty"
- exit 1
- fi
-
- if [ $commitment3 == $commitment4 ]; then
- echo "Pass - Id, Order(Beneficiary) & OrderSecret"
- else
- echo "Fail"
- exit 1
- fi
-
-
- #make another BeneficiaryID
- output5=$(curl -s -X POST "http://localhost:5556/$apiVersion/identity" -H
"accept: */*" -H "Content-Type: application/json" -d "{\"Name\":\"AA\"}")
- benid=$(echo $output5 | jq -r .idDocumentCID)
-
-
-
- #Tests against the Bitcoin Extension - different befificary
- output6=$(curl -s -X POST "http://localhost:5556/$apiVersion/order" -H
"accept: */*" -H "Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
- #echo $output6
- op6=$(echo $output6 | jq .orderReference)
- commitment6=$(echo $output6 | jq .commitment)
- address6=$(echo $output6 | jq .extension.address)
-
- output7=$(curl -s -X POST "http://localhost:5556/$apiVersion/order/secret"
-H "accept: */*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op6,\"beneficiaryIDDocumentCID\":\"$benid\"}")
- address7=$(echo $output7 | jq .extension.address)
- commitment7=$(echo $output7 | jq .commitment)
-
- echo "Committment5 $commitment6 $address6"
- echo "Committment6 $commitment7 $address7"
-
- if [ -z $commitment7 ]; then
- echo "Failed Commitment is empty"
- exit 1
- fi
-
- if [ $commitment6 == $commitment7 ]; then
- echo "Pass - Id, Order & OrderSecret(Beneficiary)"
- else
- echo "Fail"
- exit 1
- fi
-
- output8=$(curl -s -X POST "http://localhost:5556/$apiVersion/order" -H
"accept: */*" -H "Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"$benid\",\"extension\":{\"coin\":\"0\"}}")
- op8=$(echo $output8 | jq .orderReference)
- commitment8=$(echo $output8 | jq .commitment)
- address8=$(echo $output8 | jq .extension.address)
-
-
- output9=$(curl -s -X POST "http://localhost:5556/$apiVersion/order/secret"
-H "accept: */*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op8}")
- commitment9=$(echo $output9 | jq .commitment)
- address9=$(echo $output9 | jq .extension.address)
- orderReference=$(echo $output9 | jq .orderReference)
- orderIndex=1
-
- echo "Committment7 $commitment8 $address8"
- echo "Committment8 $commitment9 $address9"
-
- if [ -z $commitment9 ]; then
- echo "Failed Commitment is empty"
- exit 1
- fi
-
- if [ $commitment8 == $commitment9 ]; then
- echo "Pass - Id, Order(Beneficiary) & OrderSecret"
- else
- echo "Fail"
- exit 1
- fi
-
-}
-
-
-###############################################################################################################################
-
-execute_safeguardsecret () {
- inputString="This is some random test text 1234567890!"
- echo "Encrypt a String [1 Test]"
- echo $output1
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"plainText\":\"$inputString\"}}")
- echo $output1
- op1=$(echo $output1 | jq .orderReference)
- cipherText=$(echo $output1 | jq .extension.cypherText)
- tvalue=$(echo $output1 | jq .extension.t)
- vvalue=$(echo $output1 | jq .extension.v)
- commitment1=$(echo $output1 | jq .commitment)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"cypherText\":$cipherText,\"t\":$tvalue,\"v\":$vvalue}}")
- result=$(echo $output2 | jq -r .extension.plainText)
-
- orderReference=$(echo $output2 | jq .orderReference)
- orderIndex=0
-
-
- if [ "$inputString" == "$result" ]; then
- echo "Pass"
- else
- echo "Fail"
- exit 1
- fi
-}
-
-# #############################################################################
-
-
-execute_milagro () {
- echo "Milagro Tests [1 Test]"
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d "{\"beneficiaryIDDocumentCID\":$identity}")
- echo $output1
- op1=$(echo $output1 | jq .orderReference)
-
-
- commitment1=$(echo $output1 | jq .commitment)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity}")
- commitment2=$(echo $output2 | jq .commitment)
-
- orderReference=$(echo $output2 | jq .orderReference)
- orderIndex=0
-
-
- echo "Committment1 $commitment1"
- echo "Committment2 $commitment2"
-
- if [ -z $commitment2 ]; then
- echo "Failed Commitment is empty"
- exit 1
- fi
-
- if [ $commitment1 == $commitment2 ]; then
- echo "Order Create/Retrieve Pass"
- else
- echo "Order Create/Retrieve Fail"
- exit 1
- fi
-}
-
-
-
-
-
-
-# #############################################################################
-
-execute_orderlist () {
- echo "Milagro Tests [1 Test]"
- commitment2=$(echo $output2 | jq .commitment)
- outputList=$(curl -s -X GET
"$apiURL/$apiVersion/order?page=0&perPage=2&sortBy=dateCreatedDsc" -H "accept:
*/*")
- orderReference=$(echo $outputList | jq -r ".orderReference | .[$orderIndex]")
- outputOrder=$(curl -s -X GET "$apiURL/$apiVersion/order/$orderReference" -H
"accept: */*")
-
- #A simple smoke test to ensure some sort of order is returned
- hasSecret=`echo $outputOrder | grep "Secret"`
-
- if [ -z $hasSecret ]; then
- echo "Failed Order has error"
- exit 1
- else
- echo "Passed orderList & get"
- fi
-}
-
-# #############################################################################
-
-status
-
-if [ $plugin == "bitcoinwallet" ]; then
- execute_bitcoin
-fi
-
-if [ $plugin == "milagro" ]; then
- execute_milagro
-fi
-
-if [ $plugin == "safeguardsecret" ]; then
- execute_safeguardsecret
-fi
-execute_orderlist
-
diff --git a/cmd/servicetester/e2e_test.sh b/cmd/servicetester/e2e_test.sh
index 7d1b0f4..cbd53ef 100755
--- a/cmd/servicetester/e2e_test.sh
+++ b/cmd/servicetester/e2e_test.sh
@@ -117,17 +117,15 @@ execute_safeguardsecret () {
inputString="This is some random test text 1234567890!"
printf " Encrypt a String [1 Test]\n"
-
- ( sleep 1; curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"plainText\":\"$inputString\"}}"
> ref ) &
+ ( sleep 2; curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"plainText\":\"$inputString\"}}"
> ref ) &
output1=$(fishhook $configdir $host "self" 2)
+
ref=$(cat ref | jq .orderReference)
- cipherText=$(echo $output1 | jq .OrderPart2.Extension.cypherText)
+ cipherText=$(echo $output1 | jq .OrderPart2.Extension.CipherText)
- #echo $cipherText
- ( sleep 1; curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$ref,\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"cypherText\":$cipherText}}"
> /dev/null) &
+ ( sleep 1; curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$ref,\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"cipherText\":$cipherText}}"
> /dev/null) &
output2=$(fishhook $configdir $host "self" 2)
- plaintext=$(echo $output2 | jq -r .OrderPart4.Extension.plainText)
-
+ plaintext=$(echo $output2 | jq -r .OrderPart4.Extension.PlainText)
if [ -z "$plaintext" ]; then
printf " ${RED}FAIL${NC} Commitment is empty\n"
diff --git a/cmd/servicetester/e2e_test.sh.old
b/cmd/servicetester/e2e_test.sh.old
deleted file mode 100755
index a0f7f0d..0000000
--- a/cmd/servicetester/e2e_test.sh.old
+++ /dev/null
@@ -1,267 +0,0 @@
-#!/bin/bash
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-
-#End to End Test of Services using curl/bash
-
-apiVersion="v1"
-defaultURL="http://localhost:5556"
-apiURL="${1:-$defaultURL}"
-
-
-status () {
- #Determine if an extension is running
- statusOutput=$(curl -s -X GET "$apiURL/$apiVersion/status" -H "accept: */*"
-H "Content-Type: application/json")
-
-echo "$apiURL/$apiVersion/status"
-
- identity=$(echo $statusOutput | jq .nodeCID)
- extensionVendor=$(echo $statusOutput | jq -r .extensionVendor)
- plugin=$(echo $statusOutput | jq -r .plugin)
- echo "Plugin $plugin"
-
- if [ -z "${extensionVendor}" ]; then
- echo "Server Not Running"
- exit 1
- fi
-}
-
-###############################################################################################################################
-
-execute_bitcoin () {
- # #Run 4 Tests against the Bitcoin Extension
- echo "Bitcoin Plugin Tests [4 Tests]"
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
- #echo $output1
- op1=$(echo $output1 | jq .orderReference)
- commitment1=$(echo $output1 | jq .commitment)
- address1=$(echo $output1 | jq .extension.address)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret1" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity}")
- address2=$(echo $output2 | jq .extension.address)
- commitment2=$(echo $output2 | jq .commitment)
-
- echo "Committment1 $commitment1 $address1"
- echo "Committment2 $commitment2 $address2"
-
- if [ -z $commitment2 ]; then
- echo "Failed Commitment is empty"
- exit 1
- fi
-
- if [ $commitment1 == $commitment2 ]; then
- echo "Pass - Id, Order & OrderSecret(Beneficiary)"
- else
- echo "Fail"
- exit 1
- fi
-
- output3=$(curl -s -X POST "$apiURL/$apiVersion/order1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"coin\":\"0\"}}")
-
- op3=$(echo $output3 | jq .orderReference)
- commitment3=$(echo $output3 | jq .commitment)
- address3=$(echo $output3 | jq .extension.address)
- output4=$(curl -s -X POST "$apiURL/$apiVersion/order/secret1" -H "accept:
*/*" -H "Content-Type: application/json" -d "{\"orderReference\":$op3}")
- commitment4=$(echo $output4 | jq .commitment)
- address4=$(echo $output4 | jq .extension.address)
- orderReference=$(echo $output4 | jq .orderReference)
- orderIndex=1
-
- echo "Committment3 $commitment3 $address3"
- echo "Committment4 $commitment4 $address4"
-
- if [ -z $commitment4 ]; then
- echo "Failed Commitment is empty"
- exit 1
- fi
-
- if [ $commitment3 == $commitment4 ]; then
- echo "Pass - Id, Order(Beneficiary) & OrderSecret"
- else
- echo "Fail"
- exit 1
- fi
-
-
- #make another BeneficiaryID
- # output5=$(curl -s -X POST "http://localhost:5556/$apiVersion/identity" -H
"accept: */*" -H "Content-Type: application/json" -d "{\"Name\":\"AA\"}")
- # benid=$(echo $output5 | jq -r .idDocumentCID)
-
- # #Tests against the Bitcoin Extension - different befificary
- # output6=$(curl -s -X POST "http://localhost:5556/$apiVersion/order" -H
"accept: */*" -H "Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
- # #echo $output6
- # op6=$(echo $output6 | jq .orderReference)
- # commitment6=$(echo $output6 | jq .commitment)
- # address6=$(echo $output6 | jq .extension.address)
-
- # output7=$(curl -s -X POST
"http://localhost:5556/$apiVersion/order/secret" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"orderReference\":$op6,\"beneficiaryIDDocumentCID\":\"$benid\"}")
- # address7=$(echo $output7 | jq .extension.address)
- # commitment7=$(echo $output7 | jq .commitment)
-
- # echo "Committment5 $commitment6 $address6"
- # echo "Committment6 $commitment7 $address7"
-
- # if [ -z $commitment7 ]; then
- # echo "Failed Commitment is empty"
- # exit 1
- # fi
-
- # if [ $commitment6 == $commitment7 ]; then
- # echo "Pass - Id, Order & OrderSecret(Beneficiary)"
- # else
- # echo "Fail"
- # exit 1
- # fi
-
- # output8=$(curl -s -X POST "http://localhost:5556/$apiVersion/order" -H
"accept: */*" -H "Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"$benid\",\"extension\":{\"coin\":\"0\"}}")
- # op8=$(echo $output8 | jq .orderReference)
- # commitment8=$(echo $output8 | jq .commitment)
- # address8=$(echo $output8 | jq .extension.address)
-
-
- # output9=$(curl -s -X POST "http://localhost:5556/$apiVersion/order/secret"
-H "accept: */*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op8}")
- # commitment9=$(echo $output9 | jq .commitment)
- # address9=$(echo $output9 | jq .extension.address)
- # orderReference=$(echo $output9 | jq .orderReference)
- # orderIndex=1
-
- # echo "Committment7 $commitment8 $address8"
- # echo "Committment8 $commitment9 $address9"
-
- # if [ -z $commitment9 ]; then
- # echo "Failed Commitment is empty"
- # exit 1
- # fi
-
- # if [ $commitment8 == $commitment9 ]; then
- # echo "Pass - Id, Order(Beneficiary) & OrderSecret"
- # else
- # echo "Fail"
- # exit 1
- # fi
-
-}
-
-
-###############################################################################################################################
-
-execute_safeguardsecret () {
- inputString="This is some random test text 1234567890!"
- echo "Encrypt a String [1 Test]"
- echo $output1
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"plainText\":\"$inputString\"}}")
- echo $output1
- op1=$(echo $output1 | jq .orderReference)
- cipherText=$(echo $output1 | jq .extension.cypherText)
- tvalue=$(echo $output1 | jq .extension.t)
- vvalue=$(echo $output1 | jq .extension.v)
- commitment1=$(echo $output1 | jq .commitment)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret1" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"cypherText\":$cipherText,\"t\":$tvalue,\"v\":$vvalue}}")
- result=$(echo $output2 | jq -r .extension.plainText)
-
- orderReference=$(echo $output2 | jq .orderReference)
- orderIndex=0
-
-
- if [ "$inputString" == "$result" ]; then
- echo "Pass"
- else
- echo "Fail"
- exit 1
- fi
-}
-
-# #############################################################################
-
-
-execute_milagro () {
- echo "Milagro Tests [1 Test]"
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order1" -H "accept: */*" -H
"Content-Type: application/json" -d "{\"beneficiaryIDDocumentCID\":$identity}")
- echo $output1
- op1=$(echo $output1 | jq .orderReference)
-
-
- commitment1=$(echo $output1 | jq .commitment)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret1" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity}")
- commitment2=$(echo $output2 | jq .commitment)
-
- orderReference=$(echo $output2 | jq .orderReference)
- orderIndex=0
-
-
- echo "Committment1 $commitment1"
- echo "Committment2 $commitment2"
-
- if [ -z $commitment2 ]; then
- echo "Failed Commitment is empty"
- exit 1
- fi
-
- if [ $commitment1 == $commitment2 ]; then
- echo "Order Create/Retrieve Pass"
- else
- echo "Order Create/Retrieve Fail"
- exit 1
- fi
-}
-
-
-
-
-
-
-# #############################################################################
-
-execute_orderlist () {
- echo "Milagro Tests [1 Test]"
- commitment2=$(echo $output2 | jq .commitment)
- outputList=$(curl -s -X GET
"$apiURL/$apiVersion/order?page=0&perPage=2&sortBy=dateCreatedDsc" -H "accept:
*/*")
- orderReference=$(echo $outputList | jq -r ".orderReference | .[$orderIndex]")
- outputOrder=$(curl -s -X GET "$apiURL/$apiVersion/order/$orderReference" -H
"accept: */*")
-
- #A simple smoke test to ensure some sort of order is returned
- hasSecret=`echo $outputOrder | grep "Secret"`
-
- if [ -z $hasSecret ]; then
- echo "Failed Order has error"
- exit 1
- else
- echo "Passed orderList & get"
- fi
-}
-
-# #############################################################################
-
-status
-
-if [ $plugin == "bitcoinwallet" ]; then
- execute_bitcoin
-fi
-
-if [ $plugin == "qredoplugin" ]; then
- execute_bitcoin
-fi
-
-if [ $plugin == "milagro" ]; then
- execute_milagro
-fi
-
-if [ $plugin == "safeguardsecret" ]; then
- execute_safeguardsecret
-fi
-execute_orderlist
-
diff --git a/cmd/servicetester/fishhook b/cmd/servicetester/fishhook
index 6353907..287284c 100755
Binary files a/cmd/servicetester/fishhook and b/cmd/servicetester/fishhook
differ
diff --git a/cmd/servicetester/fulltest.sh b/cmd/servicetester/fulltest.sh
index 7586079..f81ad19 100755
--- a/cmd/servicetester/fulltest.sh
+++ b/cmd/servicetester/fulltest.sh
@@ -44,6 +44,7 @@ report () {
printf " ${GREEN}PASSED $1 ${NC}\n"
else
printf " ${RED}FAILED $1 ${NC}\n"
+ printf " Remeber to recompile fishhook (esp. if Protobuffers
change)\n"
fi
}
@@ -51,15 +52,16 @@ test_plugin () {
pushd .
cd ../..
start_server $1
- popd
+ popd
./e2e_test.sh #> /dev/null
res=$?
- report "$1" $res
-
+ report "$1" $res
+
kill -s int $pid
}
cd "$(dirname "$0")"
+
test_plugin bitcoinwallet
test_plugin milagro
test_plugin safeguardsecret
diff --git a/cmd/servicetester/go.mod b/cmd/servicetester/go.mod
deleted file mode 100644
index 0a4bd6f..0000000
--- a/cmd/servicetester/go.mod
+++ /dev/null
@@ -1,8 +0,0 @@
-module github.com/apache/incubator-milagro-dta/cmd/servicetester
-
-go 1.13
-
-require (
- github.com/apache/incubator-milagro-dta
v0.0.0-20191001084144-6bc9bc4c9a45
- github.com/tendermint/tendermint v0.32.4
-)
diff --git a/cmd/servicetester/main.go b/cmd/servicetester/main.go
deleted file mode 100644
index 700645c..0000000
--- a/cmd/servicetester/main.go
+++ /dev/null
@@ -1,93 +0,0 @@
-package main
-
-import (
- "context"
- "encoding/json"
- "os"
-
- tmclient "github.com/tendermint/tendermint/rpc/client"
- tmtypes "github.com/tendermint/tendermint/types"
-)
-
-type BlockChainTX struct {
- Processor string
- SenderID string
- RecipientID string
- AdditionalRecipientIDs []string
- Payload []byte
- TXhash []byte
- Tags map[string]string
-}
-
-func main() {
-
- subscribe(3)
-}
-
-//Subscribe to Websocket and add to queue
-func subscribe(ignore int) error {
- client := tmclient.NewHTTP("tcp://34.246.173.153:26657", "/websocket")
- err := client.Start()
- if err != nil {
- print("Failed to start Tendermint HTTP client %s", err)
- return err
- }
- defer client.Stop()
- query :=
"tag.recipient='QmNpPp9wbBFUfBYCABrmKcaxd3eVxd2bGHfVQsEhRJPHjD'"
- //query := "tm.event = 'Tx'"
-
- out, err := client.Subscribe(context.Background(), "test", query, 1000)
- if err != nil {
- print("Failed to subscribe to query %s %s", query, err)
- return err
- }
-
- print("Tendermint: Connected")
-
- for {
- select {
- case result := <-out:
- tx := result.Data.(tmtypes.EventDataTx).Tx
- payload := BlockChainTX{}
- err := json.Unmarshal(tx, &payload)
- if err != nil {
- print("******** Invalid TX - ignored")
- break
- }
- print(".")
- ignore--
- if ignore == 0 {
- print("Complete")
- os.Exit(0)
- }
- }
-
- }
- return nil
-}
-
-
-
-//Dump - used for debugging purpose, print the entire Encrypted Transaction
-func Dump(tx *BlockChainTX) error {
- nodeID := s.NodeID()
- txHashString := hex.EncodeToString(tx.TXhash)
-
- localIDDoc, err := common.RetrieveIDDocFromIPFS(s.Ipfs, nodeID)
- if err != nil {
- return err
- }
-
- _, _, _, sikeSK, err := common.RetrieveIdentitySecrets(s.Store, nodeID)
- if err != nil {
- return err
- }
-
- order := &documents.OrderDoc{}
- err = documents.FinalPrivateKey(tx.Payload, txHashString, order,
sikeSK, nodeID, localIDDoc.BLSPublicKey)
-
- pp, _ := prettyjson.Marshal(order)
- fmt.Println(string(pp))
-
- return nil
-}
\ No newline at end of file
diff --git a/cmd/servicetester/tendertest1.sh b/cmd/servicetester/tendertest1.sh
deleted file mode 100755
index b9d2f8c..0000000
--- a/cmd/servicetester/tendertest1.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /bin/bash
-
-apiVersion="v1"
-defaultURL="http://localhost:5556"
-apiURL="${1:-$defaultURL}"
-
-echo "DTA URL: $apiURL"
-
-statusOutput=$(curl -s -X GET "$apiURL/$apiVersion/status")
-identity=$(echo $statusOutput | jq -r .nodeCID)
-plugin=$(echo $statusOutput | jq -r .plugin)
-
-if [ -z "${identity}" ]; then
- echo "Server Not Running"
- exit 1
-fi
-
-benID="${2:-$identity}"
-
-echo "DTA Plugin: $plugin"
-echo "DTA ID: $identity"
-echo "BeneficiaryID: $benID"
-
-
-respOrder=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"$benID\",\"extension\":{\"coin\":\"0\"}}")
-
-orderRef=$(echo $respOrder | jq '.orderReference')
-if [ -z "${orderRef}" ]; then
- echo "Create order invalid response"
- exit 1
-fi
-
-
-#sleep long enough for blockchain to catch up
-sleep 4
-
-curl -X POST "$apiURL/$apiVersion/order/secret" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"orderReference\":$orderRef,\"beneficiaryIDDocumentCID\":\"$benID\"}"
-
-
diff --git a/libs/crypto/bench_test.go b/libs/crypto/bench_test.go
index 063b427..f9ef8ba 100644
--- a/libs/crypto/bench_test.go
+++ b/libs/crypto/bench_test.go
@@ -102,7 +102,7 @@ func Test_Bench1(t *testing.T) {
elapsed = time.Since(start)
log.Printf("EncapsulateEncrypt took %s", elapsed/100)
- // Decapsulate the AES Key and use it to decrypt the ciphertext.
+ // Decapsulate the AES Key and use it to decrypt the cipherText.
// P2 and P3 should be the same. This value is the AES-256 key
// used to encrypt the plaintext P1
diff --git a/libs/crypto/pqnist.go b/libs/crypto/pqnist.go
index 551f31a..9df6c5b 100644
--- a/libs/crypto/pqnist.go
+++ b/libs/crypto/pqnist.go
@@ -348,7 +348,7 @@ func SIKEKeys(seed []byte) (rc int, sikePK []byte, sikeSK
[]byte) {
The message is encrypted using AES-256. The key
is generated inside this function as an output
- from the encapsulation function. The ciphertext
+ from the encapsulation function. The cipherText
is returned using the P paramter.
@param P Plaintext to be encrypted
@@ -380,7 +380,7 @@ func EncapsulateEncrypt(p []byte, iv []byte, sikePK []byte)
(rc int, c []byte, e
/*DecapsulateDecrypt Decapsulate the AES Key and decrypt the message
Decapsulate the AES key and use it to decrypt the
-ciphertext. The plaintext is returned using the C
+cipherText. The plaintext is returned using the C
parameter.
@param C Ciphertext to be decrypted
diff --git a/libs/crypto/pqnist_test.go b/libs/crypto/pqnist_test.go
index febe2f9..b83b60a 100644
--- a/libs/crypto/pqnist_test.go
+++ b/libs/crypto/pqnist_test.go
@@ -159,18 +159,18 @@ func Test_Smoke_Test(t *testing.T) {
EKHex := hex.EncodeToString(EK)
fmt.Printf("EKHex : %s \n", EKHex)
- // Decapsulate the AES Key and use it to decrypt the ciphertext.
+ // Decapsulate the AES Key and use it to decrypt the cipherText.
// P2 and P3 should be the same. This value is the AES-256 key
// used to encrypt the plaintext P1
RC3, P3 := DecapsulateDecrypt(C2, IV2, SIKEsk, EK)
if RC3 != 0 {
fmt.Println("Panicking!")
- panic("Failed to decapsulate key and decrypt ciphertext")
+ panic("Failed to decapsulate key and decrypt cipherText")
}
P3Hex := hex.EncodeToString(P3)
fmt.Printf("P3Hex : %s \n", P3Hex)
- // Decrypt the ciphertext to recover the orignal plaintext
+ // Decrypt the cipherText to recover the orignal plaintext
// contained in P1
K2 := P3
P4 := AESCBCDecrypt(K2, IV1, C1)
diff --git a/libs/crypto/secp256k1.go b/libs/crypto/secp256k1.go
index 9419f89..0c1ea58 100644
--- a/libs/crypto/secp256k1.go
+++ b/libs/crypto/secp256k1.go
@@ -81,11 +81,11 @@ func Secp256k1Decrypt(C, V, T, sK string) (message string,
err error) {
return
}
- //Cast the cypherText back to Octets
+ //Cast the cipherText back to Octets
mOct := NewOctet(len(C) + 16 - (len(C) % 16))
if C.ECP_SECP256K1_ECIES_DECRYPT(hashFunc, paramP1, paramP2, vOct,
cOct, tOct, uOct, mOct) != 1 {
- return "", errors.New("Cannot decrypt cyphertext")
+ return "", errors.New("Cannot decrypt cipherText")
}
b := mOct.ToBytes()
diff --git a/libs/crypto/secp256k1_test.go b/libs/crypto/secp256k1_test.go
index 89781fb..8b8a1ea 100644
--- a/libs/crypto/secp256k1_test.go
+++ b/libs/crypto/secp256k1_test.go
@@ -28,7 +28,7 @@ const (
secpPublicKey =
"041adb36d23c6d01a77d0c2064d491a948922718b848a5f422d17f64b19d65c195986e0ee28049d34e912b3f8022eeb5ec60bcd6562d0c1ee507427e183bdbdd66"
secpPrivateKey =
"8ba005a4ab3b655205435cd61da3630655ccba3c5365e32207eb9bdad561b38f"
- testCypherText =
"16751918cf55801daf36e6e6e595a41f3e31d7ba2db55790693e90dfff61ba617fa5ad63fb5fd0c52ccf4b2a85c1f527"
+ testCipherText =
"16751918cf55801daf36e6e6e595a41f3e31d7ba2db55790693e90dfff61ba617fa5ad63fb5fd0c52ccf4b2a85c1f527"
testT = "68d7e2c2a4dbceb4e7b885d3"
testV =
"04a68004e3de100c2b76537e0b3d6eb95ce4f03e4dfac2e01527f73f723b4387c956d1120c6b64a812ccde3658ceeed80cf062e6ea6bf6a95395315e0ef6f2140f"
)
@@ -52,7 +52,7 @@ func TestEncrypt(t *testing.T) {
func TestDecrypt(t *testing.T) {
- plainText, err := Secp256k1Decrypt(testCypherText, testV, testT,
secpPrivateKey)
+ plainText, err := Secp256k1Decrypt(testCipherText, testV, testT,
secpPrivateKey)
if err != nil {
t.Fatal(err)
}
diff --git a/libs/documents/docs.go b/libs/documents/docs.go
index 59bad92..1949af5 100644
--- a/libs/documents/docs.go
+++ b/libs/documents/docs.go
@@ -123,7 +123,7 @@ func DecodeOrderDocument(rawdoc []byte, tag string,
orderdoc *OrderDoc, sikeSK [
return nil
}
-//Decode - Given a raw envelope, Sike Secret Key & ID - decode into plaintext,
ciphertext(decrypted) and header
+//Decode - Given a raw envelope, Sike Secret Key & ID - decode into plaintext,
cipherText(decrypted) and header
func Decode(rawDoc []byte, tag string, sikeSK []byte, recipientID string,
plainText proto.Message, encryptedText proto.Message, sendersBlsPK []byte)
(header *Header, err error) {
signedEnvelope := SignedEnvelope{}
err = proto.Unmarshal(rawDoc, &signedEnvelope)
@@ -171,7 +171,7 @@ func Decode(rawDoc []byte, tag string, sikeSK []byte,
recipientID string, plainT
}
err = proto.Unmarshal(decryptedCipherText, encryptedText)
if err != nil {
- return &Header{}, errors.New("Failed to unmarshall
ciphertext")
+ return &Header{}, errors.New("Failed to unmarshall
cipherText")
}
}
return header, nil
@@ -204,7 +204,7 @@ func Encode(nodeID string, plainText proto.Message,
secretText proto.Message, he
return nil, errors.Wrap(err, "Failed to marshall
Plaintext to Protobuf")
}
}
- //Ciphertext
+ //CipherText
var cipherText []byte
if secretText != nil {
secretBody, err := proto.Marshal(secretText)
diff --git a/libs/documents/docs.pb.go b/libs/documents/docs.pb.go
index a57e80a..d6316b3 100644
--- a/libs/documents/docs.pb.go
+++ b/libs/documents/docs.pb.go
@@ -5,11 +5,10 @@ package documents
import (
fmt "fmt"
- math "math"
-
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
+ math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
diff --git a/libs/documents/docs_test.go b/libs/documents/docs_test.go
index 513fc7b..ab33a01 100644
--- a/libs/documents/docs_test.go
+++ b/libs/documents/docs_test.go
@@ -48,7 +48,7 @@ func Test_EnvelopeEncryption(t *testing.T) {
order.Reference = testText
raw, _ := EncodeOrderDocument(id1, order, blsSK, recipients)
contains := bytes.Contains(raw, testTextBytes)
- assert.False(t, contains, "Testtext should not be found inside the
Envelope - its inside the ciphertext")
+ assert.False(t, contains, "Testtext should not be found inside the
Envelope - its inside the cipherText")
iddoc, _, _, _, _, blsSK := BuildTestIDDoc()
iddoc.AuthenticationReference = testText
diff --git a/pkg/safeguardsecret/README.md b/pkg/safeguardsecret/README.md
index 742868c..c4708bc 100644
--- a/pkg/safeguardsecret/README.md
+++ b/pkg/safeguardsecret/README.md
@@ -37,7 +37,7 @@ curl -X POST "http:localhost:5556/order" -H "accept: */*" -H
"Content-Type: appl
**Swap In the correct Values from above**
```
-curl -X POST "http:localhost:5556/order/secret" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"OrderPart2CID\":\"QmXDdLPoeczWxzNFyxgSDkqxw71pnvBqB1xdW7XnyAPMJo\",\"BeneficiaryIDDocumentCID\":\"QmaJAj18pABdfU777mhv3rBmAqZRbE6vr1JgrZ2BcXwWj3\",\"Extension\":{\"cypherText\":\"3752ca1032ddba51b9525833550d509def1a9692d910b048172e7406ad40cbf1\",\"t\":\"b1e72740d16a6587496ec563\",\"v\":\"04dac12c6648f2c8e2f8c8522c46c70fdc0fe37f43ad855a11cb66132f1fab75ab1b8d9c1594a20c0dc947ef604e733
[...]
+curl -X POST "http:localhost:5556/order/secret" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"OrderPart2CID\":\"QmXDdLPoeczWxzNFyxgSDkqxw71pnvBqB1xdW7XnyAPMJo\",\"BeneficiaryIDDocumentCID\":\"QmaJAj18pABdfU777mhv3rBmAqZRbE6vr1JgrZ2BcXwWj3\",\"Extension\":{\"cipherText\":\"3752ca1032ddba51b9525833550d509def1a9692d910b048172e7406ad40cbf1\",\"t\":\"b1e72740d16a6587496ec563\",\"v\":\"04dac12c6648f2c8e2f8c8522c46c70fdc0fe37f43ad855a11cb66132f1fab75ab1b8d9c1594a20c0dc947ef604e733
[...]
```
## To Test the Plugin Code
diff --git a/pkg/safeguardsecret/open-api.yaml
b/pkg/safeguardsecret/open-api.yaml
index 39f8a51..d7e21d8 100644
--- a/pkg/safeguardsecret/open-api.yaml
+++ b/pkg/safeguardsecret/open-api.yaml
@@ -69,7 +69,7 @@ paths:
extension:
type: object
properties:
- cypherText:
+ cipherText:
type: string
example:
a72d69d8fb151edde606163ff880ae4f572d40b5135816379c7f6438a66dee44
t:
@@ -100,7 +100,7 @@ components:
extension:
type: object
properties:
- cypherText:
+ cipherText:
type: string
t:
type: string
diff --git a/pkg/safeguardsecret/service.go b/pkg/safeguardsecret/service.go
index 12e40cf..68ec337 100644
--- a/pkg/safeguardsecret/service.go
+++ b/pkg/safeguardsecret/service.go
@@ -63,9 +63,9 @@ func (s *Service) PrepareOrderResponse(order
*documents.OrderDoc) (commitment st
plainText := order.OrderReqExtension["plainText"]
delete(order.OrderReqExtension, "plainText") //we don't want to store
this
c, v, t, err := crypto.Secp256k1Encrypt(plainText, finalPublicKey)
- cypherTextWithParams := fmt.Sprintf("%s:%s:%s", t, v, c)
- return finalPublicKey, map[string]string{"cypherText":
cypherTextWithParams}, nil
- // return finalPublicKey, map[string]string{"cypherText": c, "v":
v, "t": t}, nil
+ CiphertextWithParams := fmt.Sprintf("%s:%s:%s", t, v, c)
+ return finalPublicKey, map[string]string{"CipherText":
CiphertextWithParams}, nil
+ // return finalPublicKey, map[string]string{"Ciphertext": c, "v":
v, "t": t}, nil
}
// ProduceFinalSecret -
@@ -76,14 +76,14 @@ func (s *Service) ProduceFinalSecret(seed, sikeSK []byte,
order, orderPart4 *doc
if err != nil {
return "", "", nil, err
}
- cypherTextWithParams := order.OrderPart2.Extension["cypherText"]
+ cypherTextWithParams := order.OrderPart2.Extension["CipherText"]
cypherparts := strings.SplitN(cypherTextWithParams, ":", 3) //maps
parts to t:v:c
if len(cypherparts) != 3 {
- return "", "", nil, errors.New("Invalid CypherText")
+ return "", "", nil, errors.New("Invalid Ciphertext")
}
plainText, err := crypto.Secp256k1Decrypt(cypherparts[2],
cypherparts[1], cypherparts[0], finalPrivateKey)
if err != nil {
return "", "", nil, err
}
- return finalPrivateKey, finalPublicKey, map[string]string{"plainText":
plainText}, nil
+ return finalPrivateKey, finalPublicKey, map[string]string{"PlainText":
plainText}, nil
}
diff --git a/pkg/tendermint/connector.go b/pkg/tendermint/connector.go
index 4810266..5bba07b 100644
--- a/pkg/tendermint/connector.go
+++ b/pkg/tendermint/connector.go
@@ -317,7 +317,7 @@ func (nc *NodeConnector) processTXQueue(ctx
context.Context, txQueue chan *api.B
msg := fmt.Sprintf("TX %s Block:%v Index:%v
Error:%v", color.RedString("FAILURE"), chainTx.Height, chainTx.Index, err)
nc.log.Info(msg)
} else {
- msg := fmt.Sprintf("TX %s Block:%v Index:%v",
color.GreenString("PROCESSED"), chainTx.Height, chainTx.Index)
+ msg := fmt.Sprintf("TX %s Block:%v Index:%v
Type:%v", color.GreenString("PROCESSED"), chainTx.Height, chainTx.Index,
chainTx.Processor)
nc.log.Info(msg)
}
if err := nc.updateProcessedUpToHeight(chainTx.Height,
chainTx.Index); err != nil {
diff --git a/pkg/tendermint/fishhook/build b/pkg/tendermint/fishhook/build
index f590499..ee9ce70 100755
--- a/pkg/tendermint/fishhook/build
+++ b/pkg/tendermint/fishhook/build
@@ -1,2 +1,3 @@
go build -o fishhook main.go
+cp fishhook
/Users/chris/go/src/github.com/apache/incubator-milagro-dta/cmd/servicetester/
diff --git a/pkg/tendermint/fishhook/fishhook b/pkg/tendermint/fishhook/fishhook
index 24ad43f..287284c 100755
Binary files a/pkg/tendermint/fishhook/fishhook and
b/pkg/tendermint/fishhook/fishhook differ