-
Notifications
You must be signed in to change notification settings - Fork 45
feat: support bytes codec in ProtocolKey
#2557
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8185a0c
refactor(common): promote 'codec' module to directory
jpraynaud a2bb004
feat(common): add binary codec
jpraynaud 7ac3a17
refactor(common): simplify binary codec trait
jpraynaud bf11e52
refactor(common): update binary codec to support hex encoding
jpraynaud 71cf605
feat(common): support bytes hex encoding in 'ProtocolKey'
jpraynaud c2ea537
refactor(common): native support for ed25519 'Signature' bytes encoding
jpraynaud 164854f
feat(common): support bytes hex encoding for individual signatures
jpraynaud 839e147
fix(common): avoid panics in 'from_bytes' conversions
jpraynaud f9d6fcb
fix(common): broken tests in 'fake_keys'
jpraynaud e708723
fix(common): fix clippy warnings
jpraynaud 76f15ce
refactor(common): rename 'ToBytes' in 'TryToBytes'
jpraynaud 1038f4e
refactor(common): enhance 'MKProof' conversion to binary
jpraynaud f60f32a
refactor(common): enhance 'MKMapProof' conversion to binary
jpraynaud 1f0605f
test(aggregator): add golden tests for individual signature message
jpraynaud 88fbb08
test(common): add golden tests for certificate message
jpraynaud f42fcc6
refactor(common): enhance 'OpCert' conversion to binary
jpraynaud ce41837
test(aggregator): add golden tests for signer message part
jpraynaud 69d00ee
docs: update CHANGELOG
jpraynaud 873cdb8
chore: upgrade crate versions
jpraynaud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use anyhow::anyhow; | ||
use bech32::{self, Bech32, Hrp}; | ||
|
||
use crate::StdResult; | ||
|
||
/// Encode to bech32 given Human Readable Part (hrp) and data | ||
pub fn encode_bech32(human_readable_part: &str, data: &[u8]) -> StdResult<String> { | ||
let human_readable_part = Hrp::parse(human_readable_part).map_err(|e| anyhow!(e))?; | ||
bech32::encode::<Bech32>(human_readable_part, data).map_err(|e| anyhow!(e)) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use hex::FromHex; | ||
|
||
use super::encode_bech32; | ||
|
||
#[test] | ||
fn test_bech32_encode() { | ||
let hrp = "pool"; | ||
let data = | ||
Vec::from_hex("edfa208d441511f9595ba80e8f3a7b07b6a80cbc9dda9d8e9d1dc039").unwrap(); | ||
let encoded_data = encode_bech32(hrp, &data).unwrap(); | ||
let expected_encoded_data = | ||
"pool1ahazpr2yz5gljk2m4q8g7wnmq7m2sr9unhdfmr5arhqrjnntwdz".to_string(); | ||
|
||
assert_eq!(expected_encoded_data, encoded_data); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.