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

feat(nodeconfig)!: Default to Bech32 format for IOTA key pairs #4826

Merged
merged 25 commits into from
Feb 4, 2025
Merged
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
472193b
line
Alex6323 Jan 10, 2025
2d81cf3
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Jan 10, 2025
de76660
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Jan 16, 2025
70b66b2
switch to Bech32 serialized IOTA key pairs
Alex6323 Jan 16, 2025
15f7b73
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Jan 20, 2025
37d1837
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Jan 21, 2025
6dab4e5
improve comment
Alex6323 Jan 21, 2025
10e43e9
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Jan 21, 2025
1f2903a
clippy
Alex6323 Jan 21, 2025
747d6dd
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Jan 23, 2025
8a51781
use config specific serialization for IotaKeyPair
Alex6323 Jan 23, 2025
aab6a51
expect
Alex6323 Jan 23, 2025
324ba1e
fix rebase
Alex6323 Jan 24, 2025
534227c
make generic
Alex6323 Jan 24, 2025
abd27ff
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Jan 24, 2025
92fc5cf
suggestions
DaughterOfMars Jan 24, 2025
f6e3a42
one more
DaughterOfMars Jan 24, 2025
2ea14ca
improve comment
Alex6323 Jan 27, 2025
901d9ed
update network config snap
Alex6323 Jan 28, 2025
cd5d589
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Jan 31, 2025
0b79c6b
Merge branch 'develop' into dev-tools/bech32-private-keys
Alex6323 Feb 3, 2025
e4f0a0c
Merge branch 'develop' into dev-tools/bech32-private-keys
thibault-martinez Feb 4, 2025
7558191
Merge branch 'develop' into dev-tools/bech32-private-keys
thibault-martinez Feb 4, 2025
855e727
nits
thibault-martinez Feb 4, 2025
155a46c
fmt
thibault-martinez Feb 4, 2025
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
12 changes: 10 additions & 2 deletions crates/iota-types/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ impl EncodeDecodeBase64 for IotaKeyPair {
Self::from_bytes(&bytes).map_err(|_| FastCryptoError::InvalidInput)
}
}

impl IotaKeyPair {
pub fn to_bytes(&self) -> Vec<u8> {
let mut bytes: Vec<u8> = Vec::new();
Expand Down Expand Up @@ -268,7 +269,9 @@ impl Serialize for IotaKeyPair {
where
S: Serializer,
{
let s = self.encode_base64();
use serde::ser::Error;
// Serialize keypair to Bech32 string
let s = self.encode().map_err(|e| Error::custom(e.to_string()))?;
serializer.serialize_str(&s)
}
}
Expand All @@ -280,7 +283,12 @@ impl<'de> Deserialize<'de> for IotaKeyPair {
{
use serde::de::Error;
let s = String::deserialize(deserializer)?;
IotaKeyPair::decode_base64(&s).map_err(|e| Error::custom(e.to_string()))
// Deserialize keypair from Bech32 (default) or Base64 string
if let Ok(kp) = IotaKeyPair::decode(&s) {
Ok(kp)
} else {
IotaKeyPair::decode_base64(&s).map_err(|e| Error::custom(e.to_string()))
}
}
}

Expand Down
Loading