-
Notifications
You must be signed in to change notification settings - Fork 187
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
libsecp256k1 bindings: also use secp256k1 for point addition #1621
base: master
Are you sure you want to change the base?
Conversation
Taken from Electrum 65d896b
Also Mark if you do end up helping here -- help me write tests for this? Or are the tests we already have sufficient? (I couldn't easily port over the Electrum tests as they massively refactored |
Yeah this is a decent idea. Point addition isn't the slowest operation in EC math but it will definitely help if it's accelerated. I expect this would get used in the BIP32 key derivations. The code looks exactly right too, no problems there. :) (If it runs, then it seems to be right!) |
Note that in the diff I modified the signature for This change affects your code here in Line 419 in 41874f8
The reason for my changing it to My reading of this situation is that it would work 100%. Can you sanity check me on that? :) |
Hmm the correct argument type should |
Hmm yeah actually those |
For reference the C call signature:
where |
This makes my brain melt. I know C really well. I know Python well as well. But thinking about how ctypes tries to think about how C thinks about things makes my brain melt. You clearly are more of a I'll leave it as-is for fear of touching it. After this is merged -- feel free to correct what they did. I am pushing a commit now that adds some tests for this (I had to import a whole bunch of code from Electrum to do it -- but it's a good thing: they refactored that Now |
This involved pulling in 2 classes refactored from EC_KEY: EC_Pubkey and EC_Privkey. They work a lot like the original EC_KEY class. Note that now all 3 classes are present in the codebase (perhaps some day we will transition to using the new classes).
@markblundeberg Can you review this again? I pushed some changes that adds some stuff from Electrum (I actually wanted their tests for these operations -- but I ended up pulling in a bunch of stuff into Can you review the changes in terms of relevancy? I am pretty sure the code is correct and the port is ok (although if your eyeballs catch something, that's good!). All tests pass. In particular I don't know what that signature65 business is and a bunch of utility functions added to Can you tell me if any of them need to be deleted? Maybe they are BTC-only things? Also I realize Thanks! |
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.
I looked over the code and it seems generally reasonable, though for now it's just bloating the file I guess. :-)
Signature65 is the thing used in signed messages (65 byte signatures that allow unambiguous pubkey recovery).
following @markblundeberg's suggestion Electron-Cash#1621 (comment)
@SomberNight well that's one way to answer the question. Thanks :-) |
Ha ha — that works, @SomberNight. Thanks Mark a ton for your review. I will update this PR soon to reflect discussion and ghost43’s changes. I am thinking about the bloat issue — I may try and simplify the file by either re-using this code or some other approach. |
This is from 1669dd9 as per @markblundeberg 's suggestion.
As per @markblundeberg 's suggetion.
@markblundeberg Ok, I incorporated your changes but I want to let it sit some more. I am travelling but maybe I can find time to refactor what we have in |
I saw this commit recently in Electrum: 65d896b
It was an easy port, but I have no idea if this helps or what. Is it worth doing? @markblundeberg help!
Note I ported it over by copy-pasting the code and adapting it without really understanding. I am weak at ECC crypto operations, sadly. I could use some help here.
All tox tests pass.. so that's a good sign.. I think. EC also runs and signs and verifies sigs ok both with and without schnorr.
No idea what I am doing though. :)
Should we merge this commit? Is it worth it? Help!