Skip to content
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

release dev feature #137

Merged
merged 23 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c263cca
Feature/support dogecoin (#112)
tyrone98 Jul 31, 2024
3fbf1da
feat: add hrp to coininfo (#113)
XuNeal Jul 31, 2024
4039e2f
Feature/support dogecoin (#116)
tyrone98 Aug 15, 2024
e244c49
feat: imkey support bitcoin psbt transaction[R2D2-11602] (#114)
xiaoguang1010 Aug 16, 2024
d4f34db
hotfix: import private key of dogecoin (#117)
tyrone98 Aug 16, 2024
386d5bb
fix: cannot derive sub account with hrp (#118)
XuNeal Aug 27, 2024
ffb7824
feat: add top 15 chain_id and hrp verified (#121)
XuNeal Aug 29, 2024
2ae880e
ci: run unittest when push (#122)
XuNeal Aug 30, 2024
47f4a0a
chore(deps): bump openssl from 0.10.62 to 0.10.66 (#111)
dependabot[bot] Aug 30, 2024
2be9194
security: remove rustc serialize (#123)
XuNeal Sep 2, 2024
ade18a2
feat: imk support mnemonic verification feature (#119)
xiaoguang1010 Sep 4, 2024
2cfefee
cosmos: derive account by chain id (#125)
XuNeal Sep 9, 2024
143bdf7
fix: remove bech32_prefix from ikc (#129)
XuNeal Sep 26, 2024
1420577
fix: fixed the issue of Legacy and Nested Segwit transaction failure …
xiaoguang1010 Sep 27, 2024
cece9e9
feat: tron sign message support v2 version[R2D2-11852] (#131)
xiaoguang1010 Oct 25, 2024
85a2e35
feat: imKey support dogecoin[R2D2-12636] (#132)
xiaoguang1010 Oct 25, 2024
606106e
fix: fix imkey tron ​​message signature verification failure error[R2…
xiaoguang1010 Dec 3, 2024
4f44644
fix invalid signature on uncompressed wif (#135)
tyrone98 Dec 3, 2024
7f50872
fix: imkey tron message sign error (#136)
xiaoguang1010 Dec 23, 2024
9ec12a6
raise need_password_or_derived_key when key is null (#115)
tyrone98 Dec 23, 2024
b44ffe7
Merge branch 'main' into dev
xiaoguang1010 Dec 23, 2024
ec90a42
fix: fix build error
xiaoguang1010 Dec 23, 2024
02b15d0
ci: change runner to macos 13
XuNeal Dec 23, 2024
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
64 changes: 64 additions & 0 deletions .github/workflows/run-unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Run Tcx Unit Testing

on:
pull_request:
types:
- opened
- synchronize

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always


jobs:
build:
name: Run Tcx Unit Testing
runs-on: macos-12
steps:
- name: Get the latest commit SHA
id: sha
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const { owner, repo, number } = context.issue
const pr = await github.rest.pulls.get({
owner,
repo,
pull_number: number,
})
return pr.data.head.sha

- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ steps.sha.outputs.result }}
fetch-depth: 5

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.rustup
target
key: ${{ runner.os }}-nightly

- name: Install Rust
run: |
rustup toolchain install nightly-2022-10-31
rustup default nightly-2022-10-31-x86_64-apple-darwin
rustup show

- name: Install dependency
run: |
brew install protobuf

- name: Run TCX Unit Testing
run: |
make test-tcx
17 changes: 6 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.4
2.8.0
1 change: 0 additions & 1 deletion imkey-core/ikc-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ edition = "2018"
hyper = { version = "=0.14.23", features = ["full"] }
hyper-tls = "=0.5.0"
hyper-timeout = "=0.4.1"
rustc-serialize = "=0.3.24"
serde = { version = "=1.0.147", features = ["derive"] }
serde_derive = "=1.0.147"
serde_json = "=1.0.89"
Expand Down
31 changes: 30 additions & 1 deletion imkey-core/ikc-common/src/apdu.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::constants::{BTC_AID, COSMOS_AID, EOS_AID, ETH_AID, LC_MAX};
use crate::error::ApduError;
use crate::hex::ToHex;
use crate::Result;
use hex;
use rustc_serialize::hex::ToHex;

pub trait CoinCommonApdu: Default {
fn select_applet() -> String;
Expand Down Expand Up @@ -69,6 +69,19 @@ impl BtcApdu {
apdu.to_hex().to_uppercase()
}

/**
*p2 00:sign psbt transaction 80: sign message
**/
pub fn btc_psbt_preview(data: &Vec<u8>, p2: u8) -> String {
if data.len() as u32 > LC_MAX {
panic!("data to long");
}
let mut apdu = ApduHeader::new(0x80, 0x4C, 0x00, p2, data.len() as u8).to_array();
apdu.extend(data.iter());
apdu.push(0x00);
apdu.to_hex().to_uppercase()
}

pub fn btc_sign(index: u8, hash_type: u8, path: &str) -> String {
let path_bytes = path.as_bytes();
let mut apdu =
Expand Down Expand Up @@ -108,6 +121,21 @@ impl BtcApdu {
apdu.to_hex().to_uppercase()
}

pub fn btc_taproot_script_sign(last_one: bool, data: Vec<u8>) -> String {
if data.len() as u32 > LC_MAX {
panic!("data to long");
}

let mut apdu = match last_one {
true => ApduHeader::new(0x80, 0x40, 0x80, 0x80, data.len() as u8).to_array(),
_ => ApduHeader::new(0x80, 0x40, 0x00, 0x80, data.len() as u8).to_array(),
};

apdu.extend(data.iter());
apdu.push(0x00);
apdu.to_hex().to_uppercase()
}

pub fn omni_prepare_data(p1: u8, data: Vec<u8>) -> String {
if data.len() as u32 > LC_MAX {
panic!("data to long");
Expand Down Expand Up @@ -629,6 +657,7 @@ impl ApduCheck {
"F080" => Err(ApduError::ImkeyInMenuPage.into()),
"F081" => Err(ApduError::ImkeyPinNotVerified.into()),
"6F01" => Err(ApduError::ImkeyBluetoothChannelError.into()),
"6943" => Err(ApduError::ImkeyMnemonicCheckFail.into()),
_ => Err(anyhow!("imkey_command_execute_fail_{}", response_data)), //Err(ApduError::ImkeyCommandExecuteFail.into())
}
}
Expand Down
8 changes: 6 additions & 2 deletions imkey-core/ikc-common/src/applet.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::constants::{
BCH_AID, BTC_AID, COSMOS_AID, EOS_AID, ETH_AID, FILECOIN_AID, IMK_AID, KUSAMA_AID, LTC_AID,
NERVOS_AID, POLKADOT_AID, TEZOS_AID, TRON_AID,
BCH_AID, BTC_AID, COSMOS_AID, DOGECOIN_AID, EOS_AID, ETH_AID, FILECOIN_AID, IMK_AID,
KUSAMA_AID, LTC_AID, NERVOS_AID, POLKADOT_AID, TEZOS_AID, TRON_AID,
};
// type __appletName = 'IMK' | 'Ethereum' | 'Bitcoin' | 'EOS' | 'Cosmos' | 'Filecoin' | 'Kusama' | 'Tezos' | 'Polkadot' | 'TRON' | 'Bitcoin Cash' | 'Litecoin' | 'Nervos'
pub fn get_appname_by_instid(instid: &str) -> Option<&str> {
Expand All @@ -18,6 +18,7 @@ pub fn get_appname_by_instid(instid: &str) -> Option<&str> {
IMK_AID => Some("IMK"),
NERVOS_AID => Some("Nervos"),
TEZOS_AID => Some("Tezos"),
DOGECOIN_AID => Some("Dogecoin"),
_ => None,
}
}
Expand All @@ -36,6 +37,7 @@ pub fn get_instid_by_appname(appname: &str) -> Option<&str> {
"Bitcoin Cash" => Some(BCH_AID),
"Litecoin" => Some(LTC_AID),
"IMK" => Some(IMK_AID),
"Dogecoin" => Some(DOGECOIN_AID),
_ => None,
}
}
Expand All @@ -56,6 +58,7 @@ mod tests {
assert_eq!(get_appname_by_instid("695F626368").unwrap(), "Bitcoin Cash");
assert_eq!(get_appname_by_instid("695F6C7463").unwrap(), "Litecoin");
assert_eq!(get_appname_by_instid("695F696D6B").unwrap(), "IMK");
assert_eq!(get_appname_by_instid("695F646F6765636F696E").unwrap(), "Dogecoin");
assert!(get_appname_by_instid("1111111111").is_none());
}

Expand All @@ -72,6 +75,7 @@ mod tests {
);
assert_eq!(get_instid_by_appname("Bitcoin Cash").unwrap(), "695F626368");
assert_eq!(get_instid_by_appname("Litecoin").unwrap(), "695F6C7463");
assert_eq!(get_instid_by_appname("Dogecoin").unwrap(), "695F646F6765636F696E");
assert!(get_instid_by_appname("APPLET").is_none());
}
}
84 changes: 84 additions & 0 deletions imkey-core/ikc-common/src/coin_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,34 @@ lazy_static! {
network: "TESTNET".to_string(),
seg_wit: "P2WPKH".to_string(),
},
CoinInfo {
coin: "BITCOIN".to_string(),
derivation_path: "m/84'/0'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "MAINNET".to_string(),
seg_wit: "VERSION_0".to_string(),
},
CoinInfo {
coin: "BITCOIN".to_string(),
derivation_path: "m/84'/1'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "TESTNET".to_string(),
seg_wit: "VERSION_0".to_string(),
},
CoinInfo {
coin: "BITCOIN".to_string(),
derivation_path: "m/86'/0'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "MAINNET".to_string(),
seg_wit: "VERSION_1".to_string(),
},
CoinInfo {
coin: "BITCOIN".to_string(),
derivation_path: "m/86'/1'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "TESTNET".to_string(),
seg_wit: "VERSION_1".to_string(),
},
CoinInfo {
coin: "BITCOINCASH".to_string(),
derivation_path: "m/44'/145'/0'/0/0".to_string(),
Expand Down Expand Up @@ -207,6 +235,62 @@ lazy_static! {
network: "TESTNET".to_string(),
seg_wit: "".to_string(),
},
CoinInfo {
coin: "DOGECOIN".to_string(),
derivation_path: "m/44'/3'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "MAINNET".to_string(),
seg_wit: "NONE".to_string(),
},
CoinInfo {
coin: "DOGECOIN".to_string(),
derivation_path: "m/44'/1'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "TESTNET".to_string(),
seg_wit: "NONE".to_string(),
},
CoinInfo {
coin: "DOGECOIN".to_string(),
derivation_path: "m/49'/3'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "MAINNET".to_string(),
seg_wit: "P2WPKH".to_string(),
},
CoinInfo {
coin: "DOGECOIN".to_string(),
derivation_path: "m/49'/1'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "TESTNET".to_string(),
seg_wit: "P2WPKH".to_string(),
},
CoinInfo {
coin: "DOGECOIN".to_string(),
derivation_path: "m/84'/3'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "MAINNET".to_string(),
seg_wit: "VERSION_0".to_string(),
},
CoinInfo {
coin: "DOGECOIN".to_string(),
derivation_path: "m/84'/1'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "TESTNET".to_string(),
seg_wit: "VERSION_0".to_string(),
},
CoinInfo {
coin: "DOGECOIN".to_string(),
derivation_path: "m/86'/3'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "MAINNET".to_string(),
seg_wit: "VERSION_1".to_string(),
},
CoinInfo {
coin: "DOGECOIN".to_string(),
derivation_path: "m/86'/1'/0'/0/0".to_string(),
curve: CurveType::SECP256k1,
network: "TESTNET".to_string(),
seg_wit: "VERSION_1".to_string(),
},
];
RwLock::new(coin_infos)
};
Expand Down
2 changes: 2 additions & 0 deletions imkey-core/ikc-common/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ pub struct SignParam {
pub sender: ::prost::alloc::string::String,
#[prost(string, tag = "8")]
pub fee: ::prost::alloc::string::String,
#[prost(string, tag = "9")]
pub seg_wit: ::prost::alloc::string::String,
}
14 changes: 11 additions & 3 deletions imkey-core/ikc-common/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub const VERSION: &str = "2.15.2";
// pub const URL: &str = "https://imkey.online:1000/imkey";
pub const URL: &str = "https://imkeyserver.com:10444/imkey";
pub const VERSION: &str = "2.16.0";
pub const URL: &str = "https://imkey.online:1000/imkey";
// pub const URL: &str = "https://imkeyserver.com:10444/imkey";

pub const TSM_ACTION_SE_SECURE_CHECK: &str = "/seSecureCheck";
pub const TSM_ACTION_APP_DOWNLOAD: &str = "/appDownload";
Expand Down Expand Up @@ -29,6 +29,7 @@ pub const NERVOS_AID: &str = "695F6B315F636B62";
pub const TEZOS_AID: &str = "695F65645F78747A";
pub const BCH_AID: &str = "695F626368";
pub const LTC_AID: &str = "695F6C7463";
pub const DOGECOIN_AID: &str = "695F646F6765636F696E";

pub const BL_AID: &str = "D0426F6F746C6F61646572";

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

pub const ETH_MAX_SUPPORT_PAYMENT_LEN: usize = 255;

pub const BTC_PSBT_TRX_PER_PAGE_NUMBER: usize = 3;

pub const BTC_SEG_WIT_TYPE_LEGACY: &str = "NONE";
pub const BTC_SEG_WIT_TYPE_P2WPKH: &str = "P2WPKH";
pub const BTC_SEG_WIT_TYPE_VERSION_0: &str = "VERSION_0";
pub const BTC_SEG_WIT_TYPE_VERSION_1: &str = "VERSION_1";

lazy_static! {
/// Lazily initialized secp256k1 engine
pub static ref SECP256K1_ENGINE: secp256k1::Secp256k1<secp256k1::All> = secp256k1::Secp256k1::new();
Expand Down
6 changes: 6 additions & 0 deletions imkey-core/ikc-common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub enum CommonError {
InvalidKeyIvLength,
#[error("invalid_base58")]
InvalidBase58,
#[error("missing_network")]
MissingNetwork,
}

#[derive(Error, Debug, PartialOrd, PartialEq)]
Expand Down Expand Up @@ -40,6 +42,8 @@ pub enum ApduError {
ImkeyInMenuPage,
#[error("imkey_pin_not_verified")]
ImkeyPinNotVerified,
#[error("imkey_mnemonic_check_fail")]
ImkeyMnemonicCheckFail,
}

#[derive(Error, Debug, PartialOrd, PartialEq)]
Expand Down Expand Up @@ -90,4 +94,6 @@ pub enum CoinError {
InvalidAddrLength,
#[error("invalid_utxo")]
InvalidUtxo,
#[error("missing_signature")]
MissingSignature,
}
Loading
Loading