-
Notifications
You must be signed in to change notification settings - Fork 36
Update stellar-strkey to 0.0.18 #547
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
c7796c1
6f3e5ca
e69fdd3
150246b
5c69faa
355ac1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,8 +160,7 @@ impl core::str::FromStr for MuxedAccount { | |
| ed25519: Uint256(ed25519), | ||
| id, | ||
| })), | ||
| stellar_strkey::Strkey::PrivateKeyEd25519(_) | ||
| | stellar_strkey::Strkey::PreAuthTx(_) | ||
| stellar_strkey::Strkey::PreAuthTx(_) | ||
| | stellar_strkey::Strkey::HashX(_) | ||
| | stellar_strkey::Strkey::SignedPayloadEd25519(_) | ||
| | stellar_strkey::Strkey::Contract(_) | ||
|
|
@@ -204,10 +203,8 @@ impl core::fmt::Display for SignerKeyEd25519SignedPayload { | |
| ed25519: Uint256(ed25519), | ||
| payload, | ||
| } = self; | ||
| let k = stellar_strkey::ed25519::SignedPayload { | ||
| ed25519: *ed25519, | ||
| payload: payload.into(), | ||
| }; | ||
| let k = stellar_strkey::ed25519::SignedPayload::new(*ed25519, payload.as_ref()) | ||
| .map_err(|_| core::fmt::Error)?; | ||
|
Comment on lines
-201
to
+207
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a subtle meaningful change here that I'd like to give a heads up and a chance for commentary before this is merged. The Previously you could construct a The latest rs-stellar-strkey rectified the asymmetry in its own type for two reasons:
This has a side-effect that it's possible to construct a I think this change is inevitable unless we remove the limits from rs-stellar-strkey, and walked back the no-std no-alloc support for that type. I don't think this can effect stellar-core, but there is some XDR, albeit invalid, that cannot be represented in string and json forms.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why do we need to panic in the Display impl. Can't we just return something like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will create the same problem that the auditors had with the strkey library, that the type will not roundtrip which can also be a failure point similar to the failure point we are trying to address here. Maybe it's more appropriate to use the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could look at introducing a validation into the XDR type so that it cannot be constructed with a payload outside the range. We do that today with max lengths on XDR var arrays, but not min lengths.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why is that an issue, if the input is invalid? IMO it doesn't make sense to require every input to be able to roundtrip. Moreover, this is about XDR types, not strkey types. There is no requirement for XDR types to roundtrip through Display, is there? It's not a serialization format.
That's an option, but I'm still not sold on the roundtrip argument TBH.
Comment on lines
+206
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a Useful? React with 👍 / 👎. |
||
| let s = k.to_string(); | ||
| f.write_str(&s)?; | ||
| Ok(()) | ||
|
|
@@ -217,11 +214,10 @@ impl core::fmt::Display for SignerKeyEd25519SignedPayload { | |
| impl core::str::FromStr for SignerKeyEd25519SignedPayload { | ||
| type Err = Error; | ||
| fn from_str(s: &str) -> core::result::Result<Self, Self::Err> { | ||
| let stellar_strkey::ed25519::SignedPayload { ed25519, payload } = | ||
| stellar_strkey::ed25519::SignedPayload::from_str(s)?; | ||
| let sp = stellar_strkey::ed25519::SignedPayload::from_str(s)?; | ||
| Ok(SignerKeyEd25519SignedPayload { | ||
| ed25519: Uint256(ed25519), | ||
| payload: payload.try_into()?, | ||
| ed25519: Uint256(*sp.ed25519()), | ||
| payload: sp.payload().try_into()?, | ||
| }) | ||
| } | ||
| } | ||
|
|
@@ -240,16 +236,13 @@ impl core::str::FromStr for SignerKey { | |
| stellar_strkey::Strkey::HashX(stellar_strkey::HashX(h)) => { | ||
| Ok(SignerKey::HashX(Uint256(h))) | ||
| } | ||
| stellar_strkey::Strkey::SignedPayloadEd25519( | ||
| stellar_strkey::ed25519::SignedPayload { ed25519, payload }, | ||
| ) => Ok(SignerKey::Ed25519SignedPayload( | ||
| SignerKeyEd25519SignedPayload { | ||
| ed25519: Uint256(ed25519), | ||
| payload: payload.try_into()?, | ||
| }, | ||
| )), | ||
| stellar_strkey::Strkey::PrivateKeyEd25519(_) | ||
| | stellar_strkey::Strkey::Contract(_) | ||
| stellar_strkey::Strkey::SignedPayloadEd25519(sp) => Ok( | ||
| SignerKey::Ed25519SignedPayload(SignerKeyEd25519SignedPayload { | ||
| ed25519: Uint256(*sp.ed25519()), | ||
| payload: sp.payload().try_into()?, | ||
| }), | ||
| ), | ||
| stellar_strkey::Strkey::Contract(_) | ||
| | stellar_strkey::Strkey::MuxedAccountEd25519(_) | ||
| | stellar_strkey::Strkey::LiquidityPool(_) | ||
| | stellar_strkey::Strkey::ClaimableBalance(_) => Err(Error::Invalid), | ||
|
|
@@ -332,8 +325,7 @@ impl core::str::FromStr for ScAddress { | |
| )) => Ok(ScAddress::ClaimableBalance( | ||
| ClaimableBalanceId::ClaimableBalanceIdTypeV0(Hash(claimable_balance)), | ||
| )), | ||
| stellar_strkey::Strkey::PrivateKeyEd25519(_) | ||
| | stellar_strkey::Strkey::PreAuthTx(_) | ||
| stellar_strkey::Strkey::PreAuthTx(_) | ||
| | stellar_strkey::Strkey::HashX(_) | ||
| | stellar_strkey::Strkey::SignedPayloadEd25519(_) => Err(Error::Invalid), | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.