Function from

  • Creates a WritableName from an existing signing key (private key).

    Expects the given Uint8Array to contain a binary representation of a private signing key. Note that this is not the same as the output of Name.bytes, which always returns an encoding of the public key, even when the name in question is a WritableName.

    To save the key for a WritableName so that it can be used with this function, use key.bytes, for example:

    Example

    import * as Name from 'w3name'
    import fs from 'fs'

    async function example() {
    const myName = await Name.create()

    // myName.key.bytes can now be written to disk / database, etc.
    await fs.promises.writeFile('myName.key', myName.key.bytes)

    // let's pretend some time has passed and we want to load the
    // key from disk:
    const loadedBytes = await fs.promises.readFile('myName.key')
    const myName2 = await Name.from(loadedBytes)

    // myName and myName2 can now be used interchangeably
    }

    Parameters

    • key: Uint8Array

    Returns Promise<WritableName>

Generated using TypeDoc