Skip to content

Latest commit

 

History

History
689 lines (412 loc) · 21.9 KB

doc.md

File metadata and controls

689 lines (412 loc) · 21.9 KB

Table of Contents

server

src/server/index.js:6-6

Module containing functions about Factom server identities.

FactomServerIdentityManager

src/server/factom-server-identity-manager.js:27-95

Main class to read and write Factom identities.

Parameters

Examples

const manager = new FactomServerIdentityManager({
     factomd: {
         host: 'api.factomd.net',
         port: 443,
         protocol: 'https'
     },
     walletd: {
         host: 'localhost',
         user: 'paul',
         password: 'pass'
     }
});

addCoinbaseCancel

src/server/factom-server-identity-manager.js:85-94

Add a coinbase cancel message to a server identity.

Parameters
  • rootChainId string Identity Root Chain Id.
  • descriptorHeight number Coinbase descriptor block height.
  • descriptorIndex number Coinbase descriptor index.
  • sk1 string Server identity Secret Key 1.
  • ecAddress string Entry Credit address paying for the entry.

Returns {txId: string, repeatedCommit: boolean, chainId: string, entryHash: string} Info about the Entry insertion.

getServerIdentity

src/server/factom-server-identity-manager.js:38-40

Get a server identity information.

Parameters
  • rootChainId string Identity Root Chain Id.

Returns {rootChainId: string, serverManagementSubchainId: string, coinbaseAddress: string, efficiency: number, identityKeys: Array<string>}

getServerIdentityHistory

src/server/factom-server-identity-manager.js:48-50

Get a server identity information history.

Parameters
  • rootChainId string Identity Root Chain Id.

Returns {rootChainId: string, serverManagementSubchainId: string, coinbaseAddressHistory: Array<Object>, efficiencyHistory: Array<Object>, identityKeys: Array<string>}

updateCoinbaseAddress

src/server/factom-server-identity-manager.js:60-62

Update the coinbase address of a server identity.

Parameters
  • rootChainId string Identity Root Chain Id.
  • fctAddress string Public Factoid address to set as coinbase address.
  • sk1 string Server identity Secret Key 1.
  • ecAddress string Entry Credit address paying for the entry.

Returns {txId: string, repeatedCommit: boolean, chainId: string, entryHash: string} Info about the Entry insertion.

updateEfficiency

src/server/factom-server-identity-manager.js:72-74

Update the efficiency of a server identity.

Parameters
  • rootChainId string Identity Root Chain Id.
  • efficiency number Efficiency between 0 and 100.
  • sk1 string Server identity Secret Key 1.
  • ecAddress string Entry Credit address paying for the entry.

Returns {txId: string, repeatedCommit: boolean, chainId: string, entryHash: string} Info about the Entry insertion.

generateCoinbaseAddressUpdateEntry

src/server/coinbase-address.js:115-127

Generate Entry object to update a server identity coinbase address.

Parameters

  • rootChainId string Identity Root Chain Id.
  • fctAddress string Public Factoid address to set as the new coinbase address.
  • sk1 string Server identity Secret Key 1.

generateCoinbaseCancelEntry

src/server/coinbase-cancel.js:54-100

Parameters

  • rootChainId string Identity Root Chain Id.
  • serverManagementSubchainId string Server Management Subchain Id.
  • height number Block height of the coinbase descriptor to cancel.
  • index number Index of the coinbase descriptor to cancel.
  • sk1 string Server identity Secret Key 1.

generateEfficiencyUpdateEntry

src/server/efficiency.js:105-125

Generate Entry object to update a server identity efficiency.

Parameters

  • rootChainId string Identity Root Chain Id.
  • serverManagementSubchainId string Server Management Subchain Id.
  • efficiency number Efficiency between 0 and 100.
  • sk1 string Server identity Secret Key 1.

Returns {chainId: Buffer, extIds: Array<Buffer>, content: Buffer}

app

src/app/index.js:5-5

Module containing functions about Factom identities for applications.

FactomIdentityManager

src/app/factom-identity-manager.js:29-112

Main class to read and write Factom identities.

Parameters

Examples

const manager = new FactomIdentityManager({
     factomd: {
         host: 'api.factomd.net',
         port: 443,
         protocol: 'https'
     },
     walletd: {
         host: 'localhost',
         user: 'paul',
         password: 'pass'
     }
});

createIdentity

src/app/factom-identity-manager.js:87-89

Create a new identity on-chain.

Parameters
  • name Array<string> Array of strings used as the "name" of the identity.
  • keys (Array<string> | number) Either an array of public identity keys or a number. If a number is provided the library generate new random keys (the secret keys are part of the returned object).
  • ecAddress string Entry Credit address paying for the entry. If a public EC address is provided the library attempts to retrieve the secret part from the configured walletd instance.

Returns Array<{identityKeys: {public: string, secret: string}, txId: string, repeatedCommit: boolean, chainId: string, entryHash: string}> Info about the Chain creation together with the list of identity keys associated with the new identity.

getActivePublicIdentityKeys

src/app/factom-identity-manager.js:43-45

Get all the active public identity keys of an identity at a given blockchain height. If no block height is specified, check for the latest block height.

Parameters
  • identityChainId string Identity chain id.
  • blockHeight number? Specific blockchain height. If not provided check for the latest block.

Returns Array<string> Array of public identity keys active for the identity.

getIdentityName

src/app/factom-identity-manager.js:52-54

Retrieve the identity "name" that was set at the creation of the identity chain.

Parameters
  • identityChainId string Identity chain id.

Returns Array<Buffer> Array of Buffer representing the name of the identity.

isIdentityKeyActive

src/app/factom-identity-manager.js:65-74

Check if an identity key is (was) active for an identity at a given blockchain height. If no block height is specified, check for the latest block height.

Parameters
  • identityChainId string Identity chain id.
  • idKey string Public or private identity key.
  • blockHeight number? Specific blockchain height. If not provided check for the latest block.

Returns boolean True if the identity key is active for the identity.

replaceIdentityKey

src/app/factom-identity-manager.js:103-111

Replace an identity key by another on-chain.

Parameters
  • identityChainId string Identity chain id.
  • keys Object
    • keys.oldIdKey string Old public identity key to replace.
    • keys.newIdKey string New public identity key to take the place of oldIdKey.
    • keys.signingSecretIdKey string Secret identity key signing for the replacement. Must be of same or higher priority than oldIdKey.
  • ecAddress string Entry Credit address paying for the entry. If a public EC address is provided the library attempts to retrieve the secret part from the configured walletd instance.

Returns {txId: string, repeatedCommit: boolean, chainId: string, entryHash: string} Info about the Entry insertion.

extractCryptoMaterial

src/app/key-helpers.js:68-73

Extract the ed25519 cryptographic material encapsulated in the identity key.

Parameters

  • idKey string Public or secret identity key.

Returns Buffer Either the ed25519 32-byte public key or the 32-byte secret seed.

FactomWalletdKeyStore

src/app/walletd-key-store.js:19-123

Helper class to user factom-walletd as a key store.

Parameters

Examples

const store = new FactomWalletdKeyStore({
         host: 'localhost',
         user: 'paul',
         password: 'pass'
});

generateIdentityKey

src/app/walletd-key-store.js:110-122

Generates a new identity key from the wallet seed and stores it into walletd. New keys are generated from the same mnemonic seed used for FCT and EC addresses.

Parameters
  • number number Number of identity keys to generate. (optional, default 1)

Returns {public: string, secret: string}

getAllIdentityKeys

src/app/walletd-key-store.js:98-101

Get all identity keys stored in walletd.

Returns Array<{public: string, secret: string}>

getSecretIdentityKey

src/app/walletd-key-store.js:30-40

Fetch corresponding identity key from the wallet if necessary.

Parameters

Returns string Corresponsing secret identity key.

importIdentityKeys

src/app/walletd-key-store.js:48-64

Import keys in walletd.

Parameters
  • secretIdKeys (string | Array<string>) A single secret key or an array of secret keys to import.

Returns Array<{public: string, secret: string}>

removeIdentityKeys

src/app/walletd-key-store.js:70-91

Remove from walletd some identity keys.

Parameters

generateRandomIdentityKeyPair

src/app/key-helpers.js:129-136

Generate a random identity key pair.

Returns {public: string, secret: string} Random identity key pair.

getPublicIdentityKey

src/app/key-helpers.js:81-91

Get the public identity key corresponding to the input identity key.

Parameters

  • idKey string Secret (or public) identity key.

Returns string Corresponding public identity key.

isValidIdentityKey

src/app/key-helpers.js:16-40

Check if an identity key is well formed.

Parameters

  • idKey string Public or secret identity key.

Returns boolean True if the identity key is valid.

isValidPublicIdentityKey

src/app/key-helpers.js:48-50

Check if a public identity key is well formed.

Parameters

  • pubIdKey string Public identity key.

Returns boolean True if the public identity key is valid.

isValidSecretIdentityKey

src/app/key-helpers.js:58-60

Check if a secret identity key is well formed.

Parameters

  • secIdKey string Public identity key.

Returns boolean True if the secret identity key is valid.

keyToPublicIdentityKey

src/app/key-helpers.js:99-101

Convert a 32-byte key to a public identity key.

Parameters

Returns string Public identity key.

seedToSecretIdentityKey

src/app/key-helpers.js:109-111

Convert a 32-byte seed to a secret identity key.

Parameters

Returns string Secret identity key.