1
0
Эх сурвалжийг харах

Implemented AuthKey.

With this, the crypto package has been finished.
painor 5 жил өмнө
parent
commit
bece4fa13b
1 өөрчлөгдсөн 19 нэмэгдсэн , 2 устгасан
  1. 19 2
      crypto/AuthKey.js

+ 19 - 2
crypto/AuthKey.js

@@ -1,3 +1,20 @@
+const helper = require("../utils/Helpers").helpers;
+
 class AuthKey {
-    
-}
+    constructor(data) {
+        this.data = data;
+
+        let buffer = Buffer.from(helper.sha1(data));
+
+        this.aux_hash = buffer.slice(0, 8).readBigUInt64LE();
+        this.key_id = buffer.slice(12, 20).readBigUInt64LE();
+
+    }
+
+    calcNewNonceHash(new_nonce, number) {
+        let buffer = Buffer.concat([new_nonce, number, this.aux_hash]);
+        return helper.calcMsgKey(buffer);
+    }
+
+}
+