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

updates ironfish to use latest ironfish-frost changes, etc. #5369

Merged
merged 15 commits into from
Sep 13, 2024

Conversation

hughy
Copy link
Contributor

@hughy hughy commented Sep 12, 2024

Summary

integrates latest updates to ironfish-frost to support Ledger: iron-fish/ironfish-frost#81

upgrades napi to accommodate dependency conflicts

adds deserialization helper functions to support round3_min

fixes test failures from encryption and error message changes

Testing Plan

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and label it with breaking-change-rpc or breaking-change-sdk.

[ ] Yes

@hughy hughy requested a review from a team as a code owner September 12, 2024 23:23
@hughy hughy marked this pull request as draft September 13, 2024 00:56
mat-if and others added 9 commits September 12, 2024 17:56
deserialize_round2_combined_public_package takes a serialized
'CombinedPublicPackage' from dkg round2 and returns an object containing an
array of round2 public packages with all fields available as strings
throws FrostLibErrors using new_with_source to give error messages

updates decryption test for new decryption error message
we've updated encryption/decryption in the ironfish-frost crate and changed the
structure of encrypted data

older account exports cannot be decrypted with the current 'decrypt' method and
must use 'decrypt_legacy' instead

defines 'decrypt_legacy_data' on ParticipantSecret and updates account
decryption to try decrypting with that method if the first decryption attempt
fails
@hughy hughy force-pushed the hughy/ironfish-frost-integration branch from 3946a3f to 9abbc9a Compare September 13, 2024 01:03
@hughy hughy force-pushed the hughy/ironfish-frost-integration branch from 9abbc9a to 0e10875 Compare September 13, 2024 17:38
@hughy hughy marked this pull request as ready for review September 13, 2024 17:52
@@ -78,7 +83,7 @@ pub fn create_signing_commitment(
&signers,
);

let bytes = signing_commitment.serialize();
let bytes = signing_commitment.unwrap().serialize();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we bubble up the error instead of unwrapping here?

@@ -415,6 +432,7 @@ pub fn dkg_round2(
&round1_public_packages,
thread_rng(),
)
.map_err(|e| IronfishError::new_with_source(IronfishErrorKind::FrostLibError, e))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should look into adding fmt::Display for the errors returned from the frost lib in std mode, then I think we can skip spamming these map_err everywhere. Doesn't need to happen right now, just thinking out loud.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do have fmt::Display in std mode 🤔

I'll see if we can easily get rid of these

@@ -43,7 +43,7 @@ chacha20poly1305 = "0.10.1"
crypto_box = { version = "0.9", features = ["std"] }
ff = "0.12.0"
group = "0.12.0"
ironfish-frost = { git = "https://github.com/iron-fish/ironfish-frost.git", branch = "main" }
ironfish-frost = { git = "https://github.com/iron-fish/ironfish-frost.git", branch = "main", features = ["std", "signing"] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use the default features here, so we don't need to define custom features? The difference I guess is that ironfish-frost has dkg, but we aren't enabling it here https://github.com/iron-fish/ironfish-frost/blob/main/Cargo.toml#L27

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think we can use the default features here. We also support dkg in the CLI, and I can't remember what's behind the dkg feature in ironfish-frost

let authorizing_key = Option::from(SubgroupPoint::from_bytes(&authorizing_key.serialize()))
.expect("failied to derive authorizing key");
let mut bytes: [u8; 32] = [0; 32];
bytes.copy_from_slice(&authorizing_key.serialize().unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should re-factor this to return a result instead of using an unwrap and expect on the next line

@@ -33,7 +35,7 @@ pub fn split_spender_key(
split_secret(spender_key, identities, min_signers, thread_rng())?;

assert_eq!(
public_key_package.verifying_key().serialize(),
public_key_package.verifying_key().serialize().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unwrap -> result

@@ -229,7 +229,9 @@ impl UnsignedTransaction {

let serialized_signature = authorizing_group_signature.serialize();

let transaction = self.add_signature(serialized_signature)?;
let mut bytes = [0; 64];
bytes.copy_from_slice(&serialized_signature.unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unwrap -> result

@hughy hughy merged commit 5ea1113 into staging Sep 13, 2024
13 checks passed
@hughy hughy deleted the hughy/ironfish-frost-integration branch September 13, 2024 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants