@kadena/cryptography-utils
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published

@kadena/cryptography-utils

Collection of Kadena cryptography utility functions

kadena.js logo

Cryptography Utils

Cryptography-Utils is a collection of cryptography utility functions. This library is used by kadena.js to hash your transactions. If you have private keys available, you can also sign them with this library.

API Reference can be found here cryptography-utils.api.md

Usage Examples

import { hash, sign } from '@kadena/cryptography-utils';
import { IKeyPair } from '@kadena/types';

// Create a command
let commandPayload: string = 'Hello world!';

// Get the has of the command
let h: string = hash(commandPayload);

// Signing is normally handled by wallets, but if you have the private key
// available to you, you can also sign in this way:
let keyPair: IKeyPair = {
  publicKey: 'ba54b224d1924dd98403f5c751abdd10de6cd81b0121800bf7bdbdcfaec7388d',
  secretKey: '8693e641ae2bbe9ea802c736f42027b03f86afe63cae315e7169c9c496c17332',
};

let sig: string = sign(commandPayload, keyPair);

Available Functions

crypto:

  • binToHex
  • hexToBin
  • base64UrlEncode
  • base64UrlDecode
  • base64UrlEncodeArr
  • base64UrlDecodeArr
  • strToUint8Array
  • uint8ArrayToStr
  • hash
  • hashBin
  • genKeyPair
  • restoreKeyPairFromSecretKey
  • sign
  • signHash
  • verifySig
  • unique
  • toTweetNaclSecretKey

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.4.2
    292
    • latest

Version History

Package Sidebar

Install

npm i @kadena/cryptography-utils

Weekly Downloads

356

Version

0.4.2

License

ISC

Unpacked Size

115 kB

Total Files

157

Last publish

Collaborators

  • kadena-lars
  • alber70g
  • takadenoshi
  • ash_vd
  • randynamic
  • buckie
  • heekyun