stacks-network / key-encoder-js

Library for encoding and decoding ecdsa private keys and converting between formats
MIT License
44 stars 27 forks source link

How to make raw keys #5

Open croraf opened 7 years ago

croraf commented 7 years ago

I need to make pem encoded secp256k1 keys.

I do this:

var KeyEncoder = require('key-encoder'),
    keyEncoder = new KeyEncoder('secp256k1')

How I create raw keys from here?

I first have to make these raw keys from here and then encode them in Pem format with keyEncoder.encodePrivate and keyEncoder.encodePublic?

earonesty commented 6 years ago

In this library, a raw key is a hex string. For secp256k1, you'll see it start with hex bytes 02, 03 or 04 and be either 33 or 65 bytes (66 or 130 hex chars) long. For a description of that curve and an example of a hex point, see: https://en.bitcoin.it/wiki/Secp256k1. For a library that allows you to manipulate points, see: https://github.com/indutny/elliptic