Add HKDF_HMAC256_L32 and method to negate a private key#14047
Add HKDF_HMAC256_L32 and method to negate a private key#14047laanwj merged 4 commits intobitcoin:masterfrom
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
2130c88 to
dc02f90
Compare
75a15a3 to
a034ec2
Compare
a034ec2 to
32633ff
Compare
|
Rebased |
32633ff to
acf3deb
Compare
|
utACK acf3debc6a2f8b80a5de1e71bc658086c6de77b4 |
acf3deb to
65948ee
Compare
|
rebased |
sipa
left a comment
There was a problem hiding this comment.
utACK 65948ee3d41c33cd442a6572ab9e9d071499022d, just some nits.
src/crypto/hkdf_sha256_32.cpp
Outdated
There was a problem hiding this comment.
Style nit: we don't usually use the C++ cast operators for primitive types (just (const unsigned char*)salt.c_str() works).
src/crypto/hkdf_sha256_32.cpp
Outdated
65948ee to
8794a4b
Compare
|
Thanks for the review. Fixed the C++ cast nit. |
|
Restarted failed job. |
| @@ -0,0 +1,21 @@ | |||
| // Copyright (c) 2018 The Bitcoin Core developers | |||
| std::vector<unsigned char> salt = ParseHex(salt_hex); | ||
| std::vector<unsigned char> info = ParseHex(info_hex); | ||
|
|
||
|
|
There was a problem hiding this comment.
nit, remove 2nd empty line.
| BOOST_CHECK(tag == tagres); | ||
| } | ||
|
|
||
| static void TestHKDF_SHA256_32(const std::string &ikm_hex, const std::string &salt_hex, const std::string &info_hex, const std::string &okm_check_hex) { |
There was a problem hiding this comment.
nit, space after &, not before.
|
utACK 8794a4b |
8794a4b QA: add test for HKDF HMAC_SHA256 L32 (Jonas Schnelli) 551d489 Add HKDF HMAC_SHA256 L=32 implementations (Jonas Schnelli) 3b64f85 QA: add test for CKey::Negate() (Jonas Schnelli) 463921b CKey: add method to negate the key (Jonas Schnelli) Pull request description: This adds a limited implementation of `HKDF` (defined by rfc5869) that supports only HMAC-SHA256 and length output of 32 bytes (will be required for v2 transport protocol). This PR also includes a method to negate a private key which is useful to enforce public keys starting with 0x02 (or 0x03) (a requirement for the v2 transport protocol). The new `CKey::Negate()` method is pretty much a wrapper around `secp256k1_ec_privkey_negate()`. Including tests. This is a subset of #14032 and a pre-requirement for the v2 transport protocol. ACKs for commit 8794a4: Tree-SHA512: 5341929dfa29f5da766ec3612784baec6a3ad69972f08b5a985a8aafdae4dae36f104a2b888d1f5d1f33561456bd111f960d7e32c2cc4fd18e48358468f26c1a
…ate key 8794a4b QA: add test for HKDF HMAC_SHA256 L32 (Jonas Schnelli) 551d489 Add HKDF HMAC_SHA256 L=32 implementations (Jonas Schnelli) 3b64f85 QA: add test for CKey::Negate() (Jonas Schnelli) 463921b CKey: add method to negate the key (Jonas Schnelli) Pull request description: This adds a limited implementation of `HKDF` (defined by rfc5869) that supports only HMAC-SHA256 and length output of 32 bytes (will be required for v2 transport protocol). This PR also includes a method to negate a private key which is useful to enforce public keys starting with 0x02 (or 0x03) (a requirement for the v2 transport protocol). The new `CKey::Negate()` method is pretty much a wrapper around `secp256k1_ec_privkey_negate()`. Including tests. This is a subset of bitcoin#14032 and a pre-requirement for the v2 transport protocol. ACKs for commit 8794a4: Tree-SHA512: 5341929dfa29f5da766ec3612784baec6a3ad69972f08b5a985a8aafdae4dae36f104a2b888d1f5d1f33561456bd111f960d7e32c2cc4fd18e48358468f26c1a
Summary: bitcoin/bitcoin@463921b --- Partial backport of Core [[bitcoin/bitcoin#14047 | PR14047]] Test Plan: ninja Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7393
Summary: bitcoin/bitcoin@3b64f85 --- Depends on D7393 Partial backport of Core [[bitcoin/bitcoin#14047 | PR14047]] Test Plan: ninja check-bitcoin-key_tests Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7394
Summary: bitcoin/bitcoin@551d489 --- Depends on D7394 Partial backport of Core [[bitcoin/bitcoin#14047 | PR14047]] Test Plan: ninja Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7395
Summary: bitcoin/bitcoin@8794a4b --- Depends on D7395 Partial backport of Core [[bitcoin/bitcoin#14047 | PR14047]] Test Plan: ninja check-bitcoin-crypto_tests Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7396
…ate key 8794a4b QA: add test for HKDF HMAC_SHA256 L32 (Jonas Schnelli) 551d489 Add HKDF HMAC_SHA256 L=32 implementations (Jonas Schnelli) 3b64f85 QA: add test for CKey::Negate() (Jonas Schnelli) 463921b CKey: add method to negate the key (Jonas Schnelli) Pull request description: This adds a limited implementation of `HKDF` (defined by rfc5869) that supports only HMAC-SHA256 and length output of 32 bytes (will be required for v2 transport protocol). This PR also includes a method to negate a private key which is useful to enforce public keys starting with 0x02 (or 0x03) (a requirement for the v2 transport protocol). The new `CKey::Negate()` method is pretty much a wrapper around `secp256k1_ec_privkey_negate()`. Including tests. This is a subset of bitcoin#14032 and a pre-requirement for the v2 transport protocol. ACKs for commit 8794a4: Tree-SHA512: 5341929dfa29f5da766ec3612784baec6a3ad69972f08b5a985a8aafdae4dae36f104a2b888d1f5d1f33561456bd111f960d7e32c2cc4fd18e48358468f26c1a
This adds a limited implementation of
HKDF(defined by rfc5869) that supports only HMAC-SHA256 and length output of 32 bytes (will be required for v2 transport protocol).This PR also includes a method to negate a private key which is useful to enforce public keys starting with 0x02 (or 0x03) (a requirement for the v2 transport protocol). The new
CKey::Negate()method is pretty much a wrapper aroundsecp256k1_ec_privkey_negate().Including tests.
This is a subset of #14032 and a pre-requirement for the v2 transport protocol.