-
Notifications
You must be signed in to change notification settings - Fork 97
fix::> confidential escrow example - LFX25 #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6b30633
fix::> init confidential escrow
PsychoPunkSage 84833e9
fix::> Added Create and read transaction
PsychoPunkSage 2b1f157
fix::>> changed some of the params
PsychoPunkSage 292094e
fix::> integrated txns
PsychoPunkSage 3e597b7
fix::> README.md updated
PsychoPunkSage 8da643c
fix::> 2 automation script added
PsychoPunkSage 51eab0f
fix::> Changed ACLs and corrected READ logics fo alll assets
PsychoPunkSage a144e96
fix::>> Removed/cleanup unnecessary fields
PsychoPunkSage 9dbf17c
fix::>> made a unified setup scripts. source file and cleaneup useles…
PsychoPunkSage 359f381
fix::> Made a minimalistic main.go + a dedicated go modules for this …
PsychoPunkSage 2061cb0
fix::>> modified ssets den
PsychoPunkSage b672204
fix::> Modified CRUD ops based on changes
PsychoPunkSage 6a177c2
fix::> Made main script bit more slimer + updated Readme
PsychoPunkSage fd350c8
update setup.go with new functionality
PsychoPunkSage e416c3e
fix::> Addn of new functionality for Token... + cleanup
PsychoPunkSage 9cfd367
fix::> Get balance + get wallet by owner added
PsychoPunkSage bdb3fec
fix::> Updated scripts
PsychoPunkSage File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
57 changes: 57 additions & 0 deletions
57
samples/chaincode/confidential-escrow/chaincode/assets/digital_asset.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}, | ||
} |
69 changes: 69 additions & 0 deletions
69
samples/chaincode/confidential-escrow/chaincode/assets/escrow.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}, | ||
} |
33 changes: 33 additions & 0 deletions
33
samples/chaincode/confidential-escrow/chaincode/assets/user_directory.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}, | ||
} |
52 changes: 52 additions & 0 deletions
52
samples/chaincode/confidential-escrow/chaincode/assets/wallet.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.