Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
5e412d6
add filecoin files
wyoyw Oct 15, 2020
7924286
修改filecoin path ,签名的指令,测试的地址
Oct 16, 2020
aa59de7
feat: add the framework build script
XuNeal Oct 20, 2020
c7dcfbf
Update test data
wyoyw Oct 20, 2020
2d33cb1
Delete unused imports
wyoyw Oct 20, 2020
b4dc0a7
Submit the dev environment library
wyoyw Oct 20, 2020
b6e4fc9
feat: fix build conflict with tcx
XuNeal Oct 22, 2020
ee2f9e6
Merge remote-tracking branch 'origin/feat-filecoin' into feature/imke…
XuNeal Oct 22, 2020
6d57428
add tron project
xiemener Oct 22, 2020
849bc61
fix: update bitcoin 0.25.1
XuNeal Oct 23, 2020
4b4120c
Modify filecoin command and typos
wyoyw Oct 26, 2020
0ab0e15
Merge remote-tracking branch 'origin/feat-filecoin' into feature/imke…
XuNeal Oct 26, 2020
1c93736
feat: refactor the api design
XuNeal Oct 27, 2020
276dd54
add tron api
xiemener Oct 28, 2020
e50f5d2
add tron functions
xiemener Oct 28, 2020
3c40702
fmt code
xiemener Oct 28, 2020
561c389
feat: add the init_icx, refactor the bitcoin wallet result
XuNeal Oct 28, 2020
037f1c2
feat: remove the filepath from bind_check
XuNeal Oct 28, 2020
df73b6e
refactor the sign param
XuNeal Oct 28, 2020
4e0c7db
Merge branch 'dev' into feature/tron
xiemener Oct 28, 2020
7e4bf93
Merge branch 'dev' into feature/tron
xiemener Oct 28, 2020
dafcb55
feat: refactor the eos wallet
XuNeal Oct 28, 2020
eef750c
refactor the message sign api
XuNeal Oct 29, 2020
32940bb
refactor: eos and eth signature result struct
XuNeal Oct 29, 2020
27753f1
refactor: use the same btctx struct with old imkeyConnector
XuNeal Oct 29, 2020
aa3548b
fix address
xiemener Oct 29, 2020
832b067
fix sign
xiemener Oct 29, 2020
25c0fe7
fix sign
xiemener Oct 31, 2020
5cf4de6
correct the sign result
xiemener Nov 1, 2020
db05766
fix sign test
xiemener Nov 1, 2020
e0be119
remove last 00 flag at sign message apdu
xiemener Nov 2, 2020
508b060
remove logs
xiemener Nov 2, 2020
831d3c8
add missing semicolon
xiemener Nov 2, 2020
ebeabd2
chore: fix eos unpack warning
XuNeal Nov 2, 2020
76bb008
Update the compiled android library for staging
wyoyw Nov 2, 2020
6a5a90b
fix: append a slash to the path
XuNeal Nov 2, 2020
8016092
fix app id mapping problem
xiaoguang1010 Nov 2, 2020
2b2f6ec
filecoin uses the public k1 applet
wyoyw Nov 2, 2020
8bb80a9
filecoin uses the public k1 applet
wyoyw Nov 2, 2020
cf0a268
Merge remote-tracking branch 'origin/feature/imkey_core_integration' …
wyoyw Nov 2, 2020
f98c4ee
fix torn verify sign and select issue
xiemener Nov 3, 2020
09f1687
Merge remote-tracking branch 'origin/hotfix-multi-instance' into feat…
XuNeal Nov 3, 2020
af5c64d
Compile the latest package for the staging environment
wyoyw Nov 3, 2020
64e17c2
modify the name of the binding key file
xiaoguang1010 Nov 3, 2020
9f35027
Compile the latest package for the staging environment
wyoyw Nov 3, 2020
da539af
align result format with old sdk
xiemener Nov 4, 2020
86b7f9d
remove cos version format code
xiemener Nov 4, 2020
15a3bcf
Compile the latest package for the staging environment
wyoyw Nov 4, 2020
bcf429a
check ble name & undecode charging flag
xiemener Nov 4, 2020
263d3af
Merge branch 'feature/imkey_core_integration' of github.com:consenlab…
xiemener Nov 4, 2020
b69347a
When auth_code is wrong, throw Err instead
wyoyw Nov 4, 2020
775f98f
Merge remote-tracking branch 'origin/feature/imkey_core_integration' …
wyoyw Nov 4, 2020
c3b0401
Compile the latest package for the staging environment
wyoyw Nov 5, 2020
015d7f9
fix: display address not append index
XuNeal Nov 5, 2020
de3331c
Firmware version bug fix
wyoyw Nov 5, 2020
b5ec3b3
Compile the latest package for the staging environment
wyoyw Nov 5, 2020
a95cbac
fix: eth hex arguemnt parse and btc data hex parse error
XuNeal Nov 10, 2020
343dc0d
fix some sign test
xiemener Nov 11, 2020
86b83b8
Merge branch 'feature/imkey_core_integration' of github.com:consenlab…
xiemener Nov 11, 2020
8d5d748
revert host address
xiemener Nov 11, 2020
23e3400
format code
xiemener Nov 11, 2020
23ed988
Unit test case modification
wyoyw Nov 11, 2020
9301cf0
Change the version number to 2.0.0
wyoyw Nov 12, 2020
86acc60
fix all unit tests
xiemener Nov 12, 2020
0764592
Merge branch 'feature/imkey_core_integration' of github.com:consenlab…
xiemener Nov 12, 2020
9dd9f44
fix: eth sign unwrap error
XuNeal Nov 13, 2020
c9e5343
revert toolchain version
xiemener Nov 13, 2020
bb9ebbc
fix: fil cid incorrect
wyoyw Nov 20, 2020
00ab7ef
Merge remote-tracking branch 'origin/feature/imkey_core_integration' …
wyoyw Nov 20, 2020
0d2dff3
fix: throw unknown error when pair imkey
XuNeal Nov 18, 2020
6a84aad
fix: openssl compile error
XuNeal Nov 21, 2020
4d3ba72
fix read keys error
xiemener Nov 21, 2020
08f3be4
Merge branch 'feature/imkey_core_integration' of github.com:consenlab…
xiemener Nov 21, 2020
113a1d3
compare system ignore caps
XuNeal Nov 23, 2020
1bdf433
optimize keys reading logic
xiemener Nov 23, 2020
c7c3e4e
rename appName define
XuNeal Nov 30, 2020
d9cd859
add substrate
xiemener Dec 7, 2020
3b63858
add transaction test
xiemener Dec 7, 2020
e988cb2
fix select applet error
xiemener Dec 8, 2020
f3647ea
fix sig verify error
xiemener Dec 8, 2020
c220f87
fix sign tx unit test
xiemener Dec 8, 2020
d80785e
support kusama
xiemener Dec 8, 2020
3220882
add substrate api
xiemener Dec 9, 2020
7340af7
add ksm instant id
XuNeal Dec 9, 2020
037e8a5
fix merge error
XuNeal Dec 9, 2020
0448c0b
fix type build error
xiemener Dec 9, 2020
c0dbadf
resolve conflict
xiemener Dec 10, 2020
57e3e57
fix build error
xiemener Dec 10, 2020
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,9 @@ fastlane/test_output
.DS_Store

libconnector.a


tools/ios-internal-release.sh
tools/android-internal-release.sh
ios-release/**
mobile-sdk/imKeyCoreX/Products/
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ members = [
"wallet/coin-ethereum",
"wallet/coin-eos",
"wallet/coin-cosmos",
"wallet/coin-tron",
"wallet/coin-substrate",
]
49 changes: 49 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SHELL := /bin/bash

.PHONY: test

help: ##@other show help
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)

# This is a code for automatic help generator.
# To add new item into help output, simply add comments
# starting with '##'. To add category, use @category.
GREEN := $(shell tput -Txterm setaf 2)
WHITE := $(shell tput -Txterm setaf 7)
YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
HELP_FUN = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z0-9\-]+)\s*:.*\#\#(?:@([a-zA-Z0-9\-]+))?\s(.*)$$/ }; \
print "Usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; \
}

build-ios-example: ##@build generate the iOS compiled file
./tools/ios-example-build.sh

build-ios-rn-example: ##@build generate the iOS RN compiled file
sh ./tools/ios-rn-example-build.sh

build-android-rn-example: ##@build generate the Android RN compiled file
sh ./tools/android-rn-example-build.sh

internal-release-android:
./tools/android-token-v2-build.sh

internal-release-ios: ##@build generate the Android RN compiled file
sh ./tools/ios-framework-build.sh
sh ./tools/ios-internal-release.sh $(VER)

e2e: ##@test run e2e test
(cd examples/RN && yarn)
(cd examples/RN/ios && pod install)
(cd examples/RN && yarn pbjs)
(cd examples/RN && yarn e2e)

18 changes: 16 additions & 2 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ coin-ethereum = {path = "../wallet/coin-ethereum"}
coin-bitcoin = {path = "../wallet/coin-bitcoin"}
coin-eos = {path = "../wallet/coin-eos"}
coin-cosmos = {path = "../wallet/coin-cosmos"}
coin-tron = {path = "../wallet/coin-tron"}
coin-filecoin = {path = "../wallet/coin-filecoin"}
coin-substrate = {path = "../wallet/coin-substrate"}
common = {path = "../common"}
bitcoin = "0.21.0"
bitcoin = "0.25.0"
ethereum-types = "0.6.0"
prost = "0.6.1"
bytes = "0.5.4"
Expand All @@ -26,7 +29,18 @@ hex = "0.4.2"
failure = "0.1.8"
linked-hash-map = { version = "0.5.3", features = ["serde_impl"] }
serde_json = { version = "1.0.53", default-features = false, features = ["alloc"] }
base64 = "0.10.1"
parking_lot = "0.10"

[lib]
name="connector"
crate-type=["staticlib","cdylib"]
crate-type=["staticlib","cdylib"]
#
#[target.aarch64-linux-android.dependencies]
#openssl = { version = "*", features = ["vendored"] }
#[target.armv7-linux-androideabi.dependencies]
#openssl = { version = "*", features = ["vendored"] }
#[target.i686-linux-android.dependencies]
#openssl = { version = "*", features = ["vendored"] }
#[target.x86_64-linux-android.dependencies]
#openssl = { version = "*", features = ["vendored"] }
110 changes: 110 additions & 0 deletions api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,113 @@ pub struct CommonResponse {
#[prost(string, tag = "1")]
pub result: std::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AddressParam {
#[prost(string, tag = "1")]
pub chain_type: std::string::String,
#[prost(string, tag = "2")]
pub path: std::string::String,
#[prost(string, tag = "3")]
pub network: std::string::String,
#[prost(bool, tag = "4")]
pub is_seg_wit: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AddressResult {
#[prost(string, tag = "1")]
pub path: std::string::String,
#[prost(string, tag = "2")]
pub chain_type: std::string::String,
#[prost(string, tag = "3")]
pub address: std::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubKeyParam {
#[prost(string, tag = "1")]
pub chain_type: std::string::String,
#[prost(string, tag = "2")]
pub path: std::string::String,
#[prost(string, tag = "3")]
pub network: std::string::String,
#[prost(string, tag = "4")]
pub is_seg_wit: std::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubKeyResult {
#[prost(string, tag = "1")]
pub path: std::string::String,
#[prost(string, tag = "2")]
pub chain_type: std::string::String,
#[prost(string, tag = "3")]
pub pub_key: std::string::String,
#[prost(string, tag = "4")]
pub derived_mode: std::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExternalAddress {
#[prost(string, tag = "1")]
pub address: std::string::String,
#[prost(string, tag = "2")]
pub derived_path: std::string::String,
#[prost(string, tag = "3")]
pub r#type: std::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BitcoinWallet {
#[prost(string, tag = "1")]
pub path: std::string::String,
#[prost(string, tag = "2")]
pub chain_type: std::string::String,
#[prost(string, tag = "3")]
pub address: std::string::String,
#[prost(string, tag = "4")]
pub enc_x_pub: std::string::String,
#[prost(message, optional, tag = "5")]
pub external_address: ::std::option::Option<ExternalAddress>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EosWallet {
#[prost(string, tag = "1")]
pub chain_type: std::string::String,
#[prost(string, tag = "2")]
pub address: std::string::String,
#[prost(message, repeated, tag = "3")]
pub public_keys: ::std::vec::Vec<eos_wallet::PubKeyInfo>,
}
pub mod eos_wallet {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubKeyInfo {
#[prost(string, tag = "1")]
pub path: std::string::String,
#[prost(string, tag = "2")]
pub derived_mode: std::string::String,
#[prost(string, tag = "3")]
pub public_key: std::string::String,
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExternalAddressParam {
#[prost(string, tag = "1")]
pub path: std::string::String,
#[prost(string, tag = "2")]
pub chain_type: std::string::String,
#[prost(string, tag = "3")]
pub network: std::string::String,
#[prost(string, tag = "4")]
pub seg_wit: std::string::String,
#[prost(int32, tag = "5")]
pub external_idx: i32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InitImKeyCoreXParam {
#[prost(string, tag = "1")]
pub file_dir: std::string::String,
#[prost(string, tag = "2")]
pub xpub_common_key: std::string::String,
#[prost(string, tag = "3")]
pub xpub_common_iv: std::string::String,
#[prost(bool, tag = "4")]
pub is_debug: bool,
#[prost(string, tag = "5")]
pub system: std::string::String,
}
112 changes: 88 additions & 24 deletions api/src/btc_address.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use crate::api::{
AddressParam, AddressResult, BitcoinWallet, ExternalAddress, ExternalAddressParam,
};
use crate::error_handling::Result;
use crate::message_handler::encode_message;
use bitcoin::Network;
use coin_bitcoin::address::BtcAddress;
use coin_bitcoin::btcapi::{BtcAddressReq, BtcAddressRes, BtcXpubReq, BtcXpubRes};
use coin_bitcoin::btcapi::{BtcXpubReq, BtcXpubRes};
use prost::Message;

pub fn get_btc_xpub(data: &[u8]) -> Result<Vec<u8>> {
Expand All @@ -20,61 +23,122 @@ pub fn get_btc_xpub(data: &[u8]) -> Result<Vec<u8>> {
encode_message(address_message)
}

pub fn get_btc_address(data: &[u8]) -> Result<Vec<u8>> {
let input: BtcAddressReq = BtcAddressReq::decode(data).expect("imkey_illegal_param");

let network = match input.network.as_ref() {
pub fn get_address(param: &AddressParam) -> Result<Vec<u8>> {
let network = match param.network.as_ref() {
"MAINNET" => Network::Bitcoin,
"TESTNET" => Network::Testnet,
_ => Network::Testnet,
};

let address = BtcAddress::get_address(network, input.path.as_ref())?;
let account_path = param.path.to_string();
let main_address: String;
let receive_address: String;

if param.is_seg_wit {
main_address =
BtcAddress::get_segwit_address(network, format!("{}/0/0", account_path).as_str())?;
receive_address =
BtcAddress::get_segwit_address(network, format!("{}/0/1", account_path).as_str())?;
} else {
main_address = BtcAddress::get_address(network, format!("{}/0/0", account_path).as_str())?;
receive_address =
BtcAddress::get_address(network, format!("{}/0/1", account_path).as_str())?;
}

let enc_xpub = get_enc_xpub(network, param.path.as_ref())?;

let external_address = ExternalAddress {
address: receive_address,
derived_path: "0/1".to_string(),
r#type: "EXTERNAL".to_string(),
};

let address_message = BtcAddressRes { address };
let address_message = BitcoinWallet {
path: param.path.to_owned(),
chain_type: param.chain_type.to_string(),
address: main_address,
enc_x_pub: enc_xpub,
external_address: Some(external_address),
};
encode_message(address_message)
}

pub fn get_segwit_address(data: &[u8]) -> Result<Vec<u8>> {
let input: BtcAddressReq = BtcAddressReq::decode(data).expect("imkey_illegal_param");

let network = match input.network.as_ref() {
pub fn calc_external_address(param: &ExternalAddressParam) -> Result<Vec<u8>> {
let network = match param.network.as_ref() {
"MAINNET" => Network::Bitcoin,
"TESTNET" => Network::Testnet,
_ => Network::Testnet,
};

let address = BtcAddress::get_segwit_address(network, input.path.as_ref())?;
let account_path = param.path.to_string();
let external_path = format!("{}/0/{}", account_path, param.external_idx);
let receive_address: String;

let address_message = BtcAddressRes { address };
encode_message(address_message)
if param.seg_wit.to_uppercase() == "P2WPKH" {
receive_address = BtcAddress::get_segwit_address(network, external_path.as_str())?;
} else {
receive_address = BtcAddress::get_address(network, external_path.as_str())?;
}

let external_address = ExternalAddress {
address: receive_address,
derived_path: format!("0/{}", param.external_idx),
r#type: "EXTERNAL".to_string(),
};

encode_message(external_address)
}

pub fn display_btc_address(data: &[u8]) -> Result<Vec<u8>> {
let input: BtcAddressReq = BtcAddressReq::decode(data).expect("imkey_illegal_param");
pub fn get_enc_xpub(network: Network, path: &str) -> Result<String> {
let xpub = BtcAddress::get_xpub(network, path)?;
let key = common::XPUB_COMMON_KEY_128.read();
let iv = common::XPUB_COMMON_IV.read();
let key_bytes = hex::decode(&*key)?;
let iv_bytes = hex::decode(&*iv)?;
let encrypted = common::aes::cbc::encrypt_pkcs7(&xpub.as_bytes(), &key_bytes, &iv_bytes)?;
Ok(base64::encode(&encrypted))
}

let network = match input.network.as_ref() {
pub fn register_btc_address(param: &AddressParam) -> Result<Vec<u8>> {
if param.is_seg_wit {
display_segwit_address(param)
} else {
display_btc_legacy_address(param)
}
}

pub fn display_btc_legacy_address(param: &AddressParam) -> Result<Vec<u8>> {
let network = match param.network.as_ref() {
"MAINNET" => Network::Bitcoin,
"TESTNET" => Network::Testnet,
_ => Network::Testnet,
};

let address = BtcAddress::display_address(network, input.path.as_ref())?;
let path = format!("{}/0/0", param.path);
let address = BtcAddress::display_address(network, &path)?;

let address_message = BtcAddressRes { address };
let address_message = AddressResult {
address,
path: param.path.to_string(),
chain_type: param.chain_type.to_string(),
};
encode_message(address_message)
}

pub fn display_segwit_address(data: &[u8]) -> Result<Vec<u8>> {
let input: BtcAddressReq = BtcAddressReq::decode(data).expect("imkey_illegal_param");
let network = match input.network.as_ref() {
pub fn display_segwit_address(param: &AddressParam) -> Result<Vec<u8>> {
let network = match param.network.as_ref() {
"MAINNET" => Network::Bitcoin,
"TESTNET" => Network::Testnet,
_ => Network::Testnet,
};

let address = BtcAddress::display_segwit_address(network, input.path.as_ref())?;
let path = format!("{}/0/0", param.path);
let address = BtcAddress::display_segwit_address(network, &path)?;

let address_message = BtcAddressRes { address };
let address_message = AddressResult {
path: param.path.to_string(),
chain_type: param.chain_type.to_string(),
address,
};
encode_message(address_message)
}
Loading