@omnituum/pqc-shared 0.2.6 → 0.3.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/dist/crypto/index.cjs +21 -22
- package/dist/crypto/index.d.cts +3 -3
- package/dist/crypto/index.d.ts +3 -3
- package/dist/crypto/index.js +6 -7
- package/dist/fs/index.cjs +5 -5
- package/dist/fs/index.js +2 -2
- package/dist/index.cjs +21 -22
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -7
- package/dist/utils/index.cjs +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/vault/index.cjs +5 -6
- package/dist/vault/index.js +5 -6
- package/package.json +4 -4
- package/src/crypto/dilithium.ts +1 -1
- package/src/crypto/primitives/blake3.ts +1 -1
- package/src/crypto/primitives/chacha.ts +1 -1
- package/src/crypto/primitives/hkdf.ts +2 -3
- package/src/crypto/primitives.ts +2 -2
package/dist/crypto/index.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var sha2_js = require('@noble/hashes/sha2.js');
|
|
4
|
+
var hmac_js = require('@noble/hashes/hmac.js');
|
|
5
5
|
var nacl = require('tweetnacl');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var sha512 = require('@noble/hashes/sha512');
|
|
6
|
+
var blake3_js = require('@noble/hashes/blake3.js');
|
|
7
|
+
var chacha_js = require('@noble/ciphers/chacha.js');
|
|
8
|
+
var hkdf_js = require('@noble/hashes/hkdf.js');
|
|
10
9
|
|
|
11
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
11
|
|
|
@@ -60,7 +59,7 @@ function randN(n) {
|
|
|
60
59
|
return globalThis.crypto.getRandomValues(new Uint8Array(n));
|
|
61
60
|
}
|
|
62
61
|
function sha256(bytes) {
|
|
63
|
-
return
|
|
62
|
+
return sha2_js.sha256(bytes);
|
|
64
63
|
}
|
|
65
64
|
function sha256String(str) {
|
|
66
65
|
return sha256(textEncoder.encode(str));
|
|
@@ -69,7 +68,7 @@ function hkdfSha256(ikm, opts) {
|
|
|
69
68
|
const salt = opts?.salt ?? new Uint8Array(32);
|
|
70
69
|
const info = opts?.info ?? new Uint8Array(0);
|
|
71
70
|
const L = opts?.length ?? 32;
|
|
72
|
-
const prk =
|
|
71
|
+
const prk = hmac_js.hmac(sha2_js.sha256, salt, ikm);
|
|
73
72
|
let t = new Uint8Array(0);
|
|
74
73
|
const chunks = [];
|
|
75
74
|
for (let i = 1; i <= Math.ceil(L / 32); i++) {
|
|
@@ -77,7 +76,7 @@ function hkdfSha256(ikm, opts) {
|
|
|
77
76
|
input.set(t, 0);
|
|
78
77
|
input.set(info, t.length);
|
|
79
78
|
input[input.length - 1] = i;
|
|
80
|
-
t = new Uint8Array(
|
|
79
|
+
t = new Uint8Array(hmac_js.hmac(sha2_js.sha256, prk, input));
|
|
81
80
|
chunks.push(t);
|
|
82
81
|
}
|
|
83
82
|
const out = new Uint8Array(L);
|
|
@@ -296,7 +295,7 @@ var dilithiumModule = null;
|
|
|
296
295
|
async function loadDilithium() {
|
|
297
296
|
if (dilithiumModule) return dilithiumModule;
|
|
298
297
|
try {
|
|
299
|
-
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa');
|
|
298
|
+
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa.js');
|
|
300
299
|
dilithiumModule = ml_dsa65;
|
|
301
300
|
return dilithiumModule;
|
|
302
301
|
} catch (e) {
|
|
@@ -575,7 +574,7 @@ function blake3(data, options) {
|
|
|
575
574
|
if (options?.context) {
|
|
576
575
|
opts.context = new TextEncoder().encode(options.context);
|
|
577
576
|
}
|
|
578
|
-
return
|
|
577
|
+
return blake3_js.blake3(input, opts);
|
|
579
578
|
}
|
|
580
579
|
function blake3Hex(data, options) {
|
|
581
580
|
const hash = blake3(data, options);
|
|
@@ -600,7 +599,7 @@ function chaCha20Poly1305Encrypt(key, nonce, plaintext, aad) {
|
|
|
600
599
|
if (nonce.length !== 12) {
|
|
601
600
|
throw new Error("ChaCha20-Poly1305 nonce must be 12 bytes");
|
|
602
601
|
}
|
|
603
|
-
const cipher =
|
|
602
|
+
const cipher = chacha_js.chacha20poly1305(key, nonce, aad);
|
|
604
603
|
return cipher.encrypt(plaintext);
|
|
605
604
|
}
|
|
606
605
|
function chaCha20Poly1305Decrypt(key, nonce, ciphertext, aad) {
|
|
@@ -611,7 +610,7 @@ function chaCha20Poly1305Decrypt(key, nonce, ciphertext, aad) {
|
|
|
611
610
|
throw new Error("ChaCha20-Poly1305 nonce must be 12 bytes");
|
|
612
611
|
}
|
|
613
612
|
try {
|
|
614
|
-
const cipher =
|
|
613
|
+
const cipher = chacha_js.chacha20poly1305(key, nonce, aad);
|
|
615
614
|
return cipher.decrypt(ciphertext);
|
|
616
615
|
} catch {
|
|
617
616
|
return null;
|
|
@@ -624,7 +623,7 @@ function xChaCha20Poly1305Encrypt(key, nonce, plaintext, aad) {
|
|
|
624
623
|
if (nonce.length !== 24) {
|
|
625
624
|
throw new Error("XChaCha20-Poly1305 nonce must be 24 bytes");
|
|
626
625
|
}
|
|
627
|
-
const cipher =
|
|
626
|
+
const cipher = chacha_js.xchacha20poly1305(key, nonce, aad);
|
|
628
627
|
return cipher.encrypt(plaintext);
|
|
629
628
|
}
|
|
630
629
|
function xChaCha20Poly1305Decrypt(key, nonce, ciphertext, aad) {
|
|
@@ -635,7 +634,7 @@ function xChaCha20Poly1305Decrypt(key, nonce, ciphertext, aad) {
|
|
|
635
634
|
throw new Error("XChaCha20-Poly1305 nonce must be 24 bytes");
|
|
636
635
|
}
|
|
637
636
|
try {
|
|
638
|
-
const cipher =
|
|
637
|
+
const cipher = chacha_js.xchacha20poly1305(key, nonce, aad);
|
|
639
638
|
return cipher.decrypt(ciphertext);
|
|
640
639
|
} catch {
|
|
641
640
|
return null;
|
|
@@ -648,7 +647,7 @@ function createXChaCha20Poly1305(key, nonce, aad) {
|
|
|
648
647
|
if (nonce.length !== 24) {
|
|
649
648
|
throw new Error("XChaCha20-Poly1305 nonce must be 24 bytes");
|
|
650
649
|
}
|
|
651
|
-
return
|
|
650
|
+
return chacha_js.xchacha20poly1305(key, nonce, aad);
|
|
652
651
|
}
|
|
653
652
|
function createChaCha20Poly1305(key, nonce, aad) {
|
|
654
653
|
if (key.length !== 32) {
|
|
@@ -657,7 +656,7 @@ function createChaCha20Poly1305(key, nonce, aad) {
|
|
|
657
656
|
if (nonce.length !== 12) {
|
|
658
657
|
throw new Error("ChaCha20-Poly1305 nonce must be 12 bytes");
|
|
659
658
|
}
|
|
660
|
-
return
|
|
659
|
+
return chacha_js.chacha20poly1305(key, nonce, aad);
|
|
661
660
|
}
|
|
662
661
|
var CHACHA20_KEY_SIZE = 32;
|
|
663
662
|
var CHACHA20_NONCE_SIZE = 12;
|
|
@@ -667,15 +666,15 @@ function hkdfDerive(ikm, outputLength, options) {
|
|
|
667
666
|
const hashFn = getHashFunction(options?.hash ?? "sha256");
|
|
668
667
|
const info = normalizeInfo(options?.info);
|
|
669
668
|
const salt = options?.salt;
|
|
670
|
-
return
|
|
669
|
+
return hkdf_js.hkdf(hashFn, ikm, salt, info, outputLength);
|
|
671
670
|
}
|
|
672
671
|
function hkdfExtract(ikm, salt, hash = "sha256") {
|
|
673
672
|
const hashFn = getHashFunction(hash);
|
|
674
|
-
return
|
|
673
|
+
return hkdf_js.extract(hashFn, ikm, salt);
|
|
675
674
|
}
|
|
676
675
|
function hkdfExpand(prk, info, outputLength, hash = "sha256") {
|
|
677
676
|
const hashFn = getHashFunction(hash);
|
|
678
|
-
return
|
|
677
|
+
return hkdf_js.expand(hashFn, prk, normalizeInfo(info), outputLength);
|
|
679
678
|
}
|
|
680
679
|
function hkdfSplitForNoise(chainingKey, inputKeyMaterial) {
|
|
681
680
|
const prk = hkdfExtract(inputKeyMaterial, chainingKey, "sha256");
|
|
@@ -702,9 +701,9 @@ function hkdfTripleSplitForNoise(chainingKey, inputKeyMaterial) {
|
|
|
702
701
|
function getHashFunction(hash) {
|
|
703
702
|
switch (hash) {
|
|
704
703
|
case "sha256":
|
|
705
|
-
return
|
|
704
|
+
return sha2_js.sha256;
|
|
706
705
|
case "sha512":
|
|
707
|
-
return
|
|
706
|
+
return sha2_js.sha512;
|
|
708
707
|
default:
|
|
709
708
|
throw new Error(`Unsupported HKDF hash: ${hash}`);
|
|
710
709
|
}
|
package/dist/crypto/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { E as ENVELOPE_VERSION, f as ENVELOPE_SUITE, g as ENVELOPE_AEAD } from '../version-BygzPVGs.cjs';
|
|
2
|
-
import * as
|
|
2
|
+
import * as _noble_ciphers_utils_js from '@noble/ciphers/utils.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Omnituum PQC Shared - Kyber ML-KEM-768
|
|
@@ -414,7 +414,7 @@ declare function xChaCha20Poly1305Decrypt(key: Uint8Array, nonce: Uint8Array, ci
|
|
|
414
414
|
* @param aad - Optional additional authenticated data
|
|
415
415
|
* @returns Cipher with encrypt/decrypt methods
|
|
416
416
|
*/
|
|
417
|
-
declare function createXChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array):
|
|
417
|
+
declare function createXChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array): _noble_ciphers_utils_js.CipherWithOutput;
|
|
418
418
|
/**
|
|
419
419
|
* Create a ChaCha20-Poly1305 cipher instance.
|
|
420
420
|
*
|
|
@@ -423,7 +423,7 @@ declare function createXChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad
|
|
|
423
423
|
* @param aad - Optional additional authenticated data
|
|
424
424
|
* @returns Cipher with encrypt/decrypt methods
|
|
425
425
|
*/
|
|
426
|
-
declare function createChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array):
|
|
426
|
+
declare function createChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array): _noble_ciphers_utils_js.CipherWithOutput;
|
|
427
427
|
/** ChaCha20-Poly1305 key size (32 bytes) */
|
|
428
428
|
declare const CHACHA20_KEY_SIZE = 32;
|
|
429
429
|
/** ChaCha20-Poly1305 nonce size (12 bytes) */
|
package/dist/crypto/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { E as ENVELOPE_VERSION, f as ENVELOPE_SUITE, g as ENVELOPE_AEAD } from '../version-BygzPVGs.js';
|
|
2
|
-
import * as
|
|
2
|
+
import * as _noble_ciphers_utils_js from '@noble/ciphers/utils.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Omnituum PQC Shared - Kyber ML-KEM-768
|
|
@@ -414,7 +414,7 @@ declare function xChaCha20Poly1305Decrypt(key: Uint8Array, nonce: Uint8Array, ci
|
|
|
414
414
|
* @param aad - Optional additional authenticated data
|
|
415
415
|
* @returns Cipher with encrypt/decrypt methods
|
|
416
416
|
*/
|
|
417
|
-
declare function createXChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array):
|
|
417
|
+
declare function createXChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array): _noble_ciphers_utils_js.CipherWithOutput;
|
|
418
418
|
/**
|
|
419
419
|
* Create a ChaCha20-Poly1305 cipher instance.
|
|
420
420
|
*
|
|
@@ -423,7 +423,7 @@ declare function createXChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad
|
|
|
423
423
|
* @param aad - Optional additional authenticated data
|
|
424
424
|
* @returns Cipher with encrypt/decrypt methods
|
|
425
425
|
*/
|
|
426
|
-
declare function createChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array):
|
|
426
|
+
declare function createChaCha20Poly1305(key: Uint8Array, nonce: Uint8Array, aad?: Uint8Array): _noble_ciphers_utils_js.CipherWithOutput;
|
|
427
427
|
/** ChaCha20-Poly1305 key size (32 bytes) */
|
|
428
428
|
declare const CHACHA20_KEY_SIZE = 32;
|
|
429
429
|
/** ChaCha20-Poly1305 nonce size (12 bytes) */
|
package/dist/crypto/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { sha256 as sha256$1 } from '@noble/hashes/
|
|
2
|
-
import { hmac } from '@noble/hashes/hmac';
|
|
1
|
+
import { sha256 as sha256$1, sha512 } from '@noble/hashes/sha2.js';
|
|
2
|
+
import { hmac } from '@noble/hashes/hmac.js';
|
|
3
3
|
import nacl from 'tweetnacl';
|
|
4
|
-
import { blake3 as blake3$1 } from '@noble/hashes/blake3';
|
|
5
|
-
import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha';
|
|
6
|
-
import { hkdf, extract, expand } from '@noble/hashes/hkdf';
|
|
7
|
-
import { sha512 } from '@noble/hashes/sha512';
|
|
4
|
+
import { blake3 as blake3$1 } from '@noble/hashes/blake3.js';
|
|
5
|
+
import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha.js';
|
|
6
|
+
import { hkdf, extract, expand } from '@noble/hashes/hkdf.js';
|
|
8
7
|
|
|
9
8
|
// src/crypto/primitives.ts
|
|
10
9
|
var textEncoder = new TextEncoder();
|
|
@@ -290,7 +289,7 @@ var dilithiumModule = null;
|
|
|
290
289
|
async function loadDilithium() {
|
|
291
290
|
if (dilithiumModule) return dilithiumModule;
|
|
292
291
|
try {
|
|
293
|
-
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa');
|
|
292
|
+
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa.js');
|
|
294
293
|
dilithiumModule = ml_dsa65;
|
|
295
294
|
return dilithiumModule;
|
|
296
295
|
} catch (e) {
|
package/dist/fs/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var hashWasm = require('hash-wasm');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var sha2_js = require('@noble/hashes/sha2.js');
|
|
5
|
+
var hmac_js = require('@noble/hashes/hmac.js');
|
|
6
6
|
var nacl2 = require('tweetnacl');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -94,13 +94,13 @@ function randN(n) {
|
|
|
94
94
|
return globalThis.crypto.getRandomValues(new Uint8Array(n));
|
|
95
95
|
}
|
|
96
96
|
function sha256(bytes) {
|
|
97
|
-
return
|
|
97
|
+
return sha2_js.sha256(bytes);
|
|
98
98
|
}
|
|
99
99
|
function hkdfSha256(ikm, opts) {
|
|
100
100
|
const salt = opts?.salt ?? new Uint8Array(32);
|
|
101
101
|
const info = opts?.info ?? new Uint8Array(0);
|
|
102
102
|
const L = opts?.length ?? 32;
|
|
103
|
-
const prk =
|
|
103
|
+
const prk = hmac_js.hmac(sha2_js.sha256, salt, ikm);
|
|
104
104
|
let t = new Uint8Array(0);
|
|
105
105
|
const chunks = [];
|
|
106
106
|
for (let i = 1; i <= Math.ceil(L / 32); i++) {
|
|
@@ -108,7 +108,7 @@ function hkdfSha256(ikm, opts) {
|
|
|
108
108
|
input.set(t, 0);
|
|
109
109
|
input.set(info, t.length);
|
|
110
110
|
input[input.length - 1] = i;
|
|
111
|
-
t = new Uint8Array(
|
|
111
|
+
t = new Uint8Array(hmac_js.hmac(sha2_js.sha256, prk, input));
|
|
112
112
|
chunks.push(t);
|
|
113
113
|
}
|
|
114
114
|
const out = new Uint8Array(L);
|
package/dist/fs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { argon2id } from 'hash-wasm';
|
|
2
|
-
import { sha256 as sha256$1 } from '@noble/hashes/
|
|
3
|
-
import { hmac } from '@noble/hashes/hmac';
|
|
2
|
+
import { sha256 as sha256$1 } from '@noble/hashes/sha2.js';
|
|
3
|
+
import { hmac } from '@noble/hashes/hmac.js';
|
|
4
4
|
import nacl2 from 'tweetnacl';
|
|
5
5
|
|
|
6
6
|
// src/fs/types.ts
|
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var nacl4 = require('tweetnacl');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var sha2_js = require('@noble/hashes/sha2.js');
|
|
5
|
+
var hmac_js = require('@noble/hashes/hmac.js');
|
|
6
6
|
var hashWasm = require('hash-wasm');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var sha512 = require('@noble/hashes/sha512');
|
|
7
|
+
var blake3_js = require('@noble/hashes/blake3.js');
|
|
8
|
+
var chacha_js = require('@noble/ciphers/chacha.js');
|
|
9
|
+
var hkdf_js = require('@noble/hashes/hkdf.js');
|
|
11
10
|
|
|
12
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
12
|
|
|
@@ -69,7 +68,7 @@ function randN(n) {
|
|
|
69
68
|
return globalThis.crypto.getRandomValues(new Uint8Array(n));
|
|
70
69
|
}
|
|
71
70
|
function sha256(bytes) {
|
|
72
|
-
return
|
|
71
|
+
return sha2_js.sha256(bytes);
|
|
73
72
|
}
|
|
74
73
|
function sha256String(str) {
|
|
75
74
|
return sha256(textEncoder.encode(str));
|
|
@@ -78,7 +77,7 @@ function hkdfSha256(ikm, opts) {
|
|
|
78
77
|
const salt = opts?.salt ?? new Uint8Array(32);
|
|
79
78
|
const info = opts?.info ?? new Uint8Array(0);
|
|
80
79
|
const L = opts?.length ?? 32;
|
|
81
|
-
const prk =
|
|
80
|
+
const prk = hmac_js.hmac(sha2_js.sha256, salt, ikm);
|
|
82
81
|
let t = new Uint8Array(0);
|
|
83
82
|
const chunks = [];
|
|
84
83
|
for (let i = 1; i <= Math.ceil(L / 32); i++) {
|
|
@@ -86,7 +85,7 @@ function hkdfSha256(ikm, opts) {
|
|
|
86
85
|
input.set(t, 0);
|
|
87
86
|
input.set(info, t.length);
|
|
88
87
|
input[input.length - 1] = i;
|
|
89
|
-
t = new Uint8Array(
|
|
88
|
+
t = new Uint8Array(hmac_js.hmac(sha2_js.sha256, prk, input));
|
|
90
89
|
chunks.push(t);
|
|
91
90
|
}
|
|
92
91
|
const out = new Uint8Array(L);
|
|
@@ -539,7 +538,7 @@ var dilithiumModule = null;
|
|
|
539
538
|
async function loadDilithium() {
|
|
540
539
|
if (dilithiumModule) return dilithiumModule;
|
|
541
540
|
try {
|
|
542
|
-
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa');
|
|
541
|
+
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa.js');
|
|
543
542
|
dilithiumModule = ml_dsa65;
|
|
544
543
|
return dilithiumModule;
|
|
545
544
|
} catch (e) {
|
|
@@ -1005,7 +1004,7 @@ function blake3(data, options) {
|
|
|
1005
1004
|
if (options?.context) {
|
|
1006
1005
|
opts.context = new TextEncoder().encode(options.context);
|
|
1007
1006
|
}
|
|
1008
|
-
return
|
|
1007
|
+
return blake3_js.blake3(input, opts);
|
|
1009
1008
|
}
|
|
1010
1009
|
function blake3Hex(data, options) {
|
|
1011
1010
|
const hash = blake3(data, options);
|
|
@@ -1028,7 +1027,7 @@ function chaCha20Poly1305Encrypt(key, nonce, plaintext, aad) {
|
|
|
1028
1027
|
if (nonce.length !== 12) {
|
|
1029
1028
|
throw new Error("ChaCha20-Poly1305 nonce must be 12 bytes");
|
|
1030
1029
|
}
|
|
1031
|
-
const cipher =
|
|
1030
|
+
const cipher = chacha_js.chacha20poly1305(key, nonce, aad);
|
|
1032
1031
|
return cipher.encrypt(plaintext);
|
|
1033
1032
|
}
|
|
1034
1033
|
function chaCha20Poly1305Decrypt(key, nonce, ciphertext, aad) {
|
|
@@ -1039,7 +1038,7 @@ function chaCha20Poly1305Decrypt(key, nonce, ciphertext, aad) {
|
|
|
1039
1038
|
throw new Error("ChaCha20-Poly1305 nonce must be 12 bytes");
|
|
1040
1039
|
}
|
|
1041
1040
|
try {
|
|
1042
|
-
const cipher =
|
|
1041
|
+
const cipher = chacha_js.chacha20poly1305(key, nonce, aad);
|
|
1043
1042
|
return cipher.decrypt(ciphertext);
|
|
1044
1043
|
} catch {
|
|
1045
1044
|
return null;
|
|
@@ -1052,7 +1051,7 @@ function xChaCha20Poly1305Encrypt(key, nonce, plaintext, aad) {
|
|
|
1052
1051
|
if (nonce.length !== 24) {
|
|
1053
1052
|
throw new Error("XChaCha20-Poly1305 nonce must be 24 bytes");
|
|
1054
1053
|
}
|
|
1055
|
-
const cipher =
|
|
1054
|
+
const cipher = chacha_js.xchacha20poly1305(key, nonce, aad);
|
|
1056
1055
|
return cipher.encrypt(plaintext);
|
|
1057
1056
|
}
|
|
1058
1057
|
function xChaCha20Poly1305Decrypt(key, nonce, ciphertext, aad) {
|
|
@@ -1063,7 +1062,7 @@ function xChaCha20Poly1305Decrypt(key, nonce, ciphertext, aad) {
|
|
|
1063
1062
|
throw new Error("XChaCha20-Poly1305 nonce must be 24 bytes");
|
|
1064
1063
|
}
|
|
1065
1064
|
try {
|
|
1066
|
-
const cipher =
|
|
1065
|
+
const cipher = chacha_js.xchacha20poly1305(key, nonce, aad);
|
|
1067
1066
|
return cipher.decrypt(ciphertext);
|
|
1068
1067
|
} catch {
|
|
1069
1068
|
return null;
|
|
@@ -1076,7 +1075,7 @@ function createXChaCha20Poly1305(key, nonce, aad) {
|
|
|
1076
1075
|
if (nonce.length !== 24) {
|
|
1077
1076
|
throw new Error("XChaCha20-Poly1305 nonce must be 24 bytes");
|
|
1078
1077
|
}
|
|
1079
|
-
return
|
|
1078
|
+
return chacha_js.xchacha20poly1305(key, nonce, aad);
|
|
1080
1079
|
}
|
|
1081
1080
|
function createChaCha20Poly1305(key, nonce, aad) {
|
|
1082
1081
|
if (key.length !== 32) {
|
|
@@ -1085,7 +1084,7 @@ function createChaCha20Poly1305(key, nonce, aad) {
|
|
|
1085
1084
|
if (nonce.length !== 12) {
|
|
1086
1085
|
throw new Error("ChaCha20-Poly1305 nonce must be 12 bytes");
|
|
1087
1086
|
}
|
|
1088
|
-
return
|
|
1087
|
+
return chacha_js.chacha20poly1305(key, nonce, aad);
|
|
1089
1088
|
}
|
|
1090
1089
|
var CHACHA20_KEY_SIZE = 32;
|
|
1091
1090
|
var XCHACHA20_NONCE_SIZE = 24;
|
|
@@ -1094,15 +1093,15 @@ function hkdfDerive(ikm, outputLength, options) {
|
|
|
1094
1093
|
const hashFn = getHashFunction(options?.hash ?? "sha256");
|
|
1095
1094
|
const info = normalizeInfo(options?.info);
|
|
1096
1095
|
const salt = options?.salt;
|
|
1097
|
-
return
|
|
1096
|
+
return hkdf_js.hkdf(hashFn, ikm, salt, info, outputLength);
|
|
1098
1097
|
}
|
|
1099
1098
|
function hkdfExtract(ikm, salt, hash = "sha256") {
|
|
1100
1099
|
const hashFn = getHashFunction(hash);
|
|
1101
|
-
return
|
|
1100
|
+
return hkdf_js.extract(hashFn, ikm, salt);
|
|
1102
1101
|
}
|
|
1103
1102
|
function hkdfExpand(prk, info, outputLength, hash = "sha256") {
|
|
1104
1103
|
const hashFn = getHashFunction(hash);
|
|
1105
|
-
return
|
|
1104
|
+
return hkdf_js.expand(hashFn, prk, normalizeInfo(info), outputLength);
|
|
1106
1105
|
}
|
|
1107
1106
|
function hkdfSplitForNoise(chainingKey, inputKeyMaterial) {
|
|
1108
1107
|
const prk = hkdfExtract(inputKeyMaterial, chainingKey, "sha256");
|
|
@@ -1129,9 +1128,9 @@ function hkdfTripleSplitForNoise(chainingKey, inputKeyMaterial) {
|
|
|
1129
1128
|
function getHashFunction(hash) {
|
|
1130
1129
|
switch (hash) {
|
|
1131
1130
|
case "sha256":
|
|
1132
|
-
return
|
|
1131
|
+
return sha2_js.sha256;
|
|
1133
1132
|
case "sha512":
|
|
1134
|
-
return
|
|
1133
|
+
return sha2_js.sha512;
|
|
1135
1134
|
default:
|
|
1136
1135
|
throw new Error(`Unsupported HKDF hash: ${hash}`);
|
|
1137
1136
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ export { MigrationOptions, MigrationResult, addIdentity, createEmptyVault, creat
|
|
|
4
4
|
export { c as computeIntegrityHash, b as computeKeyFingerprint } from './integrity-Dx9jukMH.cjs';
|
|
5
5
|
export { g as ENVELOPE_AEAD, f as ENVELOPE_SUITE, E as ENVELOPE_VERSION, c as VAULT_ALGORITHM, a as VAULT_ENCRYPTED_VERSION, d as VAULT_ENCRYPTED_VERSION_V2, b as VAULT_KDF, e as VAULT_KDF_V2, V as VAULT_VERSION, i as validateEncryptedVault, h as validateEnvelope, v as validateVault } from './version-BygzPVGs.cjs';
|
|
6
6
|
export { D as DecryptOptions, E as EncryptOptions, c as OQEDecryptResult, O as OQEEncryptResult, d as decryptFile, b as decryptFileWithPassword, e as encryptFile, a as encryptFileWithPassword } from './decrypt-eSHlbh1j.cjs';
|
|
7
|
-
import '@noble/ciphers/utils';
|
|
7
|
+
import '@noble/ciphers/utils.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Omnituum PQC Shared - Unified Key Derivation
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { MigrationOptions, MigrationResult, addIdentity, createEmptyVault, creat
|
|
|
4
4
|
export { c as computeIntegrityHash, b as computeKeyFingerprint } from './integrity-CCYjrap3.js';
|
|
5
5
|
export { g as ENVELOPE_AEAD, f as ENVELOPE_SUITE, E as ENVELOPE_VERSION, c as VAULT_ALGORITHM, a as VAULT_ENCRYPTED_VERSION, d as VAULT_ENCRYPTED_VERSION_V2, b as VAULT_KDF, e as VAULT_KDF_V2, V as VAULT_VERSION, i as validateEncryptedVault, h as validateEnvelope, v as validateVault } from './version-BygzPVGs.js';
|
|
6
6
|
export { D as DecryptOptions, E as EncryptOptions, c as OQEDecryptResult, O as OQEEncryptResult, d as decryptFile, b as decryptFileWithPassword, e as encryptFile, a as encryptFileWithPassword } from './decrypt-eSHlbh1j.js';
|
|
7
|
-
import '@noble/ciphers/utils';
|
|
7
|
+
import '@noble/ciphers/utils.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Omnituum PQC Shared - Unified Key Derivation
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import nacl4 from 'tweetnacl';
|
|
2
|
-
import { sha256 as sha256$1 } from '@noble/hashes/
|
|
3
|
-
import { hmac } from '@noble/hashes/hmac';
|
|
2
|
+
import { sha256 as sha256$1, sha512 } from '@noble/hashes/sha2.js';
|
|
3
|
+
import { hmac } from '@noble/hashes/hmac.js';
|
|
4
4
|
import { argon2id } from 'hash-wasm';
|
|
5
|
-
import { blake3 as blake3$1 } from '@noble/hashes/blake3';
|
|
6
|
-
import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha';
|
|
7
|
-
import { hkdf, extract, expand } from '@noble/hashes/hkdf';
|
|
8
|
-
import { sha512 } from '@noble/hashes/sha512';
|
|
5
|
+
import { blake3 as blake3$1 } from '@noble/hashes/blake3.js';
|
|
6
|
+
import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha.js';
|
|
7
|
+
import { hkdf, extract, expand } from '@noble/hashes/hkdf.js';
|
|
9
8
|
|
|
10
9
|
// src/runtime/crypto.ts
|
|
11
10
|
async function ensureCrypto() {
|
|
@@ -533,7 +532,7 @@ var dilithiumModule = null;
|
|
|
533
532
|
async function loadDilithium() {
|
|
534
533
|
if (dilithiumModule) return dilithiumModule;
|
|
535
534
|
try {
|
|
536
|
-
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa');
|
|
535
|
+
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa.js');
|
|
537
536
|
dilithiumModule = ml_dsa65;
|
|
538
537
|
return dilithiumModule;
|
|
539
538
|
} catch (e) {
|
package/dist/utils/index.cjs
CHANGED
package/dist/utils/index.js
CHANGED
package/dist/vault/index.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('@noble/hashes/
|
|
4
|
-
require('@noble/hashes/hmac');
|
|
3
|
+
require('@noble/hashes/sha2.js');
|
|
4
|
+
require('@noble/hashes/hmac.js');
|
|
5
5
|
var hashWasm = require('hash-wasm');
|
|
6
6
|
var nacl = require('tweetnacl');
|
|
7
|
-
require('@noble/hashes/blake3');
|
|
8
|
-
require('@noble/ciphers/chacha');
|
|
9
|
-
require('@noble/hashes/hkdf');
|
|
10
|
-
require('@noble/hashes/sha512');
|
|
7
|
+
require('@noble/hashes/blake3.js');
|
|
8
|
+
require('@noble/ciphers/chacha.js');
|
|
9
|
+
require('@noble/hashes/hkdf.js');
|
|
11
10
|
|
|
12
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
12
|
|
package/dist/vault/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import '@noble/hashes/
|
|
2
|
-
import '@noble/hashes/hmac';
|
|
1
|
+
import '@noble/hashes/sha2.js';
|
|
2
|
+
import '@noble/hashes/hmac.js';
|
|
3
3
|
import { argon2id } from 'hash-wasm';
|
|
4
4
|
import nacl from 'tweetnacl';
|
|
5
|
-
import '@noble/hashes/blake3';
|
|
6
|
-
import '@noble/ciphers/chacha';
|
|
7
|
-
import '@noble/hashes/hkdf';
|
|
8
|
-
import '@noble/hashes/sha512';
|
|
5
|
+
import '@noble/hashes/blake3.js';
|
|
6
|
+
import '@noble/ciphers/chacha.js';
|
|
7
|
+
import '@noble/hashes/hkdf.js';
|
|
9
8
|
|
|
10
9
|
// src/vault/types.ts
|
|
11
10
|
var DEFAULT_VAULT_SETTINGS = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnituum/pqc-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Omnituum PQC Shared Library - Crypto, Vault, File Encryption, and Utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"src"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@noble/ciphers": "
|
|
42
|
-
"@noble/hashes": "
|
|
43
|
-
"@noble/post-quantum": "
|
|
41
|
+
"@noble/ciphers": "~2.0.0",
|
|
42
|
+
"@noble/hashes": "~2.0.0",
|
|
43
|
+
"@noble/post-quantum": "~0.5.4",
|
|
44
44
|
"hash-wasm": "^4.11.0",
|
|
45
45
|
"kyber-crystals": "^1.0.7",
|
|
46
46
|
"tweetnacl": "^1.0.3"
|
package/src/crypto/dilithium.ts
CHANGED
|
@@ -41,7 +41,7 @@ async function loadDilithium(): Promise<any> {
|
|
|
41
41
|
|
|
42
42
|
try {
|
|
43
43
|
// @noble/post-quantum provides ml-dsa
|
|
44
|
-
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa');
|
|
44
|
+
const { ml_dsa65 } = await import('@noble/post-quantum/ml-dsa.js');
|
|
45
45
|
dilithiumModule = ml_dsa65;
|
|
46
46
|
return dilithiumModule;
|
|
47
47
|
} catch (e) {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Used in Noise protocols for transcript hashing.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { blake3 as nobleBlake3 } from '@noble/hashes/blake3';
|
|
12
|
+
import { blake3 as nobleBlake3 } from '@noble/hashes/blake3.js';
|
|
13
13
|
|
|
14
14
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
15
15
|
// TYPES
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Used in Noise protocols and general-purpose encryption.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha';
|
|
11
|
+
import { chacha20poly1305, xchacha20poly1305 } from '@noble/ciphers/chacha.js';
|
|
12
12
|
|
|
13
13
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
14
14
|
// TYPES
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
* Used in Noise protocols for key derivation.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { hkdf, extract, expand } from '@noble/hashes/hkdf';
|
|
15
|
-
import { sha256 } from '@noble/hashes/
|
|
16
|
-
import { sha512 } from '@noble/hashes/sha512';
|
|
14
|
+
import { hkdf, extract, expand } from '@noble/hashes/hkdf.js';
|
|
15
|
+
import { sha256, sha512 } from '@noble/hashes/sha2.js';
|
|
17
16
|
|
|
18
17
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
19
18
|
// TYPES
|
package/src/crypto/primitives.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Uses Web Crypto API and @noble/hashes for all operations.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { sha256 as nobleSha256 } from '@noble/hashes/
|
|
9
|
-
import { hmac } from '@noble/hashes/hmac';
|
|
8
|
+
import { sha256 as nobleSha256 } from '@noble/hashes/sha2.js';
|
|
9
|
+
import { hmac } from '@noble/hashes/hmac.js';
|
|
10
10
|
|
|
11
11
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
12
12
|
// TEXT ENCODING
|