Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ replace google.golang.org/grpc => google.golang.org/grpc v1.29.1
require (
github.com/client9/misspell v0.3.4
github.com/golang/protobuf v1.5.3
github.com/hyperledger/fabric v1.4.0-rc1.0.20230405174026-695dd57e01c2
github.com/hyperledger-labs/cc-tools v1.0.2
github.com/hyperledger/fabric v2.1.1+incompatible
github.com/hyperledger/fabric-chaincode-go v0.0.0-20230228194215-b84622ba6a7a
github.com/hyperledger/fabric-contract-api-go v1.2.1
github.com/hyperledger/fabric-protos-go v0.3.0
Expand All @@ -46,21 +47,12 @@ require (
require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/IBM/idemix v0.0.2-0.20231107110441-534ea4193b8f // indirect
github.com/IBM/idemix/bccsp/schemes/aries v0.0.0-20231107110234-4cf31dd43660 // indirect
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20231107110234-4cf31dd43660 // indirect
github.com/IBM/idemix/bccsp/types v0.0.0-20231107110234-4cf31dd43660 // indirect
github.com/IBM/mathlib v0.0.3-0.20231011094432-44ee0eb539da // indirect
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ale-linux/aries-framework-go/component/kmscrypto v0.0.0-20231023164747-f3f972769504 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/cfssl v1.4.1 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/containerd/containerd v1.7.13 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -85,6 +77,7 @@ require (
github.com/google/certificate-transparency-go v1.0.21 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 // indirect
Expand All @@ -93,14 +86,12 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/joho/godotenv v1.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
Expand Down Expand Up @@ -145,5 +136,4 @@ require (
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
49 changes: 14 additions & 35 deletions go.sum

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions samples/chaincode/confidential-escrow/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export CC_ID=confidential-escrow
export CHANNEL_NAME=mychannel
export CORE_PEER_ADDRESS=localhost:7051
export CORE_PEER_ID=peer0.org1.example.com
export CORE_PEER_ORG_NAME=org1
export CORE_PEER_LOCALMSPID=Org1MSP
export CORE_PEER_MSPCONFIGPATH=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/[email protected]/msp
export CORE_PEER_TLS_CERT_FILE=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
export CORE_PEER_TLS_ENABLED="true"
export CORE_PEER_TLS_KEY_FILE=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
export CORE_PEER_TLS_ROOTCERT_FILE=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export ORDERER_CA=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
export GATEWAY_CONFIG=$FPC_PATH/samples/deployment/test-network/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/connection-org1.yaml
export FPC_ENABLED=true
export RUN_CCAAS=true
10 changes: 10 additions & 0 deletions samples/chaincode/confidential-escrow/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ecc
ecc-bundle
enclave.json
private.pem
public.pem
mrenclave
details.env

.env
*.bak
7 changes: 7 additions & 0 deletions samples/chaincode/confidential-escrow/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TOP = ../../..
include $(TOP)/ecc_go/build.mk

CC_NAME ?= confidential-escrow

EGO_CONFIG_FILE = $(FPC_PATH)/samples/chaincode/confidential-escrow/confidentialEscrowEnclave.json
ECC_MAIN_FILES=$(FPC_PATH)/samples/chaincode/confidential-escrow
85 changes: 85 additions & 0 deletions samples/chaincode/confidential-escrow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Running Procedure

## Prerequisites

- FPC is properly set up and built
- `main.sh` script is placed in the chaincode directory
- `.env` file is created with environment variables

## Setup Files

**1. Set FPC_PATH:**

```bash
export FPC_PATH=/project/src/github.com/hyperledger/fabric-private-chaincode
```

**2. Create .env file:**

```bash
touch .env
# Add all environment variables as provided in the .env artifact
cp .env.example .env
```

## Running Procedure

### 1. In 1st terminal window - Setup and Deploy

```bash
# Get inside dev env
make -C $FPC_PATH/utils/docker run-dev
cd samples/chaincode/confidential-escrow

# Interactive menu
./main.sh

## For first time setup (includes ERCC build/Fabric network)
./main.sh full

## For subsequent runs (skip ERCC build)
./main.sh quick
```

### 2. In 2nd terminal window - Docker Environment

```bash
# Enter docker container
docker exec -it fpc-development-main /bin/bash
cd samples/chaincode/confidential-escrow

# Interactive menu
./main.sh

# Setup client environment and initialize enclave
./main.sh docker
```

### 3. Run Transactions

```bash
# Run all basic tests
./main.sh test-all
```

## Available Commands

| Command | Description |
| ---------------------- | ----------------------------------- |
| `./main.sh full` | Complete setup including ERCC build |
| `./main.sh quick` | Quick setup (skip ERCC build) |
| `./main.sh chaincode` | Build chaincode only |
| `./main.sh docker` | Setup docker environment |
| `./main.sh test-basic` | Run basic creation tests |
| `./main.sh test-query` | Run query tests |
| `./main.sh test-all` | Run all tests |
| `./main.sh clean` | Clean and stop network |
| `./main.sh` | Interactive menu |

## Typical Workflow

1. **First time:** `./main.sh full`
2. **Enter docker:** `docker exec -it fpc-development-main /bin/bash`
3. **Setup client:** `./main.sh docker`
4. **Run tests:** `./main.sh test-all`
5. **Code changes:** Exit docker → `./main.sh chaincode` → Re-enter docker → Test again
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package assets

import (
"github.com/hyperledger-labs/cc-tools/assets"
)

var DigitalAssetToken = assets.AssetType{
Tag: "digitalAsset",
Label: "Digital Asset Token",
Description: "Confidential digital currency token (e.g., CBDC)",

Props: []assets.AssetProp{
{
Tag: "name",
Label: "Token Name",
DataType: "string",
Required: true,
},
{
Tag: "symbol",
Label: "Token Symbol",
DataType: "string",
Required: true,
IsKey: true,
},
{
Tag: "decimals",
Label: "Decimal Places",
DataType: "number",
Required: true,
},
{
Tag: "totalSupply",
Label: "Total Supply",
DataType: "number",
Required: true,
},
{
Tag: "issuerHash",
Label: "Issuer Certificate Hash",
DataType: "string",
Required: true,
},
{
Tag: "owner",
Label: "Owner Identity",
DataType: "string",
Required: true,
},
{
Tag: "issuedAt",
Label: "Issued At",
DataType: "datetime",
Required: false,
},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package assets

import (
"github.com/hyperledger-labs/cc-tools/assets"
)

var Escrow = assets.AssetType{
Tag: "escrow",
Label: "Programmable Escrow",
Description: "Confidential escrow contract with programmable conditions",

Props: []assets.AssetProp{
{
Tag: "escrowId",
Label: "Escrow ID",
DataType: "string",
Required: true,
IsKey: true,
},
{
Tag: "buyerPubKey",
Label: "Buyer Public Key",
DataType: "string",
Required: true,
},
{
Tag: "sellerPubKey",
Label: "Seller Public Key",
DataType: "string",
Required: true,
},
{
Tag: "amount",
Label: "Escrowed Amount",
DataType: "number",
Required: true,
},
{
Tag: "assetType",
Label: "Asset Type Reference",
DataType: "->digitalAsset", // References digitalAsset symbol
Required: true,
},
{
Tag: "conditionValue",
Label: "Condition Value",
DataType: "string",
Required: true,
},
{
Tag: "status",
Label: "Escrow Status",
DataType: "string", // "Active", "Released", "Refunded"
Required: true,
},
{
Tag: "createdAt",
Label: "Creation Timestamp",
DataType: "datetime",
Required: false,
},
{
Tag: "buyerCertHash",
Label: "Buyer Certificate Hash",
DataType: "string",
Required: true,
},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package assets

import (
"github.com/hyperledger-labs/cc-tools/assets"
)

var UserDirectory = assets.AssetType{
Tag: "userdir",
Label: "User Directory",
Description: "Maps user public key hash to wallet ID for authentication",

Props: []assets.AssetProp{
{
Tag: "publicKeyHash",
Label: "Public Key Hash",
DataType: "string",
Required: true,
IsKey: true,
},
{
Tag: "walletId",
Label: "Associated Wallet ID",
DataType: "string",
Required: true,
},
{
Tag: "certHash",
Label: "Certificate Hash",
DataType: "string",
Required: true,
},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package assets

import (
"github.com/hyperledger-labs/cc-tools/assets"
)

// Wallet represents a confidential user wallet
var Wallet = assets.AssetType{
Tag: "wallet",
Label: "User Wallet",
Description: "Confidential wallet holding digital assets",

Props: []assets.AssetProp{
{
Tag: "walletId",
Label: "Wallet ID",
DataType: "string",
Required: true,
IsKey: true, // primary key
},
{
Tag: "ownerId",
Label: "Owner Identity",
DataType: "string",
Required: true,
},
{
Tag: "ownerCertHash",
Label: "Owner Certificate Hash",
DataType: "string",
Required: true,
},
{
Tag: "balances",
Label: "Token Balance",
DataType: "[]number",
Required: true,
},
{
Tag: "digitalAssetTypes",
Label: "Asset Type Reference",
DataType: "[]->digitalAsset", // References digitalAsset
Required: true,
},
{
Tag: "createdAt",
Label: "Creation Timestamp",
DataType: "datetime",
Required: false,
},
},
}
Loading