-
Notifications
You must be signed in to change notification settings - Fork 169
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
Migrate to new padding rule #1343
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left some comments inline - but all of them are pretty minor.
I was actually expecting a bit more changes - but nice to see that the impact is not that big.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left a few more small comments inline.
Overall, let's hold off on merging this until we propagate the changes to miden-base
(we can do that once we update miden-base
to work with the current VM version).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good! Thank you!
stdlib/asm/crypto/hashes/rpo.masm
Outdated
#! even words: 48 cycles + 3 * words | ||
#! odd words: 60 cycles + 3 * words | ||
#! even words: 49 cycles + 3 * words | ||
#! odd words: 61 cycles + 3 * words | ||
export.hash_memory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that I realized: I'm not sure the behavior of this procedure is entirely consistent with its naming/docs. Specifically, we assume that the number of elements to be hashed is a multiple of 4 - so, for example, it cannot be used to hash 9 elements.
Maybe a better approach would be to split it into 2 procedures:
#! Input: [C, B, A, start_addr, num_words, ...]
#! Output: [C', B', A', end_addr, ...]
export.absorb_words_from_memory
The above procedure would be similar to absorb_double_words_from_memory
but would handle the case of the odd number of words. (separately, I think we could modify the absorb_double_words_from_memory
procedure to also take num_words
instead of end_addr
).
The second procedure would actually be for computing hash of memory:
#! Input: [start_addr, num_elements, ...]
#! Output: [HASH, end_addr, ...]
export.hash_memory
One open question is whether we should assume that the last word is padded with zeros (in case the number of elements is not divisible by 4) or if we need to handle this in the procedure.
5b93c94
to
18ea698
Compare
@Fumuran - could you merge the latest |
@Fumuran could you update this branch to use |
d24a429
to
816e28c
Compare
@Fumuran - this is basically done, right? If so, before merging this, let's create a parallel PR in |
@bobbinth Should I prioritize migrating |
Describe your changes
Change the padding rule for RPO so that it uses the one in the xHash paper.
Checklist before requesting a review
next
according to naming convention.