mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
including nostr specialized types (#409)
* including nostr types * including tests for nostr type guard * fix tests for nostr type guard * fix linter and add eslint and prettier to devcontainer * including null in nostr type guard signature * fix type, ops * including ncryptsec in nostr type guard * fix linter for ncryptsec * including ncryptsec return type for nip49 * fixing names of nostr types and types guards * fixing names of nostr types and types guards in unit tests descriptions * fix prettier * including type guard for nip5
This commit is contained in:
committed by
GitHub
parent
21433049b8
commit
ee76d69b4b
8
nip49.ts
8
nip49.ts
@@ -3,8 +3,14 @@ import { xchacha20poly1305 } from '@noble/ciphers/chacha'
|
||||
import { concatBytes, randomBytes } from '@noble/hashes/utils'
|
||||
import { Bech32MaxSize, encodeBytes } from './nip19.ts'
|
||||
import { bech32 } from '@scure/base'
|
||||
import { Ncryptsec } from './core.ts'
|
||||
|
||||
export function encrypt(sec: Uint8Array, password: string, logn: number = 16, ksb: 0x00 | 0x01 | 0x02 = 0x02): string {
|
||||
export function encrypt(
|
||||
sec: Uint8Array,
|
||||
password: string,
|
||||
logn: number = 16,
|
||||
ksb: 0x00 | 0x01 | 0x02 = 0x02,
|
||||
): Ncryptsec {
|
||||
let salt = randomBytes(16)
|
||||
let n = 2 ** logn
|
||||
let key = scrypt(password.normalize('NFKC'), salt, { N: n, r: 8, p: 1, dkLen: 32 })
|
||||
|
||||
Reference in New Issue
Block a user