Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Functions | Variables
key.cpp File Reference
#include <key.h>
#include <crypto/common.h>
#include <crypto/hmac_sha512.h>
#include <random.h>
#include <secp256k1.h>
#include <secp256k1_recovery.h>
#include <secp256k1_schnorr.h>
Include dependency graph for key.cpp:

Go to the source code of this file.

Functions

int ec_privkey_import_der (const secp256k1_context *ctx, uint8_t *out32, const uint8_t *privkey, size_t privkeylen)
 These functions are taken from the libsecp256k1 distribution and are very ugly.
 
int ec_privkey_export_der (const secp256k1_context *ctx, uint8_t *privkey, size_t *privkeylen, const uint8_t *key32, bool compressed)
 This serializes to a DER encoding of the ECPrivateKey type from section C.4 of SEC 1 http://www.secg.org/sec1-v2.pdf.
 
bool SigHasLowR (const secp256k1_ecdsa_signature *sig)
 
static bool DoSignSchnorr (const CKey &key, const uint256 &hash, uint8_t *buf, uint32_t test_case)
 
bool ECC_InitSanityCheck ()
 Check that required EC support is available at runtime.
 
void ECC_Start ()
 Initialize the elliptic curve support.
 
void ECC_Stop ()
 Deinitialize the elliptic curve support.
 
static CKey validKey (bool compressed)
 

Variables

static secp256k1_contextsecp256k1_context_sign = nullptr
 

Function Documentation

◆ DoSignSchnorr()

static bool DoSignSchnorr ( const CKey key,
const uint256 hash,
uint8_t buf,
uint32_t  test_case 
)
static

Definition at line 272 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ec_privkey_export_der()

int ec_privkey_export_der ( const secp256k1_context ctx,
uint8_t privkey,
size_t privkeylen,
const uint8_t key32,
bool  compressed 
)

This serializes to a DER encoding of the ECPrivateKey type from section C.4 of SEC 1 http://www.secg.org/sec1-v2.pdf.

The optional parameters and publicKey fields are included.

privkey must point to an output buffer of length at least CKey::SIZE bytes. privkeylen must initially be set to the size of the privkey buffer. Upon return it will be set to the number of bytes used in the buffer. key32 must point to a 32-byte raw private key.

Definition at line 101 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ec_privkey_import_der()

int ec_privkey_import_der ( const secp256k1_context ctx,
uint8_t out32,
const uint8_t privkey,
size_t  privkeylen 
)

These functions are taken from the libsecp256k1 distribution and are very ugly.

This parses a format loosely based on a DER encoding of the ECPrivateKey type from section C.4 of SEC 1 http://www.secg.org/sec1-v2.pdf, with the following caveats:

  • The octet-length of the SEQUENCE must be encoded as 1 or 2 octets. It is not required to be encoded as one octet if it is less than 256, as DER would require.
  • The octet-length of the SEQUENCE must not be greater than the remaining length of the key encoding, but need not match it (i.e. the encoding may contain junk after the encoded SEQUENCE).
  • The privateKey OCTET STRING is zero-filled on the left to 32 octets.
  • Anything after the encoding of the privateKey OCTET STRING is ignored, whether or not it is validly encoded DER.

out32 must point to an output buffer of length at least 32 bytes.

Definition at line 40 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ECC_InitSanityCheck()

bool ECC_InitSanityCheck ( )

Check that required EC support is available at runtime.

Definition at line 427 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ECC_Start()

void ECC_Start ( )

Initialize the elliptic curve support.

May not be called twice without calling ECC_Stop first.

Definition at line 434 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ECC_Stop()

void ECC_Stop ( )

Deinitialize the elliptic curve support.

No-op if ECC_Start wasn't called first.

Definition at line 451 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SigHasLowR()

bool SigHasLowR ( const secp256k1_ecdsa_signature sig)

Definition at line 227 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validKey()

static CKey validKey ( bool  compressed)
static

Definition at line 460 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ secp256k1_context_sign

secp256k1_context* secp256k1_context_sign = nullptr
static

Definition at line 16 of file key.cpp.