Skip to content

Commit

Permalink
Use crypto 0.23
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Jul 18, 2023
1 parent 85e7d66 commit 90c8c82
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 60 deletions.
39 changes: 33 additions & 6 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 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 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
16 changes: 6 additions & 10 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 Expand Up @@ -591,12 +589,10 @@ mod tests {
stronghold_adapter.clear_key().await;

// Address generation returns an error when the key is cleared.
assert!(
stronghold_adapter
.generate_ed25519_addresses(IOTA_COIN_TYPE, 0, 0..1, None,)
.await
.is_err()
);
assert!(stronghold_adapter
.generate_ed25519_addresses(IOTA_COIN_TYPE, 0, 0..1, None,)
.await
.is_err());

stronghold_adapter.set_password("drowssap".to_owned()).await.unwrap();

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
18 changes: 9 additions & 9 deletions sdk/tests/client/signing/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async fn single_ed25519_unlock() -> Result<()> {
None,
None,
None,
Some(Bip44::new().with_coin_type(SHIMMER_COIN_TYPE)),
Some(Bip44::new(SHIMMER_COIN_TYPE)),
)]);

let outputs = build_outputs([Basic(
Expand All @@ -62,7 +62,7 @@ async fn single_ed25519_unlock() -> Result<()> {
None,
None,
None,
Some(Bip44::new().with_coin_type(SHIMMER_COIN_TYPE)),
Some(Bip44::new(SHIMMER_COIN_TYPE)),
)]);

let essence = TransactionEssence::Regular(
Expand Down Expand Up @@ -132,7 +132,7 @@ async fn ed25519_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 All @@ -142,7 +142,7 @@ async fn ed25519_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 All @@ -152,7 +152,7 @@ async fn ed25519_reference_unlocks() -> Result<()> {
None,
None,
None,
Some(Bip44::new().with_coin_type(SHIMMER_COIN_TYPE)),
Some(Bip44::new(SHIMMER_COIN_TYPE)),
),
]);

Expand All @@ -164,7 +164,7 @@ async fn ed25519_reference_unlocks() -> Result<()> {
None,
None,
None,
Some(Bip44::new().with_coin_type(SHIMMER_COIN_TYPE)),
Some(Bip44::new(SHIMMER_COIN_TYPE)),
)]);

let essence = TransactionEssence::Regular(
Expand Down Expand Up @@ -254,7 +254,7 @@ async fn two_signature_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 All @@ -264,7 +264,7 @@ async fn two_signature_unlocks() -> 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)),
),
]);

Expand All @@ -276,7 +276,7 @@ async fn two_signature_unlocks() -> Result<()> {
None,
None,
None,
Some(Bip44::new().with_coin_type(SHIMMER_COIN_TYPE)),
Some(Bip44::new(SHIMMER_COIN_TYPE)),
)]);

let essence = TransactionEssence::Regular(
Expand Down
Loading

0 comments on commit 90c8c82

Please sign in to comment.