Options
All
  • Public
  • Public/Protected
  • All
Menu

External module crypto

This package contains all cryptographic functions needed for Burstcoin.

Index

Functions

Const decryptAES

  • decryptAES(encryptedBase64: string, key: string): string
  • Decrypt an encrypted message

    see

    encryptAES

    Parameters

    • encryptedBase64: string

      encrypted data in base64 format

    • key: string

      The secret key

    Returns string

    The decrypted content, or undefined if failed

decryptData

  • decryptData(encryptedData: EncryptedData, senderPublicKeyHex: string, recipientPrivateKeyHex: string): Uint8Array
  • Decrypts an encrypted cipher text

    Parameters

    • encryptedData: EncryptedData

      The encrypted data

    • senderPublicKeyHex: string

      The senders public key in hex format

    • recipientPrivateKeyHex: string

      The recipients private (agreement) key in hex format

    Returns Uint8Array

    The original plain text

decryptMessage

  • decryptMessage(encryptedMessage: EncryptedMessage, senderPublicKeyHex: string, recipientPrivateKeyHex: string): string
  • Decrypts an encrypted Message

    Parameters

    • encryptedMessage: EncryptedMessage

      The encrypted message

    • senderPublicKeyHex: string

      The senders public key in hex format

    • recipientPrivateKeyHex: string

      The recipients private (agreement) key in hex format

    Returns string

    The original message

Const encryptAES

  • encryptAES(text: string, key: string): string
  • Symmetrically encrypts a text using an arbitrary key

    see

    decryptAES

    Parameters

    • text: string

      The message/text to be encrypted

    • key: string

      The key used

    Returns string

    The encrypted message as Base64 string

encryptData

  • encryptData(plaintext: Uint8Array, recipientPublicKeyHex: string, senderPrivateKeyHex: string): EncryptedData
  • Encrypts arbitrary data for P2P message/data exchange using asymmetric encryption

    see

    decryptData

    Parameters

    • plaintext: Uint8Array

      Data to be encrypted

    • recipientPublicKeyHex: string

      The recipients public key in hexadecimal format

    • senderPrivateKeyHex: string

      The senders private (agreement) key hexadecimal format

    Returns EncryptedData

    The encrypted Data

encryptMessage

  • encryptMessage(plaintext: string, recipientPublicKeyHex: string, senderPrivateKeyHex: string): EncryptedMessage
  • Encrypts arbitrary message (UTF-8 compatible) for P2P message/data exchange using asymmetric encryption

    see

    decryptMessage

    Parameters

    • plaintext: string

      Message to be encrypted

    • recipientPublicKeyHex: string

      The recipients public key hexadecimal format

    • senderPrivateKeyHex: string

      The senders private (agreement) key hexadecimal format

    Returns EncryptedMessage

    The encrypted Message

Const generateMasterKeys

  • generateMasterKeys(passPhrase: string): Keys

Const generateSignature

  • generateSignature(messageHex: string, privateKey: string): string
  • Generate a signature for a transaction

    Method:

     s = sign(sha256(sha256(transactionHex)_keygen(sha256(sha256(transactionHex)_privateKey)).publicKey),
             sha256(sha256(transactionHex)_privateKey),
             privateKey)
     p = sha256(sha256(transactionHex)_keygen(sha256(transactionHex_privateKey)).publicKey)

    Parameters

    • messageHex: string

      The data in hexadecimal representation

    • privateKey: string

      The private key for signing

    Returns string

    The signature in hexadecimal format

Const generateSignedTransactionBytes

  • generateSignedTransactionBytes(unsignedTransactionHex: string, signature: string): string

Const getAccountIdFromPublicKey

  • getAccountIdFromPublicKey(publicKey: string): string

Const hashSHA256

  • hashSHA256(input: string): string

Const verifySignature

  • verifySignature(signature: string, messageHex: string, publicKey: string): boolean
  • Verify a signature for given message

    • Method:
      * h1 = sha256(sha256(transactionHex)_keygen(sha256(transactionHex_privateKey)).publicKey)
      ==
      sha256(sha256(transactionHex)_verify(v, h1, publickey)) = h2
    see

    generateSignature

    Parameters

    • signature: string

      The signature to be verified

    • messageHex: string

      The message data in hexadecimal representation

    • publicKey: string

      The public key

    Returns boolean

    true, if signature is valid, otherwise false