Skip to content

Commit

Permalink
Use crypto 0.23 (#806)
Browse files Browse the repository at this point in the history
* Use crypto 0.23

* Fmt

* Bump stronghold

* Fix serde

* Remove default_coin_type
  • Loading branch information
thibault-martinez authored Jul 18, 2023
1 parent 2055da2 commit 4d3f2fe
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 64 deletions.
45 changes: 35 additions & 10 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 bindings/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ backtrace = { version = "0.3.68", default-features = false, features = [ "std" ]
derivative = { version = "2.2.0", default-features = false }
fern-logger = { version = "0.5.0", default-features = false }
futures = { version = "0.3.28", default-features = false }
iota-crypto = { version = "0.22.2", default-features = false, features = [ "slip10" ] }
iota-crypto = { version = "0.23.0", default-features = false, features = [ "slip10", "bip44" ] }
log = { version = "0.4.19", default-features = false }
packable = { version = "0.8.1", default-features = false }
prefix-hex = { version = "0.7.0", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ derive_more = { version = "0.99.17", default-features = false, features = [ "fro
getset = { version = "0.1.2", default-features = false }
hashbrown = { version = "0.14.0", default-features = false, features = [ "ahash", "inline-more" ] }
hex = { version = "0.4.3", default-features = false }
iota-crypto = { version = "0.22.2", default-features = false, features = [ "blake2b", "ed25519", "secp256k1", "ternary_encoding" ] }
iota-crypto = { version = "0.23.0", default-features = false, features = [ "blake2b", "ed25519", "secp256k1", "ternary_encoding" ] }
iterator-sorted = { version = "0.1.0", default-features = false }
itertools = { version = "0.11.0", default-features = false, features = [ "use_alloc" ] }
packable = { version = "0.8.1", default-features = false, features = [ "primitive-types" ] }
Expand All @@ -43,7 +43,7 @@ futures = { version = "0.3.28", default-features = false, features = [ "thread-p
heck = { version = "0.4.1", default-features = false, optional = true }
instant = { version = "0.1.12", default-features = false, optional = true }
iota-ledger-nano = { version = "1.0.0-alpha.4", default-features = false, optional = true }
iota_stronghold = { version = "2.0.0-rc.1", default-features = false, optional = true }
iota_stronghold = { version = "2.0.0-rc.2", default-features = false, optional = true }
log = { version = "0.4.19", default-features = false, optional = true }
num_cpus = { version = "1.16.0", default-features = false, optional = true }
once_cell = { version = "1.18.0", default-features = false, optional = true }
Expand Down
3 changes: 1 addition & 2 deletions sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ async fn main() -> Result<()> {
.store_mnemonic(Mnemonic::from(std::env::var("MNEMONIC").unwrap()))
.await?;

let bip44_chain = Bip44::new()
.with_coin_type(SHIMMER_COIN_TYPE)
let bip44_chain = Bip44::new(SHIMMER_COIN_TYPE)
.with_account(ACCOUNT_INDEX)
.with_change(INTERNAL_ADDRESS as _)
.with_address_index(ADDRESS_INDEX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ impl<'a> ClientBlockBuilder<'a> {
output: output_with_meta.output,
output_metadata: output_with_meta.metadata,
chain: Some(
Bip44::new()
.with_coin_type(self.coin_type)
Bip44::new(self.coin_type)
.with_account(account_index)
.with_change(internal as _)
.with_address_index(address_index),
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/client/api/block_builder/input_selection/manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ impl<'a> ClientBlockBuilder<'a> {
output: output_with_meta.output,
output_metadata: output_with_meta.metadata,
chain: address_index_internal.map(|(address_index, internal)| {
Bip44::new()
.with_coin_type(self.coin_type)
Bip44::new(self.coin_type)
.with_account(self.account_index)
.with_change(internal as _)
.with_address_index(address_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ impl<'a> ClientBlockBuilder<'a> {
output: output_with_meta.output().to_owned(),
output_metadata: output_with_meta.metadata().to_owned(),
chain: Some(
Bip44::new()
.with_coin_type(self.coin_type)
Bip44::new(self.coin_type)
.with_account(self.account_index)
.with_change(internal as _)
.with_address_index(address_index),
Expand Down Expand Up @@ -130,8 +129,7 @@ impl<'a> ClientBlockBuilder<'a> {
output: output_with_meta.output().to_owned(),
output_metadata: output_with_meta.metadata().to_owned(),
chain: address_index_internal.map(|(address_index, internal)| {
Bip44::new()
.with_coin_type(self.coin_type)
Bip44::new(self.coin_type)
.with_account(self.account_index)
.with_change(internal as _)
.with_address_index(address_index)
Expand Down Expand Up @@ -185,8 +183,7 @@ impl<'a> ClientBlockBuilder<'a> {
output: output_with_meta.output,
output_metadata: output_with_meta.metadata,
chain: address_index_internal.map(|(address_index, internal)| {
Bip44::new()
.with_coin_type(self.coin_type)
Bip44::new(self.coin_type)
.with_account(self.account_index)
.with_change(internal as _)
.with_address_index(address_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ impl<'a> ClientBlockBuilder<'a> {
output: output_with_meta.output,
output_metadata: output_with_meta.metadata,
chain: address_index_internal.map(|(address_index, internal)| {
Bip44::new()
.with_coin_type(self.coin_type)
Bip44::new(self.coin_type)
.with_account(self.account_index)
.with_change(internal as _)
.with_address_index(address_index)
Expand Down
6 changes: 2 additions & 4 deletions sdk/src/client/secret/mnemonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ impl SecretManage for MnemonicSecretManager {

Ok(address_indexes
.map(|address_index| {
let chain = Bip44::new()
.with_coin_type(coin_type)
let chain = Bip44::new(coin_type)
.with_account(account_index)
.with_change(internal as _)
.with_address_index(address_index);
Expand Down Expand Up @@ -81,8 +80,7 @@ impl SecretManage for MnemonicSecretManager {

Ok(address_indexes
.map(|address_index| {
let chain = Bip44::new()
.with_coin_type(coin_type)
let chain = Bip44::new(coin_type)
.with_account(account_index)
.with_change(internal as _)
.with_address_index(address_index);
Expand Down
6 changes: 2 additions & 4 deletions sdk/src/client/stronghold/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ impl SecretManage for StrongholdAdapter {
let internal = options.into().map(|o| o.internal).unwrap_or_default();

for address_index in address_indexes {
let chain = Bip44::new()
.with_coin_type(coin_type)
let chain = Bip44::new(coin_type)
.with_account(account_index)
.with_change(internal as _)
.with_address_index(address_index);
Expand Down Expand Up @@ -139,8 +138,7 @@ impl SecretManage for StrongholdAdapter {
let internal = options.into().map(|o| o.internal).unwrap_or_default();

for address_index in address_indexes {
let chain = Bip44::new()
.with_coin_type(coin_type)
let chain = Bip44::new(coin_type)
.with_account(account_index)
.with_change(internal as _)
.with_address_index(address_index);
Expand Down
7 changes: 3 additions & 4 deletions sdk/src/utils/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,16 @@ pub mod bip44 {
use serde::{Deserialize, Serialize};

#[derive(Default, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase", remote = "Bip44")]
#[serde(default = "default_bip44", rename_all = "camelCase", remote = "Bip44")]
pub struct Bip44Def {
#[serde(default = "default_coin_type")]
coin_type: u32,
account: u32,
change: u32,
address_index: u32,
}

const fn default_coin_type() -> u32 {
crate::client::constants::IOTA_COIN_TYPE
fn default_bip44() -> Bip44 {
Bip44::new(crate::client::constants::IOTA_COIN_TYPE)
}

pub mod option_bip44 {
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/wallet/account/operations/syncing/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ where
.map_or(false, |tx| !tx.incoming);

// BIP 44 (HD wallets) and 4218 is the registered index for IOTA https://github.com/satoshilabs/slips/blob/master/slip-0044.md
let chain = Bip44::new()
.with_coin_type(account_details.coin_type)
let chain = Bip44::new(account_details.coin_type)
.with_account(account_details.index)
.with_change(associated_address.internal as _)
.with_address_index(associated_address.key_index);
Expand Down
3 changes: 1 addition & 2 deletions sdk/src/wallet/account/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ impl OutputData {
.find(|a| a.address.inner == unlock_address)
{
Some(
Bip44::new()
.with_coin_type(account.coin_type)
Bip44::new(account.coin_type)
.with_account(account.index)
.with_change(address.internal as _)
.with_address_index(address.key_index),
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/client/input_signing_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use iota_sdk::{
fn input_signing_data_conversion() {
let protocol_parameters = protocol_parameters();

let bip44_chain = Bip44::new().with_coin_type(SHIMMER_COIN_TYPE);
let bip44_chain = Bip44::new(SHIMMER_COIN_TYPE);

let output = BasicOutput::build_with_amount(1_000_000)
.add_unlock_condition(AddressUnlockCondition::new(
Expand Down
6 changes: 3 additions & 3 deletions sdk/tests/client/signing/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn sign_alias_state_transition() -> Result<()> {
None,
None,
None,
Some(Bip44::new().with_coin_type(SHIMMER_COIN_TYPE)),
Some(Bip44::new(SHIMMER_COIN_TYPE)),
)]);

let outputs = build_outputs([Alias(
Expand Down Expand Up @@ -158,7 +158,7 @@ async fn sign_alias_governance_transition() -> Result<()> {
None,
None,
None,
Some(Bip44::new().with_coin_type(SHIMMER_COIN_TYPE).with_address_index(1)),
Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)),
)]);

let outputs = build_outputs([Alias(
Expand Down Expand Up @@ -251,7 +251,7 @@ async fn alias_reference_unlocks() -> Result<()> {
None,
None,
None,
Some(Bip44::new().with_coin_type(SHIMMER_COIN_TYPE)),
Some(Bip44::new(SHIMMER_COIN_TYPE)),
),
Basic(
1_000_000,
Expand Down
Loading

0 comments on commit 4d3f2fe

Please sign in to comment.