Creates a public/private key pair which can be applied to Identities during creation or when replacing a key. An Identity's keys are used to sign and verify messages.
Note: You do not need to use our SDK utility to create public/private key pairs. Key pairs can also be generated by applying ed25519 algorithm, however a special encoding scheme is used rather than simply the raw 32 byte arrays. For details, please refer to Identity API Documentation here.
Sample
const keyPairObj = factomConnectSDK.utils.generateKeyPair()
Returns
A key pair object with public and private keys.
- privateKey: string
The private key in base58 Idsec format. - publicKey: string
The public key in base58 Idpub format.
{
'privateKey':'idsec2rk3MH1kwZVeKD4Br3UTaU2VHxZF99kdkx27ryAhfMGYBgPgQH',
'publicKey':'idpub2WL2aH5Y2s7atB1LwjEyaKa62pnuJXUaL5kcbahzwahc1Hiba6'
}
Very similar to generateKeyPair()
in that it creates a public/private key pair which can be applied to Identity creation or replacement. However, this method allows you to pass in your own standard ed25519 key, which is converted into a key pair.
Sample
const keyPairObj = factomConnectSDK.utils.convertRawToKeyPair({
rawPrivateKey: 'abcdefghijklmnopqrstuvwxyz123456'
})
Parameters
| |
Returns
A key pair object with public and private keys.
- privateKey: string
The private key in base58 Idsec format. - publicKey: string
The public key in base58 Idpub format.
Response
{
privateKey: 'idseaoBBq4DskQwXGffkKQgYxT7zCuQFAPqVic3ZFayDZThXas1z2jv',
publicKey: 'idpub3g5z2JPJCRqvPB1S4NtD6BWiVhDtV15CxdrgQadX1L9qzYzQKC'
}
This method converts an idpub/idsec key to a raw Uint8Array.
Sample
const keyBytesArray = factomConnectSDK.utils.convertToRaw({
signerKey: 'idsec2ioPQqJvJzzwqskEW67yrWd2GwQMs1oCuLHsLHxejmBbEFpEY8'
})
Parameters
|
Returns
A key bytes array
Response
Uint8Array [
206,
52,
64,
7,
230,
61,
24,
192,
43,
186,
215,
44,
182,
4,
8,
81,
1,
203,
226,
186,
148,
125,
4,
67,
251,
60,
240,
170,
194,
252,
23,
203 ]