Преглед изворни кода

Implemented AuthKey.

With this, the crypto package has been finished.
painor пре 5 година
родитељ
комит
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 {
 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);
+    }
+
+}
+