Bitcoin full node and query server

Feb 16, 2020

View in context in the libbitcoin Slack #general mirror.

skaht01:38
FYSA - almost have SLIP10 functioning for ed25519. Lessons learned could feed libbitcoin hd-new and hd-private code to accomodate SLIP 10.
(edited)
👍 3
skaht21:22
hd_hmac.cpp C++ · 14.6 KB
#include <iostream>
#include <string>
#include <regex>

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <sodium.h>

using namespace std;

static const int MAX = 512;                                // MAX input data-message size of 512 bits to hashed using hmac-sha512
static void      sprintkey( unsigned char*, const char* ); // Converts hexadecimal char* to a MPI represented as an unsigned char sequence

enum class Curve { undefined, ed25519, secp256k1, nistp256 };

/** 
    From libgcrypt-1.8.5/cipher/ecc-curves.c:

    --ed25519   = apply Bernstein's ed25519 curve   ( order = 0x1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED }
    --secp256k1 = apply the Bitcoin secp256k1 curve { order = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 }
    --nistp256  = apply the NIST nistp256 curve     { oder  = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 }
**/

int main( const int   argc, 
          const char *argv[] )
{
  const char    *root_chaincode_ed25519   = "656432353531392073656564",     // "ed25519 seed"
                *root_chaincode_secp256k1 = "426974636f696e2073656564",     // "Bitcoin seed";
                *root_chaincode_nistp256  = "4e69737432353670312073656564"; // "Nist256p1 seed";

  string         line;
  smatch         matches;
  regex          pattern_help1{     R"(-h)"          },         // help
                 pattern_help2{     R"(--help)"      },         // help
                 pattern_index1{    R"(-i)"          },         // index
                 pattern_index2{    R"(--index)"     },         // index
                 pattern_index_val{ R"([0-9]{1,10})" },         // extracts integer index to be treated as hardened
                 pattern_ed25519{   R"(--ed25519)"   },         // sets SLIP 10 defined          chaincode of root for the ed25519 curve
full file