npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

@burstjs/crypto

0.1.0-rc.3.2 • Public • Published

@burstjs/crypto

Cryptographic functions for building Burstcoin apps.

Installation

Install using npm:

npm install @burstjs/crypto

or using yarn:

yarn add @burstjs/crypto

API Reference

Classes

Converter

A set of useful converter methods for crypto operations.

Functions

decryptAES(encryptedBase64, key)

Decrypt an encrypted message

generateMasterKeys(passPhrase)

Generate the Master Public Key and Master Private Key for a new passphrase

generateSignature(messageHex, privateKey)

Generate a signature for the 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)
generateSignedTransactionBytes(unsignedTransactionHex, signature)

Generates a signed message digest

getAccountIdFromPublicKey(publicKey)

Convert hex string of the public key to the account id

verifySignature(signature, messageHex, publicKey)

Verify a signature for given message

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

Converter

A set of useful converter methods for crypto operations.

Kind: global class

Converter.intToBytes_()

Produces an array of the specified number of bytes to represent the integer value. Default output encodes ints in little endian format. Handles signed as well as unsigned integers. Due to limitations in JavaScript's number format, x cannot be a true 64 bit integer (8 bytes).

Kind: static method of Converter

decryptAES(encryptedBase64, key) ⇒

Decrypt an encrypted message

Kind: global function
Returns:

The decrypted content

Param Description
encryptedBase64

encryprts data in base64 format

key

The secret key

generateMasterKeys(passPhrase) ⇒

Generate the Master Public Key and Master Private Key for a new passphrase

Kind: global function
Returns:

EC-KCDSA sign key pair + agreement key

Param Description
passPhrase

The passphrase

generateSignature(messageHex, privateKey)

Generate a signature for the 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)

Kind: global function

Param Description
messageHex

The data in hexadecimal representation

privateKey

The private key for signing

generateSignedTransactionBytes(unsignedTransactionHex, signature) ⇒

Generates a signed message digest

Kind: global function
Returns:

The signed message digest

Param Description
unsignedTransactionHex

The unsigned message

signature

The signature

getAccountIdFromPublicKey(publicKey) ⇒

Convert hex string of the public key to the account id

Kind: global function
Returns:

The numeric account Id

Param Description
publicKey

The public key

verifySignature(signature, messageHex, publicKey)

Verify a signature for given message

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

Kind: global function

Param Description
signature

The signature to be verified

messageHex

The message data in hexadecimal representation

publicKey

The public key

Keywords

none

install

npm i @burstjs/crypto

Downloadsweekly downloads

304

version

0.1.0-rc.3.2

license

GPL-3.0

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability