Class KeyPair

Ed25519 key pair to sign Bamboo entries with.

Example

import { KeyPair } from 'p2panda-js';

const keyPair = new KeyPair();
console.log(keyPair.publicKey());

Hierarchy

  • KeyPair

Constructors

Methods

Constructors

  • Creates a new instance of KeyPair.

    When no privateKey value is passed, the constructor generates a new Ed25519 key pair using the systems random number generator (CSPRNG) as a seed.

    Warning: Depending on the context this does not guarantee the random number generator to be cryptographically secure (eg. broken / hijacked browser or system implementations), so make sure to only run this in trusted environments.

    Returns

    KeyPair instance

    Example

    import { KeyPair } from 'p2panda-js';

    const keyPair = new KeyPair('1f9e81007da0c007314a151be11be392de4cdc76888fbc5a8c62aa03c6730c6a');

    Parameters

    • Optional privateKey: string

      Hexadecimal encoded private key. Warning: Absolutely no validation is done on the key. If you give this function bytes which do not represent a valid point, or which do not represent corresponding parts of the key, then your KeyPair will be broken and it will be your fault.

    Returns KeyPair

Methods

  • Returns public key as a hexadecimal string.

    Returns

    Hexadecimal encoded public key

    Returns string

  • Returns private key as a hexadecimal string.

    Returns

    Hexadecimal encoded private key.

    Returns string

  • Signs any data using this key pair and returns signature.

    Returns

    Hexadecimal encoded signature

    Parameters

    • bytes: string

      Any byte sequence encoded as a hexadecimal string

    Returns string

Generated using TypeDoc