5
1
Bitcoinlib refers to the requirement that if s > ORDER / 2, then the complement of s should be used instead since it's one byte shorter
This sounds like it's referring to the inverse or negative s value, but I also know complement can be a computer science term.
The relevant code can be found here (perhaps someone adept with the Bitcoin Core code can chime in on what the code is doing), so, what is the complement of s referring to?
Fantastic! Can you write some pseudocode (or Python) which shows how to flip the s value? It's not just the negative value is it? – Wizard Of Ozzie – 2015-06-25T02:45:01.013
2The pseudocode is very simple:
s2 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1;– amaclin – 2015-06-25T04:46:41.900@amaclin oh wow, so I was absolutely overthinking this. Of course, i see the logic to it now. Tangentially, why is this code so un-Pythonic? Is it basically a Python "port" of the C++ code?
– Wizard Of Ozzie – 2015-06-25T05:14:43.8171
python-bitcoinlibis unpythonic because it is emulating all of the structures that you find in Bitcoin Cores CPP codebase. You could make it more pythonic but it wouldn't be as useful that way. – Anonymous – 2015-06-25T20:12:05.010