Skip to content

Commit 4b5eaa8

Browse files
XuNealtyrone98xiaoguang1010dependabot[bot]
authored
release dev feature (#137)
* Feature/support dogecoin (#112) * add dogecoin testnet & mainnet * add dogecoin extend public key tests * feat: add hrp to coininfo (#113) * feat: add hrp to coininfo * feat: add stride address test * Feature/support dogecoin (#116) * add dogecoin testnet & mainnet * add dogecoin extend public key tests * fix: fix derive dogecoin unsupported_chain error --------- Co-authored-by: xiaoguang <[email protected]> * feat: imkey support bitcoin psbt transaction[R2D2-11602] (#114) * feat: add p2wpkhp2tr address generation * feat: add bitcoin Mixed signature function * test: modify p2wpkh test case * feat: add bitcoin p2wpkh sign * feat: add test case and add p2tr sign * test: add test case * test: modify btc test case * feat: code optimization * feat: modify display_addres and get_address * feat: add bitcoin p2tr transaction * test: add p2tr test case * test: add bitcoin transaction sign function test * feat: code optimization * feat: pass in the tweaked public key when signing * chore: code format * feat: add imKey PSBT feature code * feat: add p2wpkhp2tr address generation * feat: add bitcoin Mixed signature function * test: modify p2wpkh test case * feat: add bitcoin p2wpkh sign * feat: add test case and add p2tr sign * test: add test case * test: modify btc test case * feat: code optimization * feat: modify display_addres and get_address * feat: add bitcoin p2tr transaction * test: add p2tr test case * test: add bitcoin transaction sign function test * feat: code optimization * feat: pass in the tweaked public key when signing * chore: code format * chore: switch to staging env * feat: add imKey PSBT feature code * feat: derive_account and derive_sub_account support native segwit address and bech32 address * feat: add bitcoin psbt sign transaction * feat: add bitcoin p2tr script sign * fix: fix psbt legacy transaction bug * chore: psbt code optimized * fix: fix preview info calc error bug * fix: modify change path to account path * chore: code optimized * feat: psbt transaction support sign message * feat: add bip-322 sign message feature * feat: add bitcoin sign message api * chore: remove address verify function * chore: get_utxo_pub_key function removes the network param * chore: modify tcx version to 2.8.0 * chore: bip322 sign message add path check and code optimization * build: moify ios CI run-on version to macos-14 * fix: fix ios CI build error * fix: fix cargo check error * chore: optimization imKey public key conversion * chore: PubKeyParam removes isSegwit field * hotfix: import private key of dogecoin (#117) * fix: cannot derive sub account with hrp (#118) * feat: add top 15 chain_id and hrp verified (#121) * ci: run unittest when push (#122) * ci: run unittest when push * ci: rename workflow name * ci: fix make command error * fix: missing test data * chore(deps): bump openssl from 0.10.62 to 0.10.66 (#111) Bumps [openssl](https://github.com/sfackler/rust-openssl) from 0.10.62 to 0.10.66. - [Release notes](https://github.com/sfackler/rust-openssl/releases) - [Commits](sfackler/rust-openssl@openssl-v0.10.62...openssl-v0.10.66) --- updated-dependencies: - dependency-name: openssl dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * security: remove rustc serialize (#123) * feat: imk support mnemonic verification feature (#119) * cosmos: derive account by chain id (#125) * feat: force using known hrp * feat: cosmos derive account by chainId * fix: remove bech32_prefix from ikc (#129) * fix: fixed the issue of Legacy and Nested Segwit transaction failure [R2D2-12387] (#128) * fix: fixed the issue of Legacy and Nested Segwit transaction failure when btc not upgraded * fix: wrong to address cannot be traded when appelt is not upgraded * chore: optimization error message prompts * feat: tron sign message support v2 version[R2D2-11852] (#131) * feat: tron sign message support v2 version * chore: tron sign message v2 review problem optimization * chore: add proro field description * feat: imKey support dogecoin[R2D2-12636] (#132) * feat: support dogecoin address * feat: ikc supprot dogecoin * test: add dogecoin device_accounts test case * test: add dogecoin device_sub_account test case * feat: Modify the bitcoin address generation method * feat: support dogecoin sign and add test case * chore: modify dogecoin instance id * test: delete useless test case * fix: fix imkey tron ​​message signature verification failure error[R2D2-11852] (#134) * fix: fix imkey tron ​​message signature verification failure error * fix: fix tcx test_sign_message_by_hd testcase fail * fix invalid signature on uncompressed wif (#135) Co-authored-by: xiaoguang1010 <[email protected]> * fix: imkey tron message sign error (#136) * fix: fix imkey tron ​​message signature verification failure error * fix: fix tcx test_sign_message_by_hd testcase fail * raise need_password_or_derived_key when key is null (#115) * fix: fix build error * ci: change runner to macos 13 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: sun <[email protected]> Co-authored-by: xiaoguang <[email protected]> Co-authored-by: xiaoguang1010 <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 818de5f commit 4b5eaa8

File tree

93 files changed

+4916
-695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4916
-695
lines changed

.github/workflows/build-release-android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
build:
1616
name: Build Android Release
1717
if: github.event.review.state == 'approved'
18-
runs-on: macos-12
18+
runs-on: macos-13
1919
steps:
2020
- name: Get the latest commit SHA
2121
id: sha

.github/workflows/build-release-ios.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
build:
1515
name: Build iOS Release
1616
if: github.event.review.state == 'approved'
17-
runs-on: macos-12
17+
runs-on: macos-13
1818
steps:
1919
- name: Get the latest commit SHA
2020
id: sha

.github/workflows/run-unittest.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Run Tcx Unit Testing
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
11+
cancel-in-progress: true
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
17+
jobs:
18+
build:
19+
name: Run Tcx Unit Testing
20+
runs-on: macos-13
21+
steps:
22+
- name: Get the latest commit SHA
23+
id: sha
24+
uses: actions/github-script@v6
25+
with:
26+
result-encoding: string
27+
script: |
28+
const { owner, repo, number } = context.issue
29+
const pr = await github.rest.pulls.get({
30+
owner,
31+
repo,
32+
pull_number: number,
33+
})
34+
return pr.data.head.sha
35+
36+
- name: Checkout repository
37+
uses: actions/checkout@v3
38+
with:
39+
ref: ${{ steps.sha.outputs.result }}
40+
fetch-depth: 5
41+
42+
- name: Cache
43+
uses: actions/cache@v2
44+
with:
45+
path: |
46+
~/.cargo/registry
47+
~/.cargo/git
48+
~/.rustup
49+
target
50+
key: ${{ runner.os }}-nightly
51+
52+
- name: Install Rust
53+
run: |
54+
rustup toolchain install nightly-2022-10-31
55+
rustup default nightly-2022-10-31-x86_64-apple-darwin
56+
rustup show
57+
58+
- name: Install dependency
59+
run: |
60+
brew install protobuf
61+
62+
- name: Run TCX Unit Testing
63+
run: |
64+
make test-tcx

Cargo.lock

Lines changed: 6 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.7.4
1+
2.8.0

imkey-core/ikc-common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ edition = "2018"
1010
hyper = { version = "=0.14.23", features = ["full"] }
1111
hyper-tls = "=0.5.0"
1212
hyper-timeout = "=0.4.1"
13-
rustc-serialize = "=0.3.24"
1413
serde = { version = "=1.0.147", features = ["derive"] }
1514
serde_derive = "=1.0.147"
1615
serde_json = "=1.0.89"

imkey-core/ikc-common/src/apdu.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::constants::{BTC_AID, COSMOS_AID, EOS_AID, ETH_AID, LC_MAX};
22
use crate::error::ApduError;
3+
use crate::hex::ToHex;
34
use crate::Result;
45
use hex;
5-
use rustc_serialize::hex::ToHex;
66

77
pub trait CoinCommonApdu: Default {
88
fn select_applet() -> String;
@@ -69,6 +69,19 @@ impl BtcApdu {
6969
apdu.to_hex().to_uppercase()
7070
}
7171

72+
/**
73+
*p2 00:sign psbt transaction 80: sign message
74+
**/
75+
pub fn btc_psbt_preview(data: &Vec<u8>, p2: u8) -> String {
76+
if data.len() as u32 > LC_MAX {
77+
panic!("data to long");
78+
}
79+
let mut apdu = ApduHeader::new(0x80, 0x4C, 0x00, p2, data.len() as u8).to_array();
80+
apdu.extend(data.iter());
81+
apdu.push(0x00);
82+
apdu.to_hex().to_uppercase()
83+
}
84+
7285
pub fn btc_sign(index: u8, hash_type: u8, path: &str) -> String {
7386
let path_bytes = path.as_bytes();
7487
let mut apdu =
@@ -108,6 +121,21 @@ impl BtcApdu {
108121
apdu.to_hex().to_uppercase()
109122
}
110123

124+
pub fn btc_taproot_script_sign(last_one: bool, data: Vec<u8>) -> String {
125+
if data.len() as u32 > LC_MAX {
126+
panic!("data to long");
127+
}
128+
129+
let mut apdu = match last_one {
130+
true => ApduHeader::new(0x80, 0x40, 0x80, 0x80, data.len() as u8).to_array(),
131+
_ => ApduHeader::new(0x80, 0x40, 0x00, 0x80, data.len() as u8).to_array(),
132+
};
133+
134+
apdu.extend(data.iter());
135+
apdu.push(0x00);
136+
apdu.to_hex().to_uppercase()
137+
}
138+
111139
pub fn omni_prepare_data(p1: u8, data: Vec<u8>) -> String {
112140
if data.len() as u32 > LC_MAX {
113141
panic!("data to long");
@@ -629,6 +657,7 @@ impl ApduCheck {
629657
"F080" => Err(ApduError::ImkeyInMenuPage.into()),
630658
"F081" => Err(ApduError::ImkeyPinNotVerified.into()),
631659
"6F01" => Err(ApduError::ImkeyBluetoothChannelError.into()),
660+
"6943" => Err(ApduError::ImkeyMnemonicCheckFail.into()),
632661
_ => Err(anyhow!("imkey_command_execute_fail_{}", response_data)), //Err(ApduError::ImkeyCommandExecuteFail.into())
633662
}
634663
}

imkey-core/ikc-common/src/applet.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::constants::{
2-
BCH_AID, BTC_AID, COSMOS_AID, EOS_AID, ETH_AID, FILECOIN_AID, IMK_AID, KUSAMA_AID, LTC_AID,
3-
NERVOS_AID, POLKADOT_AID, TEZOS_AID, TRON_AID,
2+
BCH_AID, BTC_AID, COSMOS_AID, DOGECOIN_AID, EOS_AID, ETH_AID, FILECOIN_AID, IMK_AID,
3+
KUSAMA_AID, LTC_AID, NERVOS_AID, POLKADOT_AID, TEZOS_AID, TRON_AID,
44
};
55
// type __appletName = 'IMK' | 'Ethereum' | 'Bitcoin' | 'EOS' | 'Cosmos' | 'Filecoin' | 'Kusama' | 'Tezos' | 'Polkadot' | 'TRON' | 'Bitcoin Cash' | 'Litecoin' | 'Nervos'
66
pub fn get_appname_by_instid(instid: &str) -> Option<&str> {
@@ -18,6 +18,7 @@ pub fn get_appname_by_instid(instid: &str) -> Option<&str> {
1818
IMK_AID => Some("IMK"),
1919
NERVOS_AID => Some("Nervos"),
2020
TEZOS_AID => Some("Tezos"),
21+
DOGECOIN_AID => Some("Dogecoin"),
2122
_ => None,
2223
}
2324
}
@@ -36,6 +37,7 @@ pub fn get_instid_by_appname(appname: &str) -> Option<&str> {
3637
"Bitcoin Cash" => Some(BCH_AID),
3738
"Litecoin" => Some(LTC_AID),
3839
"IMK" => Some(IMK_AID),
40+
"Dogecoin" => Some(DOGECOIN_AID),
3941
_ => None,
4042
}
4143
}
@@ -56,6 +58,10 @@ mod tests {
5658
assert_eq!(get_appname_by_instid("695F626368").unwrap(), "Bitcoin Cash");
5759
assert_eq!(get_appname_by_instid("695F6C7463").unwrap(), "Litecoin");
5860
assert_eq!(get_appname_by_instid("695F696D6B").unwrap(), "IMK");
61+
assert_eq!(
62+
get_appname_by_instid("695F646F6765636F696E").unwrap(),
63+
"Dogecoin"
64+
);
5965
assert!(get_appname_by_instid("1111111111").is_none());
6066
}
6167

@@ -72,6 +78,10 @@ mod tests {
7278
);
7379
assert_eq!(get_instid_by_appname("Bitcoin Cash").unwrap(), "695F626368");
7480
assert_eq!(get_instid_by_appname("Litecoin").unwrap(), "695F6C7463");
81+
assert_eq!(
82+
get_instid_by_appname("Dogecoin").unwrap(),
83+
"695F646F6765636F696E"
84+
);
7585
assert!(get_instid_by_appname("APPLET").is_none());
7686
}
7787
}

imkey-core/ikc-common/src/coin_info.rs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,34 @@ lazy_static! {
4646
network: "TESTNET".to_string(),
4747
seg_wit: "P2WPKH".to_string(),
4848
},
49+
CoinInfo {
50+
coin: "BITCOIN".to_string(),
51+
derivation_path: "m/84'/0'/0'/0/0".to_string(),
52+
curve: CurveType::SECP256k1,
53+
network: "MAINNET".to_string(),
54+
seg_wit: "VERSION_0".to_string(),
55+
},
56+
CoinInfo {
57+
coin: "BITCOIN".to_string(),
58+
derivation_path: "m/84'/1'/0'/0/0".to_string(),
59+
curve: CurveType::SECP256k1,
60+
network: "TESTNET".to_string(),
61+
seg_wit: "VERSION_0".to_string(),
62+
},
63+
CoinInfo {
64+
coin: "BITCOIN".to_string(),
65+
derivation_path: "m/86'/0'/0'/0/0".to_string(),
66+
curve: CurveType::SECP256k1,
67+
network: "MAINNET".to_string(),
68+
seg_wit: "VERSION_1".to_string(),
69+
},
70+
CoinInfo {
71+
coin: "BITCOIN".to_string(),
72+
derivation_path: "m/86'/1'/0'/0/0".to_string(),
73+
curve: CurveType::SECP256k1,
74+
network: "TESTNET".to_string(),
75+
seg_wit: "VERSION_1".to_string(),
76+
},
4977
CoinInfo {
5078
coin: "BITCOINCASH".to_string(),
5179
derivation_path: "m/44'/145'/0'/0/0".to_string(),
@@ -207,6 +235,62 @@ lazy_static! {
207235
network: "TESTNET".to_string(),
208236
seg_wit: "".to_string(),
209237
},
238+
CoinInfo {
239+
coin: "DOGECOIN".to_string(),
240+
derivation_path: "m/44'/3'/0'/0/0".to_string(),
241+
curve: CurveType::SECP256k1,
242+
network: "MAINNET".to_string(),
243+
seg_wit: "NONE".to_string(),
244+
},
245+
CoinInfo {
246+
coin: "DOGECOIN".to_string(),
247+
derivation_path: "m/44'/1'/0'/0/0".to_string(),
248+
curve: CurveType::SECP256k1,
249+
network: "TESTNET".to_string(),
250+
seg_wit: "NONE".to_string(),
251+
},
252+
CoinInfo {
253+
coin: "DOGECOIN".to_string(),
254+
derivation_path: "m/49'/3'/0'/0/0".to_string(),
255+
curve: CurveType::SECP256k1,
256+
network: "MAINNET".to_string(),
257+
seg_wit: "P2WPKH".to_string(),
258+
},
259+
CoinInfo {
260+
coin: "DOGECOIN".to_string(),
261+
derivation_path: "m/49'/1'/0'/0/0".to_string(),
262+
curve: CurveType::SECP256k1,
263+
network: "TESTNET".to_string(),
264+
seg_wit: "P2WPKH".to_string(),
265+
},
266+
CoinInfo {
267+
coin: "DOGECOIN".to_string(),
268+
derivation_path: "m/84'/3'/0'/0/0".to_string(),
269+
curve: CurveType::SECP256k1,
270+
network: "MAINNET".to_string(),
271+
seg_wit: "VERSION_0".to_string(),
272+
},
273+
CoinInfo {
274+
coin: "DOGECOIN".to_string(),
275+
derivation_path: "m/84'/1'/0'/0/0".to_string(),
276+
curve: CurveType::SECP256k1,
277+
network: "TESTNET".to_string(),
278+
seg_wit: "VERSION_0".to_string(),
279+
},
280+
CoinInfo {
281+
coin: "DOGECOIN".to_string(),
282+
derivation_path: "m/86'/3'/0'/0/0".to_string(),
283+
curve: CurveType::SECP256k1,
284+
network: "MAINNET".to_string(),
285+
seg_wit: "VERSION_1".to_string(),
286+
},
287+
CoinInfo {
288+
coin: "DOGECOIN".to_string(),
289+
derivation_path: "m/86'/1'/0'/0/0".to_string(),
290+
curve: CurveType::SECP256k1,
291+
network: "TESTNET".to_string(),
292+
seg_wit: "VERSION_1".to_string(),
293+
},
210294
];
211295
RwLock::new(coin_infos)
212296
};

imkey-core/ikc-common/src/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ pub struct SignParam {
1717
pub sender: ::prost::alloc::string::String,
1818
#[prost(string, tag = "8")]
1919
pub fee: ::prost::alloc::string::String,
20+
#[prost(string, tag = "9")]
21+
pub seg_wit: ::prost::alloc::string::String,
2022
}

imkey-core/ikc-common/src/constants.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
pub const VERSION: &str = "2.15.2";
2-
// pub const URL: &str = "https://imkey.online:1000/imkey";
3-
pub const URL: &str = "https://imkeyserver.com:10444/imkey";
1+
pub const VERSION: &str = "2.16.0";
2+
pub const URL: &str = "https://imkey.online:1000/imkey";
3+
// pub const URL: &str = "https://imkeyserver.com:10444/imkey";
44

55
pub const TSM_ACTION_SE_SECURE_CHECK: &str = "/seSecureCheck";
66
pub const TSM_ACTION_APP_DOWNLOAD: &str = "/appDownload";
@@ -29,6 +29,7 @@ pub const NERVOS_AID: &str = "695F6B315F636B62";
2929
pub const TEZOS_AID: &str = "695F65645F78747A";
3030
pub const BCH_AID: &str = "695F626368";
3131
pub const LTC_AID: &str = "695F6C7463";
32+
pub const DOGECOIN_AID: &str = "695F646F6765636F696E";
3233

3334
pub const BL_AID: &str = "D0426F6F746C6F61646572";
3435

@@ -118,6 +119,13 @@ pub const ETH_TRANSACTION_TYPE_EIP1559: &str = "02";
118119

119120
pub const ETH_MAX_SUPPORT_PAYMENT_LEN: usize = 255;
120121

122+
pub const BTC_PSBT_TRX_PER_PAGE_NUMBER: usize = 3;
123+
124+
pub const BTC_SEG_WIT_TYPE_LEGACY: &str = "NONE";
125+
pub const BTC_SEG_WIT_TYPE_P2WPKH: &str = "P2WPKH";
126+
pub const BTC_SEG_WIT_TYPE_VERSION_0: &str = "VERSION_0";
127+
pub const BTC_SEG_WIT_TYPE_VERSION_1: &str = "VERSION_1";
128+
121129
lazy_static! {
122130
/// Lazily initialized secp256k1 engine
123131
pub static ref SECP256K1_ENGINE: secp256k1::Secp256k1<secp256k1::All> = secp256k1::Secp256k1::new();

0 commit comments

Comments
 (0)