title: Using HyperLedger Fabric certificates for signing a message
body: <p>We have generated public and private keys in Hyperledger Fabric using its API which are getting stored in crypto_material folder.</p>
  <p>Now, on one machine we want to sign a message using private key and verify its validity on second machine using corresponding public key. To achieve this task we have written code as follows.</p>
  <pre><code>var crypto = require(&quot;crypto&quot;);
  var secp256k1 = require(&quot;secp256k1&quot;);
  var fs = require(&quot;fs&quot;);
  var sha256 = require('sha256')
  
  let pub_key_file = &quot;./keyfiles/4d4a0d669d507ff05c73c9e1ca40fb5f909f9806df138a82767a739e9de31240-pub&quot;
  fs.access(pub_key_file, fs.F_OK, (err) =&gt; {
    if (err) {
      console.log(&quot;readfile error : &quot;, err);
      return;
    }
  })
  
  var public_key = fs.readFileSync(pub_key_file);
  
  // Reading private key from file system.
  let priv_key_file = &quot;./keyfiles/4d4a0d669d507ff05c73c9e1ca40fb5f909f9806df138a82767a739e9de31240-priv&quot;
  fs.access(priv_key_file, fs.F_OK, (err) =&gt; {
    if (err) {
      console.log(&quot;readfile error : &quot;, err);
      return;
    }
  })
  
  var private_key = fs.readFileSync(priv_key_file);
  
  var privKey = new Uint8Array(sha256(private_Key).match(/.{1,2}/g).map(byte =&gt; parseInt(byte, 16)));
  var pubKey = new Uint8Array(sha256(public_Key).match(/.{1,2}/g).map(byte =&gt; parseInt(byte, 16)));
  
  console.log(pubKey instanceof Uint8Array)  //returning true here
  console.log(&quot;value : &quot;, secp256k1.privateKeyVerify(privKey)); //returning true here
  console.log(&quot;value : &quot;, secp256k1.publicKeyVerify(pubKey)); // Getting error like expected public key to be an Uint8Array with length [33, 65] hyperledger fabric
  </code></pre>
  <p>Why the secp256k1 module is successfully verifying privateKey but failing with publicKey.</p>