Skip to content

Commit

Permalink
Merge pull request #290 from aitos-io/boatiotsdk_2_0-dev
Browse files Browse the repository at this point in the history
Candidate for BoAT-X-Framework V2.0.9
  • Loading branch information
flyfft authored Sep 3, 2021
2 parents c5030c1 + 30469cb commit 268b883
Show file tree
Hide file tree
Showing 25 changed files with 517 additions and 457 deletions.
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ BOAT_INCLUDE := -I$(BOAT_BASE_DIR)/include \
-I$(BOAT_SDK_DIR)/protocol/boatplaton \
-I$(BOAT_SDK_DIR)/protocol/boatplatone \
-I$(BOAT_SDK_DIR)/protocol/boatfiscobcos \
-I$(BOAT_SDK_DIR)/third-party/cJSON \
-I$(BOAT_SDK_DIR)/third-party/nghttp2/include \
-I$(BOAT_SDK_DIR)/third-party/protobuf-c/include \
-I$(BOAT_BASE_DIR)/vendor/platform/include \
Expand Down Expand Up @@ -134,17 +133,24 @@ ifeq ($(SOFT_CRYPTO), CRYPTO_DEFAULT)
BOAT_INCLUDE += -I$(BOAT_BASE_DIR)/vendor/common/crypto/crypto_default \
-I$(BOAT_BASE_DIR)/vendor/common/crypto/crypto_default/aes \
-I$(BOAT_BASE_DIR)/vendor/common/crypto/keccak \
-I$(BOAT_BASE_DIR)/vendor/common/storage \
-I$(BOAT_BASE_DIR)/vendor/platform/$(PLATFORM_TARGET)/port_crypto_default
-I$(BOAT_BASE_DIR)/vendor/common/storage
else ifeq ($(SOFT_CRYPTO), CRYPTO_MBEDTLS)
BOAT_INCLUDE += -I$(BOAT_BASE_DIR)/vendor/common/crypto/mbedTLS/include \
-I$(BOAT_BASE_DIR)/vendor/common/crypto/keccak \
-I$(BOAT_BASE_DIR)/vendor/common/storage \
-I$(BOAT_BASE_DIR)/vendor/platform/$(PLATFORM_TARGET)/port_mbedtls
-I$(BOAT_BASE_DIR)/vendor/common/storage
else
BOAT_INCLUDE +=
endif

# cJSON Dependencies
#
# - CJSON_DEFAULT : default cJSON library
# - CJSON_OUTTER : externally provided by users
CJSON_LIBRARY ?= CJSON_OUTTER

ifeq ($(CJSON_LIBRARY), CJSON_DEFAULT)
BOAT_INCLUDE += -I$(BOAT_SDK_DIR)/third-party/cJSON
endif

# Combine FLAGS
BOAT_CFLAGS := $(TARGET_SPEC_CFLAGS) \
Expand All @@ -163,8 +169,10 @@ export BOAT_PROTOCOL_USE_PLATON
export BOAT_PROTOCOL_USE_PLATONE
export BOAT_PROTOCOL_USE_FISCOBCOS
export BOAT_PROTOCOL_USE_HLFABRIC
export BOAT_USE_DEFAULT_CJSON

export SOFT_CRYPTO
export CJSON_LIBRARY
export PLATFORM_TARGET
export BOAT_BASE_DIR
export BOAT_LIB_DIR
Expand Down
1 change: 1 addition & 0 deletions SUPPORTED_LIST.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Supported Blockchain List

+ Ethereum
+ PlatON
+ PlatON Enterprise (PlatONE)
+ FISCO-BCOS
+ Hyperledger Fabric
Expand Down
10 changes: 5 additions & 5 deletions demo/demo_ethereum/demo_ethereum_storeread.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@
* PKCS format demo key. The original private key of 'pkcs_demoKey' is
* "fcf6d76706e66250dbacc9827bc427321edb9542d58a74a67624b253960465ca"
*/
const BCHAR * pkcs_demoKey = "-----BEGIN EC PRIVATE KEY-----\n"
const BCHAR *pkcs_demoKey = "-----BEGIN EC PRIVATE KEY-----\n"
"MHQCAQEEIPz212cG5mJQ26zJgnvEJzIe25VC1Yp0pnYkslOWBGXKoAcGBSuBBAAK\n"
"oUQDQgAEMU/3IAjKpQc8XdURIGQZZJQRHZhPDkp80ahiRAM7KKV9Gmn699pei5fL\n"
"qZlYLvlxdQJsoh2IPyObgGr87gBT7w==\n"
"-----END EC PRIVATE KEY-----\n";
/**
* native demo key
*/
const BCHAR * native_demoKey = "0xfcf6d76706e66250dbacc9827bc427321edb9542d58a74a67624b253960465ca";
const BCHAR *native_demoKey = "0xfcf6d76706e66250dbacc9827bc427321edb9542d58a74a67624b253960465ca";

/**
* test node url
*/
const BCHAR * demoUrl = "http://192.168.132.200:7545";
const BCHAR *demoUrl = "http://192.168.132.200:7545";

/**
* transfer recipient address
*/
const BCHAR * demoRecipientAddress = "0xDED9ea325f8D657614f0F96444ca9DF1d7E2f27c";
const BCHAR *demoRecipientAddress = "0xDED9ea325f8D657614f0F96444ca9DF1d7E2f27c";


BoatEthWallet *g_ethereum_wallet_ptr;
Expand Down Expand Up @@ -213,7 +213,7 @@ BOAT_RESULT ethereum_call_ReadStore(BoatEthWallet *wallet_ptr)
(BCHAR*)prase_result.field_ptr, TRIMBIN_TRIM_NO, BOAT_FALSE);
UtilityChangeEndian(index_u256_big, sizeof(index_u256_big));
list_len = index_u256_big[0];
for(index = 0; index < list_len; index++)
for (index = 0; index < list_len; index++)
{
result_str = StoreRead_readListByIndex(&tx_ctx, index);
result = BoatEthPraseRpcResponseResult(result_str, "", &prase_result);
Expand Down
24 changes: 13 additions & 11 deletions demo/demo_ethereum/demo_ethereum_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@
* PKCS format demo key. The original private key of 'pkcs_demoKey' is
* "fcf6d76706e66250dbacc9827bc427321edb9542d58a74a67624b253960465ca"
*/
const BCHAR * pkcs_demoKey = "-----BEGIN EC PRIVATE KEY-----\n"
"MHQCAQEEIPz212cG5mJQ26zJgnvEJzIe25VC1Yp0pnYkslOWBGXKoAcGBSuBBAAK\n"
"oUQDQgAEMU/3IAjKpQc8XdURIGQZZJQRHZhPDkp80ahiRAM7KKV9Gmn699pei5fL\n"
"qZlYLvlxdQJsoh2IPyObgGr87gBT7w==\n"
"-----END EC PRIVATE KEY-----\n";
const BCHAR *pkcs_demoKey = "-----BEGIN EC PRIVATE KEY-----\n"
"MHQCAQEEIPz212cG5mJQ26zJgnvEJzIe25VC1Yp0pnYkslOWBGXKoAcGBSuBBAAK\n"
"oUQDQgAEMU/3IAjKpQc8XdURIGQZZJQRHZhPDkp80ahiRAM7KKV9Gmn699pei5fL\n"
"qZlYLvlxdQJsoh2IPyObgGr87gBT7w==\n"
"-----END EC PRIVATE KEY-----\n";
/**
* native demo key
*/
const BCHAR * native_demoKey = "0xfcf6d76706e66250dbacc9827bc427321edb9542d58a74a67624b253960465ca";
const BCHAR *native_demoKey = "0xfcf6d76706e66250dbacc9827bc427321edb9542d58a74a67624b253960465ca";

/**
* test node url
*/
const BCHAR * demoUrl = "http://192.168.132.200:7545";
const BCHAR *demoUrl = "http://192.168.132.200:7545";

/**
* transfer recipient address
*/
const BCHAR * demoRecipientAddress = "0x4BeC3cDD520B7985067219F6f596EF7a55Ee5963";
const BCHAR *demoRecipientAddress = "0x4BeC3cDD520B7985067219F6f596EF7a55Ee5963";

BoatEthWallet *g_ethereum_wallet_ptr;

Expand Down Expand Up @@ -98,7 +98,7 @@ __BOATSTATIC BOAT_RESULT ethereum_createOnetimeWallet()
index = BoatWalletCreate(BOAT_PROTOCOL_ETHEREUM, NULL, &wallet_config, sizeof(BoatEthWalletConfig));
if (index == BOAT_ERROR)
{
//BoatLog( BOAT_LOG_CRITICAL, "create one-time wallet failed." );
//BoatLog(BOAT_LOG_CRITICAL, "create one-time wallet failed.");
return BOAT_ERROR;
}
g_ethereum_wallet_ptr = BoatGetWalletByIndex(index);
Expand Down Expand Up @@ -189,7 +189,7 @@ BOAT_RESULT ethereumGetBalance(BoatEthWallet *wallet_ptr)
result = BoatEthPraseRpcResponseResult(cur_balance_wei, "", &prase_result);
if (result == BOAT_SUCCESS)
{
//BoatLog( BOAT_LOG_NORMAL, "BoatEthWalletGetBalance returns: %s", prase_result.field_ptr );
//BoatLog(BOAT_LOG_NORMAL, "BoatEthWalletGetBalance returns: %s", prase_result.field_ptr);
}
else
{
Expand Down Expand Up @@ -259,11 +259,13 @@ int main(int argc, char *argv[])
//BoatLog(BOAT_LOG_NORMAL, "ethereumGetBalance Failed: %d.", result);
}
result = ethereumTransfer(g_ethereum_wallet_ptr);
if (result != BOAT_SUCCESS)

if (result != BOAT_SUCCESS)
{
//BoatLog(BOAT_LOG_NORMAL, "ethereumTransfer Failed: %d.", result);
}
result = ethereumGetBalance(g_ethereum_wallet_ptr);

if (result != BOAT_SUCCESS)
{
//BoatLog(BOAT_LOG_NORMAL, "CaseEthereum Failed: %d.", result);
Expand Down
2 changes: 0 additions & 2 deletions demo/demo_platon/demo_platon_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ BOAT_RESULT platonTransfer(BoatPlatONWallet *wallet_ptr)
int main(int argc, char *argv[])
{
BOAT_RESULT result = BOAT_SUCCESS;
BUINT32 bechaddresslen, i;
BUINT8 address[50];

/* step-1: Boat SDK initialization */
BoatIotSdkInit();
Expand Down
Binary file modified docs/en-us/BoAT_Getting_Started_en.pdf
Binary file not shown.
12 changes: 6 additions & 6 deletions docs/en-us/BoAT_Overall_Design_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ The intended readers of this article are: BoAT SDK detailed designers.


## BoAT Design Goals
As a middleware fusing Blockchain and IoT technologies, It should be easily and quickly transplanted into various IoT modules at the minimum cost of modification. The design of BoAT follows the following goals:
As a middleware fusing Blockchain and IoT technologies, It should be easily and quickly transplanted into various IoT modules at the minimum cost of modification. The design of BoAT is based on these following principles:
+ Hierarchical design
+ Multiple blockchain protocols are supported
+ Scalable design
+ Secret key security design
+ C interface code generation tool for corresponding smart contracts of different blockchains.
+ C interface code generation tool for corresponding smart contracts of different blockchains


## The Position of BoAT SDK in The Entire Blockchain Network
Expand All @@ -37,7 +37,7 @@ Figure 3-1 The position of BoAT in the blockchain interactive network

## BoAT Implementation Framework
Boat follows a hierarchical design consisting of Interface Layer, Protocol Layer, RPC Layer, Vendor Dependency Layer, Tool and Utility. The specific functions of each layer are as follows:
+ Interface Layer: Provide an interface for users to invoke the corresponding blockchain.
+ Interface Layer: Provide an interface for IoT Application to invoke the corresponding blockchain.
+ Protocol Layer: The main implementation of each block chain protocol.
+ RPC Layer: Provide services to the protocol layer.
+ Vendor Dependency Layer: Provide cryptographic algorithms, signature, storage and other services for the interface layer wallet.
Expand All @@ -51,7 +51,7 @@ Figure 4-1 BoAT Overall Framework
### Interface Layer

#### Overview
The interface layer is located at the top layer of BoAT and provides users with access to each blockchain. The interface layer consists of two parts:
The interface layer is located at the top layer of BoAT and provides IoT applications with access to each blockchain. The interface layer consists of two parts:
+ Wallet interface
* The wallet interface is the entrance to the BoAT SDK, and different blockchains have a common wallet entrance.
+ Transaction interface
Expand Down Expand Up @@ -456,8 +456,8 @@ The vendor dependency layer should provide a pure software implementation of the

#### TEE Support
The design of BoAT should consider the support of TEE environment. For hardware with a TEE environment, BoAT should be able to put sensitive information in the TEE environment with a small amount of modification. To meet this goal, the wallet is designed to meet the following criteria:
+ Independent design of wallet-related data structure
+ Wallet related implementation independent design
+ Wallet related data structure modular design
+ Wallet related implementation modular design
+ Sensitive information related to the wallet is not reflected outside the wallet

### General Tool Implementation
Expand Down
40 changes: 20 additions & 20 deletions docs/en-us/BoAT_System_Requirements_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
In this article, we discribe system requirements for BoAT Framework (C language version) on cellular modules. BoAT is an SDK that runs on the module's application processor. For the cellular module with an OpenCPU, BoAT is linked and called by the application as a library. For cellular modules without OpenCPU,BoAT APIs will be wrapped into AT commands to works fine in host MCUs.

### Abbreviated Terms
|Term |Explanation |
|:----- |:--------------------------- |
|BoAT|Blockchain of AI Things|
|SDK|Software Development Kit|
|API|Application Programming Interface|
|MCU|Microcontroller Unit|
|RTOS|Real Time Operating System|
|TRNG|True Random Number Generator|
|CSPRNG|Cryptographically Secure Pseudo-Random Number Generator|
|RTC|Real Time Clock|
|NTP|Network Time Protocol|
|HTTP|Hyper Text Transfer Protocol|
|HTTPs|Hyper Text Transfer Protocol Secure|
|CoAP|Constrained Application Protocol|
|MQTT|Message Queuing Telemetry Transport|
|TCP|Transmission Control Protocol|
|TEE|Trusted Execution Environment|
|TA|Trusted Application|
|ECDSA|Elliptic Curve Digital Signature Algorithm|
|SHA2|Secure Hash Algorithm 2|
|Term |Explanation |
|:----- |:----------------------------------------------------- |
|BoAT |Blockchain of AI Things |
|SDK |Software Development Kit |
|API |Application Programming Interface |
|MCU |Microcontroller Unit |
|RTOS |Real Time Operating System |
|TRNG |True Random Number Generator |
|CSPRNG |Cryptographically Secure Pseudo-Random Number Generator|
|RTC |Real Time Clock |
|NTP |Network Time Protocol |
|HTTP |Hyper Text Transfer Protocol |
|HTTPs |Hyper Text Transfer Protocol Secure |
|CoAP |Constrained Application Protocol |
|MQTT |Message Queuing Telemetry Transport |
|TCP |Transmission Control Protocol |
|TEE |Trusted Execution Environment |
|TA |Trusted Application |
|ECDSA |Elliptic Curve Digital Signature Algorithm |
|SHA2 |Secure Hash Algorithm 2 |


## Part 1 Storage Requirements
Expand Down
Loading

0 comments on commit 268b883

Please sign in to comment.