AuthKey.js 496 B

123456789101112131415161718192021
  1. const helper = require("../utils/Helpers").helpers;
  2. class AuthKey {
  3. constructor(data) {
  4. this.data = data;
  5. let buffer = Buffer.from(helper.sha1(data));
  6. this.auxHash = buffer.slice(0, 8).readBigUInt64LE();
  7. this.keyId = buffer.slice(12, 20).readBigUInt64LE();
  8. }
  9. calcNewNonceHash(new_nonce, number) {
  10. let buffer = Buffer.concat([new_nonce, number, this.auxHash]);
  11. return helper.calcMsgKey(buffer);
  12. }
  13. }
  14. exports.AuthKey = AuthKey;