Skip to content

Latest commit

 

History

History
131 lines (109 loc) · 5.05 KB

File metadata and controls

131 lines (109 loc) · 5.05 KB

utils

Table of Contents

generateKeyPair

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'
}

convertRawToKeyPair

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

Name Type Description SDK Error Message & Description
params.rawPrivateKey string
Required
The ed25519 key to be converted provided ed25519 private key is invalid
The rawPrivateKey parameter is not a properly ed25519 key.

| |

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'
}

convertToRaw

This method converts an idpub/idsec key to a raw Uint8Array.

Sample

const keyBytesArray = factomConnectSDK.utils.convertToRaw({
  signerKey: 'idsec2ioPQqJvJzzwqskEW67yrWd2GwQMs1oCuLHsLHxejmBbEFpEY8'
})

Parameters

Name Type Description SDK Error Message & Description
params.signerKey string
Required
The idsec/idpub key to be converted key is invalid
The provided value for the key is not a properly formatted idsec or idpub key.

|

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 ]