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

Properties

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.

    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

    KeyPair instance

    Example

    import { KeyPair } from 'p2panda-js';

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

Properties

__internal: KeyPair$1

Methods

  • Returns public key as a hexadecimal string.

    Returns string

    Hexadecimal encoded public key

  • Returns private key as a hexadecimal string.

    Returns string

    Hexadecimal encoded private key.

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

    Parameters

    • bytes: string

      Any byte sequence encoded as a hexadecimal string

    Returns string

    Hexadecimal encoded signature

Generated using TypeDoc