Checking the libsecp256k1 implementation, it accepts a null pointer for aux_rand and uses the possibly negated private key alone without XORing with anything in that case.
This fix brings the implementation in-line with the C implementation.
Checking the libsecp256k1 implementation, it accepts a null pointer for aux_rand and uses the possibly negated private key alone without XORing with anything in that case.
This fix brings the implementation in-line with the C implementation.
@junderw thanks for your contribution, but I don't really see a reason to have identical APIs in libsecp and the reference implementation. In libsecp this is a convenience feature, but the reference implementation isn't supposed to be used anyway.
I do think there is merit to the reference implementation showing this as Optional[]
Also, I personally find the libsecp256k1 implementation to be more in line with the BIP340 in these regards, and thus felt that the python reference implementation should reflect that (to help those implementing it down the line. Not so that the reference itself could be used)
That said, I defer the decision to you. Please let me know if you still want to NACK this, and I'll close (or Kalle can close if he notices first)
Thanks for your time @jonasnick
BIP340 makes mention of optional alternative methods of generating k, and the security tradeoffs associated.
If you want to use an truly alternative nonce function, you can't use the reference implementation's API and then it doesn't matter whether aux_rand is optional.
Keeping it non-optional helps conveying that aux_rand "is recommended whenever available" as mentioned in the BIP.
Keeping it non-optional helps conveying that aux_rand "is recommended whenever available" as mentioned in the BIP.
Keeping it non-optional conveys "it is not optional" which contradicts the BIP.
That being said, I deferred the decision to you and it seems clear that you disagree with this PR, so I will close it as mentioned before.
Thanks for your time.