Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "core/crypto/Utilities"

Index

Variables

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: any = ((): any => {function clamp(d): void {d[0] &= 248;d[31] &= 127;d[31] |= 64;}function prepareForScalarMult(sk): Uint8Array {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: Buffer.from(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;},};})()

Functions

Const ua2words

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

    Parameters

    • ua: any

      An Uint8Array

    • uaLength: any

      The Uint8Array length

    Returns WordArray

Const words2ua

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

    Parameters

    • destUa: any

      A destination Uint8Array

    • cryptoWords: any

      A wordArray

    Returns Uint8Array

Generated using TypeDoc