@bcts/crypto 1.0.0-alpha.9 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -2
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/index.cjs +263 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +134 -73
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +134 -73
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +255 -141
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +223 -124
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -19
- package/src/argon.ts +14 -9
- package/src/ecdsa-keys.ts +11 -5
- package/src/ecdsa-signing.ts +11 -6
- package/src/ed25519-signing.ts +7 -1
- package/src/error.ts +15 -0
- package/src/hash.ts +10 -4
- package/src/index.ts +24 -18
- package/src/memzero.ts +38 -12
- package/src/public-key-encryption.ts +31 -7
- package/src/schnorr-signing.ts +7 -1
- package/src/scrypt.ts +12 -3
- package/src/symmetric-encryption.ts +7 -1
package/src/schnorr-signing.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
3
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
// Ported from bc-crypto-rust/src/schnorr_signing.rs
|
|
2
8
|
|
|
3
|
-
import { schnorr } from "@noble/curves/secp256k1";
|
|
9
|
+
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
4
10
|
import type { RandomNumberGenerator } from "@bcts/rand";
|
|
5
11
|
import { SecureRandomNumberGenerator } from "@bcts/rand";
|
|
6
12
|
import { ECDSA_PRIVATE_KEY_SIZE, SCHNORR_PUBLIC_KEY_SIZE } from "./ecdsa-keys.js";
|
package/src/scrypt.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
3
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
// Ported from bc-crypto-rust/src/scrypt.rs
|
|
2
8
|
|
|
3
|
-
import { scrypt as nobleScrypt } from "@noble/hashes/scrypt";
|
|
9
|
+
import { scrypt as nobleScrypt } from "@noble/hashes/scrypt.js";
|
|
4
10
|
|
|
5
11
|
/**
|
|
6
12
|
* Derive a key using Scrypt with recommended parameters.
|
|
7
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* Mirrors Rust `bc_crypto::scrypt` which calls `scrypt::Params::recommended()`.
|
|
15
|
+
* The recommended parameters per the upstream `scrypt` crate are
|
|
16
|
+
* `log_n = 17` (N = 2^17 = 131072), `r = 8`, `p = 1`.
|
|
8
17
|
*
|
|
9
18
|
* @param password - Password or passphrase
|
|
10
19
|
* @param salt - Salt value
|
|
@@ -12,7 +21,7 @@ import { scrypt as nobleScrypt } from "@noble/hashes/scrypt";
|
|
|
12
21
|
* @returns Derived key
|
|
13
22
|
*/
|
|
14
23
|
export function scrypt(password: Uint8Array, salt: Uint8Array, outputLen: number): Uint8Array {
|
|
15
|
-
return scryptOpt(password, salt, outputLen,
|
|
24
|
+
return scryptOpt(password, salt, outputLen, 17, 8, 1);
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
/**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
3
|
+
* Copyright © 2025-2026 Parity Technologies
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
// Ported from bc-crypto-rust/src/symmetric_encryption.rs
|
|
2
8
|
|
|
3
|
-
import { chacha20poly1305 } from "@noble/ciphers/chacha";
|
|
9
|
+
import { chacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
4
10
|
import { CryptoError, AeadError } from "./error.js";
|
|
5
11
|
|
|
6
12
|
// Constants
|