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

support Message Id format for Aleo. #689

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

anstylian
Copy link

Description

Support MessageIdFormat for Aleo

@anstylian anstylian requested a review from a team as a code owner November 12, 2024 20:45
Copy link
Contributor

@cjcobb23 cjcobb23 left a comment

Choose a reason for hiding this comment

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

this should be implemented like the other message ids, particularly with a regex. This is not very safe to use the aleo_types crate to do the parsing. For instance, what if that crate allows different representations of the same transaction id? like upper vs lowercase, 0x vs not, etc. What if it does not allow that today, but does in the future? This part of the code is very sensitive and needs to be extremely secure.

@anstylian
Copy link
Author

@cjcobb23 thanks for the review.
A regex to verify message ids has been added.

Please let me know if further changes are needed.

}

const PATTERN: &str =
"^(at1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58})-(au1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58})$";
Copy link
Contributor

Choose a reason for hiding this comment

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

why are these symbols so scrambled? Can we put them in alphanumeric order?

Copy link
Author

@anstylian anstylian Nov 13, 2024

Choose a reason for hiding this comment

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

We can put the in alphanumeric order if you prefer it.
The order follows the order of "Bech32"
https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32

I have copied the table here for reference:

0 1 2 3 4 5 6 7
+0 q p z r y 9 x 8
+8 g f 2 t v d w 0
+16 s 3 j n 5 4 k h
+24 c e 6 m u a 7 l

Just let me know how you prefer it

Copy link
Contributor

@cgorenflo cgorenflo Nov 13, 2024

Choose a reason for hiding this comment

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

I would prefer to make the pattern as readable as possible, otherwise regex is easy to get wrong. You could also consider using ranges to make it more obvious which letters are skipped. I think [02-9ac-hj-np-z] works, but please double-check

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