cleanup generateUsername function

This commit is contained in:
Pavel Prichodko 2022-06-09 19:22:05 +02:00 committed by Felicio Mununga
parent 13546f2c0c
commit a41091a680
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
1 changed files with 3 additions and 7 deletions

View File

@ -1,21 +1,17 @@
const poly = BigInt(0xb8) const poly = BigInt(0xb8)
function lfsr(seed: bigint) { function lfsr(seed: bigint) {
console.log({ seed })
let bit = 0n let bit = 0n
for (let index = 0; index < 64; index++) { for (let index = 0; index < 64; index++) {
const cond = poly & (1n << BigInt(index)) if ((poly & (1n << BigInt(index))) !== 0n) {
if (cond !== 0n) {
bit ^= seed >> BigInt(index) bit ^= seed >> BigInt(index)
} }
} }
console.log({ bit })
bit &= 1n bit &= 1n
const result = BigInt.asUintN(64, seed << 1n) | bit
return result return BigInt.asUintN(64, seed << 1n) | bit
} }
export function generateUsername(publicKey: string): string { export function generateUsername(publicKey: string): string {