I am having a blockchain application set up with Hyperledger Fabric and I want to get the public key from the caller inside the chaincode.
I use golang for the chaincode and I have managed to retrieve from the caller the certificate X509 and from that, the PublicKey in an unreadable format.
Since in the documentation says that this field (Public Key) from the Certificate structure is of type any, I am just setting it into a string using Sprintf.
And this is the output:
&{{0xc000624040} 110006408051620173868267843413892792474981993401645508314118747530986647833211 30374913908846219606392346947456049633394351895879251216926799242930673498259}
I can understand that this might be the encoding of the ECDSA signature and that this might be the actual public key. But, I am not able to clearly understand what does this exactly represent and how can I convert into a hash.
If I hash it directly, the Public Key that I have retrieved from the node js application where I used KEYUTIL to parse it from the users certificate, is different than the result that is being produced here. Why is this happening? What should be hashed in order to be the same?
Any recommendations to read something or any tip would be helpful. Thank you.
After, discussion on the comments bellow, it has been found how to properly format the Public Key so all values of the ECDSA key can be visible.
Using the KEYUTIL library in the node js there is the function of 'getKey' which retrieves the Public Key of the user and in there, there is a field called: pubkeyHex
This is stated:
@param pubkeyHex hexadecimal string of public key
for that.
And what is is beeing displayed is: 04f3356ba599db0542d0cd5beeb6ac844aa1d194f787a9d9b1dbee3f034215ca7b4327 978ef9122386f73280c1dd7865eb2d1d7b27dcff6c23f20423ea81c13893
I thought that this is a hash as this looks like it. But, from the name of the function might be something else (hex).
So, the above is the representation of the whole Public Key in this format. And here comes the next question on how this might be produced.