Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "core/crypto/Utilities"

Index

Variables

Const CryptoJS

CryptoJS: any = require('crypto-js')

Const Half_Hash_Size

Half_Hash_Size: number = Hash_Size / 2

Const Half_Signature_Size

Half_Signature_Size: number = Signature_Size / 2

Const Hash_Size

Hash_Size: 64 = 64

Const Key_Size

Key_Size: 32 = 32

Const Signature_Size

Signature_Size: 64 = 64

Const catapult_crypto

catapult_crypto: { deriveSharedKey: any; deriveSharedSecret: any } = (() => {function clamp(d) {d[0] &= 248;d[31] &= 127;d[31] |= 64;}function prepareForScalarMult(sk) {const d = new Uint8Array(64);const hash = sha512.arrayBuffer(sk);array.copy(d, array.uint8View(hash), 32);clamp(d);return d;}return {deriveSharedKey: (privateKey: Uint8Array, publicKey: Uint8Array): Uint8Array => {const sharedSecret = catapult_crypto.deriveSharedSecret(privateKey, publicKey);const info = 'catapult';const hash = 'SHA-256';return hkdf(sharedSecret, 32, { salt: new Uint8Array(32), info, hash });},deriveSharedSecret: (privateKey: Uint8Array, publicKey: Uint8Array): Uint8Array => {const c = nacl;const d = prepareForScalarMult(privateKey);// sharedKey = pack(p = d (derived from privateKey) * q (derived from publicKey))const q = [c.gf(), c.gf(), c.gf(), c.gf()];const p = [c.gf(), c.gf(), c.gf(), c.gf()];const sharedSecret = new Uint8Array(Key_Size);c.unpack(q, publicKey);c.scalarmult(p, q, d);c.pack(sharedSecret, p);return sharedSecret;},};})()

Type declaration

  • deriveSharedKey: function
    • deriveSharedKey(privateKey: Uint8Array, publicKey: Uint8Array): Uint8Array
  • deriveSharedSecret: function
    • deriveSharedSecret(privateKey: Uint8Array, publicKey: Uint8Array): Uint8Array

Const hkdf

hkdf: any = require('futoin-hkdf')

Functions

Const ua2words

  • ua2words(ua: any, uaLength: any): any
  • Convert an Uint8Array to WordArray

    Parameters

    • ua: any

      An Uint8Array

    • uaLength: any

      The Uint8Array length

    Returns any

Const words2ua

  • words2ua(destUa: any, cryptoWords: any): any
  • Convert a wordArray to Uint8Array

    Parameters

    • destUa: any

      A destination Uint8Array

    • cryptoWords: any

      A wordArray

    Returns any

Generated using TypeDoc