Bitcoin Core Github
43 subscribers
123K links
Download Telegram
πŸ’¬ josibake commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685690873)
Resolving since this is no longer relevant.
πŸ’¬ josibake commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685691416)
Took your suggestion of saving the pointer in a variable. I’m not sure about a cast helper, mainly because I don’t want to put `secp256k1_keypair` into a header file, so seems better to just have people use reinterpret cast wherever KeyPair is being used.
πŸ’¬ josibake commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685691767)
Removed all of the instances of initialisation the bool outside of a function call.
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685696117)
this is SO MUCH BETTER! \\:D/ (it even has the asserts that we were talking about)

I didn't trust, but verified, of course, if you think it makes sense, please add this test to the commit (you can add me as co-author if you want as `l0rinc <pap.lorinc@gmail.com>`):
```C++
BOOST_AUTO_TEST_CASE(key_sign_schnorr_tweak_test)
{
secp256k1_context* secp256k1_context_sign = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);

for (int i = 0; i < 1000; ++i) {
CKey key;
ke
...
πŸ€” paplorinc reviewed a pull request: "crypto, refactor: add new KeyPair class"
(https://github.com/bitcoin/bitcoin/pull/30051#pullrequestreview-2190286464)
Nice, left a few nits and a clarification
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685703075)
this is the only remaining part that I'm uncomfortable with, even the IDE is complaining:
<img src="https://github.com/user-attachments/assets/52bf7173-a562-4dde-9f2c-9834b3a5d5da">

which I'm not getting for `BIP324Cipher::Initialize`, since it's assigning a field, not a local variable.

Is there a more intuitive way to do this? Do we have tests to check that this value is cleared?
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685699288)
nit: in other cases it makes sense to call it `ret`, since it's the return value, here it's just a validity check - if you think it makes sense, [consider renaming](https://github.com/bitcoin/bitcoin/blob/master/src/key.cpp#L338) to avoid the surprise
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685701466)
nit: it's 64 because of https://github.com/bitcoin/bitcoin/blob/master/src/script/sign.cpp#L86, right?
It's not really called from other places, the assert seems like noise here.
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685702437)
`BOOST_CHECK` has very bad error messages, consider using the `_EQUAL` or in this case `_EQUAL_COLLECTIONS` for better errors:
```suggestion
BOOST_CHECK_EQUAL_COLLECTIONS(std::begin(sig64), std::end(sig64), sig.begin(), sig.end());
```
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685697345)
nit: I understand this was the code before and that we've talked about this before, but in other places we use short circuiting logic for such code: https://github.com/bitcoin/bitcoin/blob/master/src/secp256k1/src/modules/extrakeys/main_impl.h#L185. Will leave it up to you to decide which is better, seems safer to me not to call verify when we're already in an invalid state.
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685703954)
resolved
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685703852)
nice!
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685704154)
I'm still a bit hesitant here, see my related comment
πŸ’¬ paplorinc commented on pull request "fuzz: Limit parse_univalue input length":
(https://github.com/bitcoin/bitcoin/pull/30473#discussion_r1685732896)
would it make sense to use a trimmed version here instead of completely skipping the call?
πŸ’¬ hodlinator commented on pull request "rest: Reject truncated hex txid early in getutxos parsing":
(https://github.com/bitcoin/bitcoin/pull/30482#issuecomment-2241616078)
@paplorinc the first 3 commits here come from pending PR #30436, so comments on those changes are probably better to make there.
πŸ’¬ josibake commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685767669)
It's 64 because Schnorr signatures, unlike ECDSA signatures, are by definition 64 bytes (see https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki#description), so we definitely want to keep this assert.
πŸ’¬ paplorinc commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685769335)
Yes, of course, but that's already the case for every caller currently (i.e. not part of a public api, we know all the callers), and we're not really asserting this in other such methods, so it seems redundant to me. If you disagree, just resolve it, not a big deal either way.
πŸ’¬ josibake commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685772925)
In this case, I think it's better to match the style of the existing test but I've made a note regarding `_EQUAL` and `_EQUAL_COLLECTIONS` going forward.
πŸ’¬ josibake commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685779527)
Ah! I was misunderstanding `m_key = CKey()`. Since CKey (and KeyPair) are using secure allocator, the contents will be cleared before deletion (e.g. when the variable goes out of scope). But in the case of `BIP324Cipher::Initialize`, it seems `m_key` is used to initialize the connection, but then needs to be explicitly cleared by setting with an empty CKey (invalid CKey), because the member field will not go out of scope and be cleared.

So in this case, we don't need the `kp = KeyPair();` lin
...
πŸ’¬ josibake commented on pull request "crypto, refactor: add new KeyPair class":
(https://github.com/bitcoin/bitcoin/pull/30051#discussion_r1685779789)
My last comment was wrong, @itornaza is correct: the KeyPair destructor is doing the secure erase job and the `kp = KeyPair();` is unnecessary.