DWQA QuestionsCategory: BlockchainIn Huawei cloud block chain application development, how to use Node.js to complete the message body signature of its REST API chain code call request?
stxxhwf asked 2 years ago

In Huawei Cloud Block Chain Service API Reference Document, Huawei Cloud has the following description for the message header requesting its REST API service:

X-bcs-signature-sign: In order to ensure that only authorized callers can make legal chain code calls, it is necessary to use the user private key downloaded from the download user certificate chapter to encrypt and sign the SHA256 digest of the whole request message body in the way of ECDSA elliptic curve encryption. The value of x-bcs-signature-sign is the result of the signature.

At the same time, Huawei cloud provides an example of using Go language. But I hope to use Node. JS to complete this process. It is very simple to abstract the request message body from SHA256, but how to use the user’s private key to encrypt the signature with ECDSA elliptic curve is difficult for me. The user private key provided by Huawei Cloud is similar to the following format:

—–BEGIN PRIVATE KEY—–
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgpCc4N3LiESy7UjPN
lL56fjWSBTL251fNNbcfq+T0RdahRANCAAQ0OtXGMFtVUiLtADfnfp3AVTYLrsVV
fZFDy+V7zcI30Mdo86JquXuAr0toDnSRbGutiVhnU+pLOGTAO7o9PfaC
—–END PRIVATE KEY—–

Xiao Baigang has just touched the block chain. I hope Dashen can point out the labyrinth.
Attachment: Huawei Cloud Block Chain Service API Reference
https://support.huaweicloud.c…
Huawei Cloud REST API example:
https://support.huaweicloud.c…