A Keypair is an object that can group relevant keys for a user in the webb system. The keys managed by a keypair are as follows:

  • pubkey: Required
    • used in commitments of circuits, to indicate ownership of a UTXO. The value can be derived from pubkey = poseidon(privkey)
  • encryptionKey: Optional
    • used to encrypting data for private communication. It is a pubkey of the privkey in a different cryptography scheme.
  • privkey: Optional
    • used for proving knowledge of a value and thus ability to spend UTXOs (creating nullifier).
    • used for decrypting data that has been encrypted with the encryptionKey.

Hierarchy

  • Keypair

Constructors

  • Initialize a new keypair from a passed hex string. Generates a random private key if not defined.

    Returns

    • A 'Keypair' object with pubkey and encryptionKey values derived from the private key.

    Parameters

    • privkey: string = ...

      hex string of a field element for the

    Returns Keypair

Properties

encryptionKey: undefined | string
privkey: undefined | string
pubkey: BigNumber = ...

Methods

  • Decrypt data using keypair private key

    Returns

    A Buffer of the decrypted data

    Parameters

    • data: string

      a hex string with data

    Returns Buffer

  • Encrypt data using keypair encryption key

    Returns

    a hex string encoding of encrypted data with this encryption key

    Parameters

    • bytes: Buffer

      A buffer to encrypt

    Returns string

  • Returns

    a 0x-prefixed, 32 fixed byte hex-string representation of the encryption key

    Returns undefined | string

  • Returns

    a 0x-prefixed, 32 fixed byte hex-string representation of the public key

    Returns string

  • Returns

    a string of public parts of this keypair object: pubkey and encryption key.

    Returns string

  • Parameters

    • encryptionKey: string
    • data: string

    Returns string

  • Initialize new keypair from string data.

    Returns

    The keypair object configured with appropriate public values.

    Throws

    If the string object is not 66 chars or 130 chars.

    Parameters

    • str: string

      A string which contains public keydata. (0, 66), the slice for the pubKey value, 0x-prefixed, which is required. (66, 130), the slice for the encryptionKey value, which is optional to enable encrypt and decrypt functionality. It should be hex encoded.

    Returns Keypair

Generated using TypeDoc