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

ProgrammingCryptol zipWith HMAC #803

Closed
weaversa opened this issue Jul 6, 2020 · 4 comments · Fixed by #900
Closed

ProgrammingCryptol zipWith HMAC #803

weaversa opened this issue Jul 6, 2020 · 4 comments · Fixed by #900
Assignees
Labels
docs LaTeX, markdown, literate haskell, or in-REPL documentation question Not a task, but rather a question or discussion topic
Milestone

Comments

@weaversa
Copy link
Collaborator

weaversa commented Jul 6, 2020

On page 25, HMAC is defined using zipWith twice. What is zipWith buying us here? Doesn't xor work pairwise already?

Cryptol> zipWith (^) (join [0..7]) (join (repeat 0x5c))
Showing a specific instance of polymorphic result:
  * Using '3' for type argument 'n' of 'Cryptol::repeat'
0x59652b
Cryptol> (join [0..7]) ^ (join (repeat 0x5c))
Showing a specific instance of polymorphic result:
  * Using '3' for type argument 'n' of 'Cryptol::repeat'
0x59652b
@yav
Copy link
Member

yav commented Jul 6, 2020

Not sure about the reasoning, might be just an oversight. I agree that using ^ without zipWith is more direct, and xor-ing words together is really not that exotic.

@robdockins
Copy link
Contributor

I think that (^) is equal to zipWith (^) for all the types where that makes sense.

@robdockins robdockins added the question Not a task, but rather a question or discussion topic label Jul 6, 2020
@brianhuffman brianhuffman added the docs LaTeX, markdown, literate haskell, or in-REPL documentation label Sep 22, 2020
@atomb atomb added this to the 2.10.0 milestone Sep 22, 2020
@brianhuffman
Copy link
Contributor

We might add some text explaining that (^) is equivalent to zipWith (^); that would be a useful lesson to communicate in the book.

@brianhuffman brianhuffman self-assigned this Sep 23, 2020
@brianhuffman
Copy link
Contributor

That particular part of the book is explaining how modules work; it is not trying to explain the code itself. So I think it probably makes sense to just change the code without changing any of the surrounding text.

@brianhuffman brianhuffman linked a pull request Sep 23, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs LaTeX, markdown, literate haskell, or in-REPL documentation question Not a task, but rather a question or discussion topic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants