-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package org.fisco.smart; | ||
|
||
// deprecated. using console.sh to sendCall to contract | ||
public class SmartInferenceClient { | ||
|
||
} |
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
call InferencePrecompiled 0x0000000000000000000000000000000000006000 predict "cd /home/junqin/examples/pytorch && python3 pytorchexample.py" | ||
call InferencePrecompiled 0x0000000000000000000000000000000000006000 predict "cd /home/junqin/fisco-smart/tee-provider && python3 pytorchexample.py" |
This file contains 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 @@ | ||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"get_all_reg_info","outputs":[{"components":[{"internalType":"address","name":"tee_provider","type":"address"},{"internalType":"string","name":"enc_ppid","type":"string"}],"internalType":"struct TPM.reg_info[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"get_latest_reg_info","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"enc_ppid","type":"string"}],"name":"register_enc_ppid","outputs":[],"stateMutability":"nonpayable","type":"function"}] |
This file contains 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 @@ | ||
608060405234801561001057600080fd5b5060408051808201909152601d8082527f5445452050726f7669646572204d616e6167657220436f6e747261637400000060209092019182526100559160009161005b565b5061012f565b828054610067906100f4565b90600052602060002090601f01602090048101928261008957600085556100cf565b82601f106100a257805160ff19168380011785556100cf565b828001600101855582156100cf579182015b828111156100cf5782518255916020019190600101906100b4565b506100db9291506100df565b5090565b5b808211156100db57600081556001016100e0565b600181811c9082168061010857607f821691505b6020821081141561012957634e487b7160e01b600052602260045260246000fd5b50919050565b6106468061013e6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80633a52604914610046578063942542f814610065578063cbcc10c11461007a575b600080fd5b61004e61008f565b60405161005c92919061042a565b60405180910390f35b61006d610195565b60405161005c9190610456565b61008d6100883660046104e9565b61029b565b005b600180546000916060916100a490829061059a565b815481106100b4576100b46105bf565b6000918252602090912060029091020154600180546001600160a01b03909216916100e090829061059a565b815481106100f0576100f06105bf565b906000526020600020906002020160010180805461010d906105d5565b80601f0160208091040260200160405190810160405280929190818152602001828054610139906105d5565b80156101865780601f1061015b57610100808354040283529160200191610186565b820191906000526020600020905b81548152906001019060200180831161016957829003601f168201915b50505050509050915091509091565b60606001805480602002602001604051908101604052809291908181526020016000905b82821015610292576000848152602090819020604080518082019091526002850290910180546001600160a01b031682526001810180549293919291840191610201906105d5565b80601f016020809104026020016040519081016040528092919081815260200182805461022d906105d5565b801561027a5780601f1061024f5761010080835404028352916020019161027a565b820191906000526020600020905b81548152906001019060200180831161025d57829003601f168201915b505050505081525050815260200190600101906101b9565b50505050905090565b604080518082019091523381526020808201838152600180548082018255600091909152835160029091027fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6810180546001600160a01b03939093166001600160a01b031990931692909217825591518051919361033e937fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf70192910190610344565b50505050565b828054610350906105d5565b90600052602060002090601f01602090048101928261037257600085556103b8565b82601f1061038b57805160ff19168380011785556103b8565b828001600101855582156103b8579182015b828111156103b857825182559160200191906001019061039d565b506103c49291506103c8565b5090565b5b808211156103c457600081556001016103c9565b6000815180845260005b81811015610403576020818501810151868301820152016103e7565b81811115610415576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009061044e908301846103dd565b949350505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b838110156104c557888303603f19018552815180516001600160a01b031684528701518784018790526104b2878501826103dd565b958801959350509086019060010161047d565b509098975050505050505050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156104fb57600080fd5b813567ffffffffffffffff8082111561051357600080fd5b818401915084601f83011261052757600080fd5b813581811115610539576105396104d3565b604051601f8201601f19908116603f01168101908382118183101715610561576105616104d3565b8160405282815287602084870101111561057a57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000828210156105ba57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052603260045260246000fd5b600181811c908216806105e957607f821691505b6020821081141561060a57634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220df1ae93e98681b0ed3cef5d16f365db898a6b44094479d71c7537bed3f2e4f0164736f6c634300080b0033 |
1 change: 1 addition & 0 deletions
1
console/contracts/.compiled/group0/TPM/0x6849f21d1e455e9f0712b1e99fa4fcd23758e8f1/TPM.abi
This file contains 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 @@ | ||
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"get_all_reg_info","outputs":[{"components":[{"internalType":"address","name":"tee_provider","type":"address"},{"internalType":"string","name":"enc_ppid","type":"string"}],"internalType":"struct TPM.reg_info[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"get_latest_reg_info","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"enc_ppid","type":"string"}],"name":"register_enc_ppid","outputs":[],"stateMutability":"nonpayable","type":"function"}] |
1 change: 1 addition & 0 deletions
1
console/contracts/.compiled/group0/TPM/0x6849f21d1e455e9f0712b1e99fa4fcd23758e8f1/TPM.bin
This file contains 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 @@ | ||
608060405234801561001057600080fd5b5060408051808201909152601d8082527f5445452050726f7669646572204d616e6167657220436f6e747261637400000060209092019182526100559160009161005b565b5061012f565b828054610067906100f4565b90600052602060002090601f01602090048101928261008957600085556100cf565b82601f106100a257805160ff19168380011785556100cf565b828001600101855582156100cf579182015b828111156100cf5782518255916020019190600101906100b4565b506100db9291506100df565b5090565b5b808211156100db57600081556001016100e0565b600181811c9082168061010857607f821691505b6020821081141561012957634e487b7160e01b600052602260045260246000fd5b50919050565b6106468061013e6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80633a52604914610046578063942542f814610065578063cbcc10c11461007a575b600080fd5b61004e61008f565b60405161005c92919061042a565b60405180910390f35b61006d610195565b60405161005c9190610456565b61008d6100883660046104e9565b61029b565b005b600180546000916060916100a490829061059a565b815481106100b4576100b46105bf565b6000918252602090912060029091020154600180546001600160a01b03909216916100e090829061059a565b815481106100f0576100f06105bf565b906000526020600020906002020160010180805461010d906105d5565b80601f0160208091040260200160405190810160405280929190818152602001828054610139906105d5565b80156101865780601f1061015b57610100808354040283529160200191610186565b820191906000526020600020905b81548152906001019060200180831161016957829003601f168201915b50505050509050915091509091565b60606001805480602002602001604051908101604052809291908181526020016000905b82821015610292576000848152602090819020604080518082019091526002850290910180546001600160a01b031682526001810180549293919291840191610201906105d5565b80601f016020809104026020016040519081016040528092919081815260200182805461022d906105d5565b801561027a5780601f1061024f5761010080835404028352916020019161027a565b820191906000526020600020905b81548152906001019060200180831161025d57829003601f168201915b505050505081525050815260200190600101906101b9565b50505050905090565b604080518082019091523381526020808201838152600180548082018255600091909152835160029091027fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6810180546001600160a01b03939093166001600160a01b031990931692909217825591518051919361033e937fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf70192910190610344565b50505050565b828054610350906105d5565b90600052602060002090601f01602090048101928261037257600085556103b8565b82601f1061038b57805160ff19168380011785556103b8565b828001600101855582156103b8579182015b828111156103b857825182559160200191906001019061039d565b506103c49291506103c8565b5090565b5b808211156103c457600081556001016103c9565b6000815180845260005b81811015610403576020818501810151868301820152016103e7565b81811115610415576000602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b038316815260406020820181905260009061044e908301846103dd565b949350505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b838110156104c557888303603f19018552815180516001600160a01b031684528701518784018790526104b2878501826103dd565b958801959350509086019060010161047d565b509098975050505050505050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156104fb57600080fd5b813567ffffffffffffffff8082111561051357600080fd5b818401915084601f83011261052757600080fd5b813581811115610539576105396104d3565b604051601f8201601f19908116603f01168101908382118183101715610561576105616104d3565b8160405282815287602084870101111561057a57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000828210156105ba57634e487b7160e01b600052601160045260246000fd5b500390565b634e487b7160e01b600052603260045260246000fd5b600181811c908216806105e957607f821691505b6020821081141561060a57634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220df1ae93e98681b0ed3cef5d16f365db898a6b44094479d71c7537bed3f2e4f0164736f6c634300080b0033 |
This file contains 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,28 @@ | ||
pragma solidity>=0.6.10 <0.8.20; | ||
|
||
contract TPM { | ||
string contract_name; | ||
|
||
struct reg_info { | ||
address tee_provider; | ||
string enc_ppid; | ||
} | ||
|
||
reg_info[] ris; | ||
|
||
constructor() { | ||
contract_name = "TEE Provider Manager Contract"; | ||
} | ||
|
||
function get_all_reg_info() public view returns (reg_info[] memory) { | ||
return ris; | ||
} | ||
|
||
function get_latest_reg_info() public view returns (address, string memory) { | ||
return (ris[ris.length-1].tee_provider, ris[ris.length-1].enc_ppid); | ||
} | ||
|
||
function register_enc_ppid(string memory enc_ppid) public { | ||
ris.push(reg_info({tee_provider: msg.sender, enc_ppid: enc_ppid})); | ||
} | ||
} |
This file contains 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
This file contains 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,46 @@ | ||
#!/bin/bash | ||
|
||
WORK_DIR=$(pwd) | ||
|
||
function getTiming(){ | ||
start=$1 | ||
end=$2 | ||
|
||
start_s=$(echo $start | cut -d '.' -f 1) | ||
start_ns=$(echo $start | cut -d '.' -f 2) | ||
end_s=$(echo $end | cut -d '.' -f 1) | ||
end_ns=$(echo $end | cut -d '.' -f 2) | ||
|
||
|
||
take=$(( ( 10#$end_s - 10#$start_s ) * 1000 + ( 10#$end_ns / 1000000 - 10#$start_ns / 1000000 ) )) | ||
|
||
echo $take | ||
} | ||
|
||
contract_address=$(cat console/deploylog.txt | grep TPM | awk '{print $5}') | ||
|
||
# retrieve enc_ppid from PCE (need root privilege) and request to attestation service | ||
start=$(date +%s.%N) | ||
|
||
cd /opt/intel/sgx-pck-id-retrieval-tool/ && sudo ./PCKIDRetrievalTool | ||
|
||
end=$(date +%s.%N) | ||
take=$(getTiming $start $end) | ||
echo -e "\033[34m [TIME] It takes ${take} ms for blockchain node to update PCK database \033[0m" # 7722, 6809 | ||
|
||
enc_ppid=$(cat /opt/intel/sgx-pck-id-retrieval-tool/pckid_retrieval.csv | awk -F, '{print $1}') | ||
|
||
# register enc_ppid with tee_provider account in the TPM contract | ||
echo -e "\033[34m Register TEE provider in the TPM \033[0m" | ||
|
||
start=$(date +%s.%N) | ||
|
||
cd ${WORK_DIR}/console && bash console.sh call TPM $contract_address register_enc_ppid $enc_ppid | ||
|
||
end=$(date +%s.%N) | ||
take=$(getTiming $start $end) | ||
|
||
echo -e "\033[34m [TIME] It takes ${take} ms for TEE provider registration \033[0m" # 2426, 2486 | ||
|
||
echo -e "\033[34m Query registered TEE provider \033[0m" | ||
bash console.sh call TPM $contract_address get_latest_reg_info |
This file contains 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