mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-10 19:43:13 +02:00
Add ElligatorSwift key creation and ECDH logic
Co-authored-by: Dhruv Mehta <856960+dhruv@users.noreply.github.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <hash.h>
|
||||
#include <secp256k1.h>
|
||||
#include <secp256k1_ellswift.h>
|
||||
#include <secp256k1_extrakeys.h>
|
||||
#include <secp256k1_recovery.h>
|
||||
#include <secp256k1_schnorrsig.h>
|
||||
@@ -335,6 +336,20 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChi
|
||||
return true;
|
||||
}
|
||||
|
||||
CPubKey EllSwiftPubKey::Decode() const
|
||||
{
|
||||
secp256k1_pubkey pubkey;
|
||||
secp256k1_ellswift_decode(secp256k1_context_static, &pubkey, UCharCast(m_pubkey.data()));
|
||||
|
||||
size_t sz = CPubKey::COMPRESSED_SIZE;
|
||||
std::array<uint8_t, CPubKey::COMPRESSED_SIZE> vch_bytes;
|
||||
|
||||
secp256k1_ec_pubkey_serialize(secp256k1_context_static, vch_bytes.data(), &sz, &pubkey, SECP256K1_EC_COMPRESSED);
|
||||
assert(sz == vch_bytes.size());
|
||||
|
||||
return CPubKey{vch_bytes.begin(), vch_bytes.end()};
|
||||
}
|
||||
|
||||
void CExtPubKey::Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const {
|
||||
code[0] = nDepth;
|
||||
memcpy(code+1, vchFingerprint, 4);
|
||||
|
Reference in New Issue
Block a user