Skip to content

Commit e1182f1

Browse files
Merge pull request #8 from mbrandenburger/master
fix ercc and update docu
2 parents ea03009 + d1136c6 commit e1182f1

File tree

3 files changed

+75
-18
lines changed

3 files changed

+75
-18
lines changed

ecc/README.md

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,51 @@ chaincode implementation see ecc_encalve/.
99

1010
The following steps guide you through the build phase. Make sure this project is on your GOPATH.
1111

12-
First, build the chaincode and the validiation plugin
12+
First, build the chaincode and the validation plugin
1313

1414
$ make
15-
16-
Next, build the chaincode docker image. Note that normally the fabric peer
17-
itself creates the docker image when a new chaincode is installed. However, we
18-
use a custom chaincode environment docker image that has SGX support enabled.
19-
You can define the peer name and the chaincode name using PEER_NAME and
20-
CC_NAME.
21-
22-
$ make docker DOCKER_IMAGE=dev-jdoe-ecc-0
15+
16+
Next, build the chaincode docker image that is used by a fabric peer
17+
to run our chaincode. Normally, the peer creates the docker image
18+
automatically when a new chaincode is installed. In particular, it
19+
fetches the source code, builds the chaincode binary, and copies them
20+
into a new docker images based on fabric-ccenv. Note that, since the
21+
peer is lazy, the docker image is only created when the chaincode is
22+
installed and it is not already existing. The image name comprise of
23+
the peer name, the chaincode name, and a hash.
24+
25+
However, we use a custom chaincode environment docker image that has
26+
SGX-support enabled. In order to tell a peer to use our SGX chaincode
27+
image, we need to override an existing chaincode image.
28+
29+
For example: ``dev-jdoe-ecc-0-8bdbb434df41902eb2d2b2e2f10f6b0504b63f56eb98582f307c11a15fc14eb7``
30+
31+
Therefore, first install some chaincode, which we are going to override,
32+
and check if the corresponding docker image has been created
33+
successfully.
34+
35+
$ peer chaincode install -n ecc -v 0 -p github.com/hyperledger/fabric/examples/chaincode/go/example02/cmd
2336
$ docker images
24-
25-
Now you should see ``ecc`` in the list of docker images ``$ docker images``.
37+
REPOSITORY
38+
TAG IMAGE ID
39+
dev-jdoe-ercc-0-a5a84629692f2ed6e111c44bd91e8c3e0906deb39d9e16f7acd5aefc51303184
40+
latest 7a5ea0677404
41+
dev-jdoe-ecc-0-8bdbb434df41902eb2d2b2e2f10f6b0504b63f56eb98582f307c11a15fc14eb7
42+
latest 0c18434ae5e3
43+
44+
Next, just run ```make docker`` to override the existing docker image with
45+
our SGX chaincode. To verify that the image contains our enclave
46+
code, let's have a look inside the image and see if we can see an
47+
enclave folder.
48+
49+
$ make docker
50+
$ docker run -i -t --entrypoint ls dev-jdoe-ecc-0-8bdbb434df41902eb2d2b2e2f10f6b0504b63f56eb98582f307c11a15fc14eb7:latest
51+
chaincode chaintool enclave node npm npx protoc-gen-go
52+
53+
You can define the peer and the chaincode name also manually.
54+
55+
$ make docker DOCKER_IMAGE=my-peername-ecc-0
56+
2657
For debugging you can also start the docker image.
2758

2859
$ make docker-run

ercc/ercc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ func (ercc *EnclaveRegistryCC) getSPID(stub shim.ChaincodeStubInterface, args []
200200

201201
func main() {
202202
// start chaincode
203-
err := shim.Start(NewTestErcc())
204-
// err := shim.Start(NewErcc())
203+
// err := shim.Start(NewTestErcc())
204+
err := shim.Start(NewErcc())
205205
if err != nil {
206206
logger.Errorf("Error starting registry chaincode: %s", err)
207207
}

fabric/README.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ to run the auction demo.
2929

3030
### IAS
3131

32-
In order to use Intel's Attestation Service (IAS) you can register
33-
[here](https://software.intel.com/en-us/sgx). Place your client certificate
34-
and your SPID in the ``ias`` folder.
32+
In order to use Intel's Attestation Service (IAS) you need to register
33+
with Intel. [Here](https://software.intel.com/en-us/articles/code-sample-intel-software-guard-extensions-remote-attestation-end-to-end-example)
34+
you can find more details on how to obtain a signed client certificate,
35+
registering it and get a SPID.
36+
37+
Place your client certificate and your SPID in the ``ias`` folder.
38+
39+
cp client.crt /path-to/fabric/sgxconfig/ias/client.crt
40+
cp client.key /path-to/fabric/sgxconfig/ias/client.key
41+
echo 'YOURSPID' | xxd -r -p > /path-to/fabric/sgxconfig/ias/spid.txt
3542

3643
## Run the Auction
3744

@@ -49,18 +56,37 @@ the peer in two separate terminals using the corresponding scripts. In a
4956
third terminal, you can you run the auction demo with ``run_sgx_auction.sh``.
5057
Please edit ``start_peer.sh`` and point LD_LIBRARY_PATH to the tlcc enclave lib.
5158

59+
Note that when you run ``run_sgx_auction.sh`` the first time, you may
60+
see the following error:
61+
62+
../.build/bin/peer chaincode instantiate -o localhost:7050 -C mychannel -n ecc -v 0 -c '{"args":["init"]}' -V ecc-vscc
63+
Error: could not assemble transaction, err Proposal response was not successful, error code 500, msg transaction returned with failure:
64+
Incorrect number of arguments. Expecting 4
65+
66+
Don't worry, that is OK! :) The short answer to resolve this is to just
67+
rebuild ecc. Go to ``path-to/fabric-secure-chaincode/ecc`` and run
68+
``make docker``. You can, then, re-run ``run_sgx_auction.sh`` and the
69+
error is gone.
70+
71+
The long answer is the following: When a new chaincode is installed, the
72+
Fabric peer takes care of building the corresponding docker image that
73+
is used to execute the chaincode. As we need a custom SGX-enabled
74+
environment to execute our chaincode inside an enclave, we need to tell
75+
the peer to use our custom docker image.
76+
5277
* Terminal 1
5378

5479
$ cd fabric/sgxconfig
5580
$ ./demo/create_channel.sh
5681
$ ./demo/start_orderer.sh
57-
82+
5883
* Terminal 2
5984

6085
$ cd fabric/sgxconfig
6186
$ ./demo/start_peer.sh
62-
87+
6388
* Terminal 3
6489

6590
$ cd fabric/sgxconfig
6691
$ ./demo/run_sgx_auction.sh
92+

0 commit comments

Comments
 (0)