Created
January 13, 2020 06:15
-
-
Save laalaguer/1eaea9354eb2deba769a92296814e4f1 to your computer and use it in GitHub Desktop.
How to generate a user signature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import library | |
const cry = require('thor-devkit/dist/cry') | |
const Transaction = require('thor-devkit/dist/transaction').Transaction | |
// User private key. | |
const originPriv = Buffer.from( | |
'2a0cbfe49ea7c18e89b87be4237e1717823fc16b52dc02e91fb30af122fba9b3', | |
'hex' | |
) | |
// User public address: 0x881Ab2380017870C49a9A114806C05F3CFE406e2 | |
const originAddress = cry.publicKeyToAddress(cry.secp256k1.derivePublicKey(originPriv)) | |
// Construct the hash for signing. | |
const originHash = tx.signingHash() | |
// Construct the user signature. | |
const originSignature = cry.secp256k1.sign(originHash, originPriv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment