0

By using Hyperledger fabric 1.4 SDK I have created one user, a set of public and private key is generated for that user. Now I want to use this key pair for encrypting and decrypting the data.

I aware hyperledger uses elliptic curve cryptography for signing the data, but I don't know in background how they are signing the data. I tried several method in nodejs but didn't get success.

following are my keys generated while registering the user

public key:
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEBWLnhsBfNE+hF1uDuDb/Z87KAPvF
6RCQLtgZIxdU4x5qcTdEWQPOfF2fUSrecmHAfgMW1cMiun0B9KAaMY7dFg==
-----END PUBLIC KEY-----

private key:
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgmQndljBNeyPyvEDM
lPtXtibQ8yYwK05RfLhkl/sCJ5WhRANCAAQFYueGwF80T6EXW4O4Nv9nzsoA+8Xp
EJAu2BkjF1TjHmpxN0RZA858XZ9RKt5yYcB+AxbVwyK6fQH0oBoxjt0W
-----END PRIVATE KEY-----

by using following method I'm able to sign by using public key but for verifying I'm getting Unknown point format error

var EC = require("elliptic").ec;
var ec = new EC("secp256k1");
var mySign = ec.sign(msg, public_key);
var res = ec.verify(private_key, msg, mySign)

Can any one suggest the suitable method for signing the data by using hyperledger key pair.

chitresh
  • 316
  • 4
  • 11
  • could you give me public_key, private_key? using console.log. I am curious if you match the type correctly. – myeongkil kim Jan 12 '21 at 10:02
  • these are my keys: private key : public key : – chitresh Jan 13 '21 at 03:49
  • When referring to the ec library, the input parameter seems to be the hex string, not the buffer type. I am curious to see if the type of the function input parameter is properly matched. See link [elliptic](https://github.com/indutny/elliptic/tree/e71b2d9359c5fe9437fbf46f1f05096de447de57) – myeongkil kim Jan 13 '21 at 06:55
  • Yes in ec library the key pair are in hex string and I tried to convert it as a hex string by using .toString('hex') method and got the same response – chitresh Jan 13 '21 at 07:22
  • I also tried [this example](https://gist.github.com/nakov/1dcbe26988e18f7a4d013b65d8803ffc) by using **keyFromPrivate()** and **getPublic()** method i'm getting the hex key and signing and verify is working fine but in this case I'm ignoring the existing keys, I have to use existing keys for the operation. – chitresh Jan 13 '21 at 07:33

0 Answers0