We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7fccb76 commit a53ce9dCopy full SHA for a53ce9d
1 file changed
src/key.ts
@@ -36,6 +36,13 @@ export class Key {
36
return concatBytes(key, csIn);
37
}
38
39
+ /** Validate key */
40
+ static validate(key: Uint8Array | string): boolean {
41
+ if(typeof key == "string") key = Key.fromString(key);
42
+ if (key.length !== 60) return false;
43
+ return this.arraysEqual(this.computeChecksum(key.slice(0, 50)), key.slice(50));
44
+ }
45
+
46
private static computeChecksum(key: Uint8Array): Uint8Array {
47
const csRaw = Angstrem3Core.generateKeystream(this.CHECKSUM_MRK, key, 1).slice(0, 5);
48
const cs = new Uint8Array(10);
0 commit comments