Skip to content

Commit

Permalink
feat: change secret-keeper-go makefile
Browse files Browse the repository at this point in the history
Signed-off-by: chenchanglew <[email protected]>
  • Loading branch information
chenchanglew committed Nov 26, 2024
1 parent e432083 commit c7028ec
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ecc_go/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ DOCKER_FILE ?= $(FPC_PATH)/ecc_go/Dockerfile
EGO_CONFIG_FILE ?= $(FPC_PATH)/ecc_go/enclave.json
ECC_BINARY ?= ecc
ECC_BUNDLE ?= $(ECC_BINARY)-bundle
MAIN_GO_PATH ?= main.go

build: ecc docker env

ecc: ecc_dependencies
ego-go build $(GOTAGS) -o $(ECC_BINARY) main.go
ego-go build $(GOTAGS) -o $(ECC_BINARY) $(MAIN_GO_PATH)
cp $(EGO_CONFIG_FILE) .
ego sign
ego uniqueid $(ECC_BINARY) > mrenclave
ego bundle $(ECC_BINARY) $(ECC_BUNDLE)

.PHONY: with_go
with_go: ecc_dependencies
$(GO) build $(GOTAGS) -o $(ECC_BUNDLE) main.go
$(GO) build $(GOTAGS) -o $(ECC_BUNDLE) $(MAIN_GO_PATH)
echo "fake_mrenclave" > mrenclave

ecc_dependencies:
Expand Down
12 changes: 12 additions & 0 deletions samples/chaincode/secret-keeper-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ TOP = ../../..
include $(TOP)/ecc_go/build.mk

CC_NAME ?= fpc-secret-keeper-go

# Define paths for cmd subdirectories
NAIVE_PATH = cmd/naive/main.go
SKVS_PATH = cmd/skvs/main.go

# Target to build naive version
naive:
$(MAKE) build MAIN_GO_PATH=$(NAIVE_PATH)

# Target to build skvs version
skvs:
$(MAKE) build MAIN_GO_PATH=$(SKVS_PATH)
41 changes: 41 additions & 0 deletions samples/chaincode/secret-keeper-go/cmd/naive/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright IBM Corp. All Rights Reserved.
Copyright 2020 Intel Corporation
SPDX-License-Identifier: Apache-2.0
*/

package main

import (
"os"

"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-contract-api-go/contractapi"
fpc "github.com/hyperledger/fabric-private-chaincode/ecc_go/chaincode"
"github.com/hyperledger/fabric-private-chaincode/samples/chaincode/secret-keeper-go/chaincode"
)

func main() {

ccid := os.Getenv("CHAINCODE_PKG_ID")
addr := os.Getenv("CHAINCODE_SERVER_ADDRESS")

// create chaincode
secretChaincode, _ := contractapi.NewChaincode(&chaincode.SecretKeeper{})
chaincode := fpc.NewPrivateChaincode(secretChaincode)

// start chaincode as a service
server := &shim.ChaincodeServer{
CCID: ccid,
Address: addr,
CC: chaincode,
TLSProps: shim.TLSProperties{
Disabled: true, // just for testing good enough
},
}

if err := server.Start(); err != nil {
panic(err)
}
}
42 changes: 42 additions & 0 deletions samples/chaincode/secret-keeper-go/cmd/skvs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright IBM Corp. All Rights Reserved.
Copyright 2020 Intel Corporation
SPDX-License-Identifier: Apache-2.0
*/

package main

import (
"os"

"github.com/hyperledger/fabric-chaincode-go/shim"
"github.com/hyperledger/fabric-contract-api-go/contractapi"
fpc "github.com/hyperledger/fabric-private-chaincode/ecc_go/chaincode"
"github.com/hyperledger/fabric-private-chaincode/samples/chaincode/secret-keeper-go/chaincode"
)

func main() {

ccid := os.Getenv("CHAINCODE_PKG_ID")
addr := os.Getenv("CHAINCODE_SERVER_ADDRESS")

// create chaincode
secretChaincode, _ := contractapi.NewChaincode(&chaincode.SecretKeeper{})
// chaincode := fpc.NewPrivateChaincode(secretChaincode)
skvsChaincode := fpc.NewSkvsChaincode(secretChaincode)

// start chaincode as a service
server := &shim.ChaincodeServer{
CCID: ccid,
Address: addr,
CC: skvsChaincode,
TLSProps: shim.TLSProperties{
Disabled: true, // just for testing good enough
},
}

if err := server.Start(); err != nil {
panic(err)
}
}

0 comments on commit c7028ec

Please sign in to comment.