Fabcoin Core  0.16.2
P2P Digital Currency
Functions
lax_der_privatekey_parsing.c File Reference
#include <string.h>
#include <secp256k1.h>
#include "lax_der_privatekey_parsing.h"
Include dependency graph for lax_der_privatekey_parsing.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int ec_privkey_import_der (const secp256k1_context *ctx, unsigned char *out32, const unsigned char *privkey, size_t privkeylen)
 Import a private key in DER format. More...
 
int ec_privkey_export_der (const secp256k1_context *ctx, unsigned char *privkey, size_t *privkeylen, const unsigned char *key32, int compressed)
 Export a private key in DER format. More...
 

Function Documentation

int ec_privkey_export_der ( const secp256k1_context ctx,
unsigned char *  privkey,
size_t *  privkeylen,
const unsigned char *  seckey,
int  compressed 
)

Export a private key in DER format.

Returns: 1 if the private key was valid. Args: ctx: pointer to a context object, initialized for signing (cannot be NULL) Out: privkey: pointer to an array for storing the private key in BER. Should have space for 279 bytes, and cannot be NULL. privkeylen: Pointer to an int where the length of the private key in privkey will be stored. In: seckey: pointer to a 32-byte secret key to export. compressed: 1 if the key should be exported in compressed format, 0 otherwise

This function is purely meant for compatibility with applications that require BER encoded keys. When working with secp256k1-specific code, the simple 32-byte private keys are sufficient.

Note that this function does not guarantee correct DER output. It is guaranteed to be parsable by secp256k1_ec_privkey_import_der

Definition at line 56 of file lax_der_privatekey_parsing.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int ec_privkey_import_der ( const secp256k1_context ctx,
unsigned char *  seckey,
const unsigned char *  privkey,
size_t  privkeylen 
)

Import a private key in DER format.

Returns: 1 if a private key was extracted. Args: ctx: pointer to a context object (cannot be NULL). Out: seckey: pointer to a 32-byte array for storing the private key. (cannot be NULL). In: privkey: pointer to a private key in DER format (cannot be NULL). privkeylen: length of the DER private key pointed to be privkey.

This function will accept more than just strict DER, and even allow some BER violations. The public key stored inside the DER-encoded private key is not verified for correctness, nor are the curve parameters. Use this function only if you know in advance it is supposed to contain a secp256k1 private key.

Definition at line 12 of file lax_der_privatekey_parsing.c.

Here is the call graph for this function:

Here is the caller graph for this function: