Giter Club home page Giter Club logo

key-encoder-js's People

Contributors

dependabot[bot] avatar giovanni9793 avatar kantai avatar shea256 avatar wileyj avatar zone117x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

key-encoder-js's Issues

How to make raw keys

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?

TypeError: KeyEncoder is not a constructor

I'm trying to use the library, but can't even get started due to an error: "TypeError: KeyEncoder is not a constructor"

To reproduce:

  • In a new directory, npm init
  • npm i key-encoder
  • In index.js, add just the two lines from the README:
var KeyEncoder = require('key-encoder'),
    keyEncoder = new KeyEncoder('secp256k1')
  • run "node index.js"

Result:

    keyEncoder = new KeyEncoder('secp256k1')
                 ^

TypeError: KeyEncoder is not a constructor

Expected result: No output.

Cannot convert PEM file to DER by using openssl tool

I'm trying to convert ethereum private key to DER format but get an error. Below are the steps:

First I use web3 to create new ethereum account that has the following key:
private key = 0x45a84f0899393274a9aa0ba3b86277543fc7f3ac508390a3b492fb88ac189dd1

Run key-encoder code:

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

var rawPrivateKey = '0x45a84f0899393274a9aa0ba3b86277543fc7f3ac508390a3b492fb88ac189dd1',

var pemPrivateKey = keyEncoder.encodePrivate(rawPrivateKey, 'raw', 'pem', 'pkcs8') //default is 'pkcs1'

console.log(pemPrivateKey)

It outputs:

-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIEWoTwiZOTJ0qaoLo7hid1Q/x/OsUIOQo7SS+4isGJ3RoAcGBSuBBAAK
oUQDQgAEQ29JqkXW6Bi9Hq1n2frYRNDnt5LUivt6lH36sXh61b4rQADSMvagnjlx
R0zS2n8Ue5t0bm/1W3h63JOCC68N5w==
-----END EC PRIVATE KEY-----

I save it to eth_private.pem file. Then I try to use openssl tool to covnert it to DER with this command:
openssl pkcs8 -inform PEM -outform DER -topk8 -nocrypt -in eth_private.pem -out eth_private.der

It raises this error:

unable to load key
4669285888:error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag:crypto/asn1/tasn_dec.c:1149:
4669285888:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error:crypto/asn1/tasn_dec.c:309:Type=X509_ALGOR
4669285888:error:0D08303A:asn1 encoding routines:asn1_template_noexp_d2i:nested asn1 error:crypto/asn1/tasn_dec.c:646:Field=pkeyalg, Type=PKCS8_PRIV_KEY_INFO
4669285888:error:0907B00D:PEM routines:PEM_read_bio_PrivateKey:ASN1 lib:crypto/pem/pem_pkey.c:88:

I'm not sure if the problem with the private key cause it works when I try the private key in project sample.

How to save & load keypair?

i am creating keyPair using elliptical-secp253k1 like:--
ec.genKeyPair();

When i print keyPair on console it shows -->
<Key priv: c55388432e65ecdf6cd89a11efdcbcdf823764c2b019fe0b99305590ea7352a9 pub: >

Question 1: what type of object is this? (its not a JSON object. converting it to JSON generates a big output.)
Question 2:how to save this pair in database or pem & load it later?

Please help.
Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.