This package has been deprecated

Author message:

Burstcoin has been rebranded to Signum. This package has been moved to @signumjs/crypto

@burstjs/crypto
TypeScript icon, indicating that this package has built-in type declarations

0.6.0-beta.6 • Public • Published

@burstjs/crypto

Cryptographic functions for building Burstcoin apps.

Installation

burstJS can be used with NodeJS or Web. Two formats are available

Using with NodeJS and/or modern web frameworks

Install using npm:

npm install @burstjs/crypto

or using yarn:

yarn add @burstjs/crypto

Example

import {encryptAES, decryptAES, hashSHA256} from '@burstjs/crypto'

const encrypted = encryptAES('test', 'key')
const decrypted = decryptAES(encrypted, 'key')
console.log(hashSHA256('test'))
console.log(decrypted)

Using in classic <script>

Each package is available as bundled standalone library using IIFE. This way burstJS can be used also within <script>-Tags. This might be useful for Wordpress and/or other PHP applications.

Just import the package using the HTML <script> tag.

<script src='https://cdn.jsdelivr.net/npm/@burstjs/crypto/dist/burstjs.crypto.min.js'></script>

Example

const encrypted = b$crypto.encryptAES("test", "key");
const decrypted = b$crypto.decryptAES(encrypted, "key");
console.log(b$crypto.hashSHA256("test"));
console.log(decrypted);

See more here:

@burstjs/crypto Online Documentation


API Reference

Modules

crypto

Decrypt an encrypted message

crypto

Decrypts an encrypted cipher text

crypto

Decrypts an encrypted Message

crypto

Symmetrically encrypts a text using an arbitrary key

crypto

Encrypts arbitrary data for P2P message/data exchange using asymmetric encryption

crypto

Encrypts arbitrary message (UTF-8 compatible) for P2P message/data exchange using asymmetric encryption

crypto

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

crypto

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)
crypto

Generates a signed message digest, which can be sent to BRS API then

crypto

Convert hex string of the public key to the account id

crypto
crypto

Hash string into hex string

crypto

A secure random passphrase generator

crypto

Verify a signature for given message

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

Classes

Converter

A set of useful converter methods for crypto operations.

Constants

IV_LENGTH

Original work Copyright (c) 2018 PoC-Consortium Modified work Copyright (c) 2019 Burst Apps Team

IV_LENGTH

Original work Copyright (c) 2018 PoC-Consortium Modified work Copyright (c) 2019 Burst Apps Team

crypto ⇒

Decrypt an encrypted message

Returns:

The decrypted content


See:

[[encryptAES]]

Param Description
encryptedBase64

encrypted data in base64 format

key

The secret key

crypto ⇒

Decrypts an encrypted cipher text

Returns:

The original plain text

Param Description
encryptedData

The encrypted data

senderPublicKeyHex

The senders public key in hex format

recipientPrivateKeyHex

The recipients private (agreement) key in hex format

crypto ⇒

Decrypts an encrypted Message

Returns:

The original message

Param Description
encryptedMessage

The encrypted message

senderPublicKeyHex

The senders public key in hex format

recipientPrivateKeyHex

The recipients private (agreement) key in hex format

crypto ⇒

Symmetrically encrypts a text using an arbitrary key

Returns:

The encrypted message as Base64 string


See:

[[decryptAES]]

Param Description
text

The message/text to be encrypted

key

The key used

crypto ⇒

Encrypts arbitrary data for P2P message/data exchange using asymmetric encryption

Returns:

The encrypted Data


See:

[[decryptData]]

Param Description
plaintext

Data to be encrypted

recipientPublicKeyHex

The recipients public key in hexadecimal format

senderPrivateKeyHex

The senders private (agreement) key hexadecimal format

crypto ⇒

Encrypts arbitrary message (UTF-8 compatible) for P2P message/data exchange using asymmetric encryption

Returns:

The encrypted Message


See:

[[decryptMessage]]

Param Description
plaintext

Message to be encrypted

recipientPublicKeyHex

The recipients public key hexadecimal format

senderPrivateKeyHex

The senders private (agreement) key hexadecimal format

crypto ⇒

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

Returns:

EC-KCDSA sign key pair + agreement key

Param Description
passPhrase

The passphrase

crypto ⇒

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)

Returns:

The signature in hexadecimal format

Param Description
messageHex

The data in hexadecimal representation

privateKey

The private key for signing

crypto ⇒

Generates a signed message digest, which can be sent to BRS API then

Returns:

The signed message digest

Param Description
unsignedTransactionHex

The unsigned message

signature

The signature

crypto ⇒

Convert hex string of the public key to the account id

Returns:

The numeric account Id

Param Description
publicKey

The public key

crypto ⇒

Returns:

A decimal string


Internal: Arbitrary length hexadecimal to decimal conversion https://stackoverflow.com/questions/21667377/javascript-hexadecimal-string-to-decimal-string
Param Description
s

A hexadecimal string

crypto ⇒

Hash string into hex string

Returns:

the hash for that string in hex format

Param Description
input

An arbitrary text

crypto

A secure random passphrase generator

Note: For secure randomization seedrandom is used.

crypto ⇒

Verify a signature for given message

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

Returns:

true, if signature is valid, otherwise false


See:

[[generateSignature]]

Param Description
signature

The signature to be verified

messageHex

The message data in hexadecimal representation

publicKey

The public key

crypto

Converter

A set of useful converter methods for crypto operations.

Kind: global class

IV_LENGTH

Original work Copyright (c) 2018 PoC-Consortium Modified work Copyright (c) 2019 Burst Apps Team

Kind: global constant

IV_LENGTH

Original work Copyright (c) 2018 PoC-Consortium Modified work Copyright (c) 2019 Burst Apps Team

Kind: global constant

Dependencies (7)

Dev Dependencies (4)

Package Sidebar

Install

npm i @burstjs/crypto

Weekly Downloads

2

Version

0.6.0-beta.6

License

Apache-2.0

Unpacked Size

1.71 MB

Total Files

119

Last publish

Collaborators

  • blankey1337
  • ohager