field: Improve docs +tests of secp256k1_fe_set_b32#1205
Conversation
64c41de to
727d50a
Compare
|
Concept ACK, though is the inclusion of the last commit intentional? An alternative follow-up could be to split the function in two:
This would get rid of the fact that this is one of the few places in the codebase where field magnitude/normalization properties depend on runtime values (they're almost always compile-time known otherwise). |
Yes, but I'm happy to remove it, of course. The story behind this is that I had forgotten to remove a debug printer first when I opened this PR. I mentioned this to @jonasnick who told me that he also had to write these functions multiple times in the past, so we thought it's a good idea to have one in the code base. Then I made it a bit nicer and added a commit. And I felt it's not worth a separate PR (but maybe I was just being lazy there). |
That's a great idea. We could still have |
It could, but I think that'd be confusing. The second function cannot handle overflow; if it was provided input that's out of range, it should return failure, and not make any promises about the parsed |
|
Ok yes, understood now. |
|
utACK 727d50a |
727d50a to
162da73
Compare
|
force-pushed to address @jonasnick's nits |
We could also change the interface to accept an explicit
overflowoutput variable, like for the scalar function. I think this makes handling (and ignoring!) overflow much more explicit in the code. What do you think?