@darkbio/crypto 0.4.0 → 0.17.2
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/argon2.d.ts +1 -1
- package/dist/argon2.d.ts.map +1 -1
- package/dist/cbor.d.ts +14 -0
- package/dist/cbor.d.ts.map +1 -0
- package/dist/cose.d.ts +8 -0
- package/dist/cose.d.ts.map +1 -1
- package/dist/cwt.d.ts.map +1 -1
- package/dist/hkdf.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2155 -2911
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +9 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/rand.d.ts +1 -1
- package/dist/rand.d.ts.map +1 -1
- package/dist/xdsa.d.ts +12 -8
- package/dist/xdsa.d.ts.map +1 -1
- package/dist/xhpke.d.ts +12 -12
- package/dist/xhpke.d.ts.map +1 -1
- package/package.json +12 -11
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures the WASM module is instantiated exactly once. Concurrent callers
|
|
3
|
+
* share the single in-flight initialization; a failed attempt is cleared so
|
|
4
|
+
* the next call can retry.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare function ensureInit(): Promise<unknown>;
|
|
9
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAQ7C"}
|
package/dist/rand.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generate cryptographically secure random bytes.
|
|
3
3
|
*
|
|
4
|
-
* @param bytes - Number of random bytes to generate
|
|
4
|
+
* @param bytes - Number of random bytes to generate (max 64 MiB)
|
|
5
5
|
* @returns A Uint8Array containing the random bytes
|
|
6
6
|
*/
|
|
7
7
|
export declare function generate(bytes: number): Promise<Uint8Array>;
|
package/dist/rand.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rand.d.ts","sourceRoot":"","sources":["../src/rand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rand.d.ts","sourceRoot":"","sources":["../src/rand.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAGjE"}
|
package/dist/xdsa.d.ts
CHANGED
|
@@ -61,11 +61,15 @@ export declare class PublicKey {
|
|
|
61
61
|
/** Converts a public key into a 1984-byte array. */
|
|
62
62
|
toBytes(): Uint8Array;
|
|
63
63
|
/** Serializes a public key into a PEM string. */
|
|
64
|
-
toPem():
|
|
64
|
+
toPem(): string;
|
|
65
65
|
/** Returns a 256-bit unique identifier for this key. */
|
|
66
|
-
fingerprint():
|
|
67
|
-
/**
|
|
68
|
-
|
|
66
|
+
fingerprint(): Fingerprint;
|
|
67
|
+
/**
|
|
68
|
+
* Verifies a digital signature of the message.
|
|
69
|
+
*
|
|
70
|
+
* @returns true if the signature is valid, false otherwise (never throws)
|
|
71
|
+
*/
|
|
72
|
+
verify(message: Uint8Array, signature: Signature): boolean;
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
71
75
|
* SecretKey contains a composite ML-DSA-65 + Ed25519 private key for
|
|
@@ -86,12 +90,12 @@ export declare class SecretKey {
|
|
|
86
90
|
/** Converts a secret key into a 64-byte array. */
|
|
87
91
|
toBytes(): Uint8Array;
|
|
88
92
|
/** Serializes a private key into a PEM string. */
|
|
89
|
-
toPem():
|
|
93
|
+
toPem(): string;
|
|
90
94
|
/** Retrieves the public counterpart of the secret key. */
|
|
91
|
-
publicKey():
|
|
95
|
+
publicKey(): PublicKey;
|
|
92
96
|
/** Returns a 256-bit unique identifier for this key. */
|
|
93
|
-
fingerprint():
|
|
97
|
+
fingerprint(): Fingerprint;
|
|
94
98
|
/** Creates a digital signature of the message. */
|
|
95
|
-
sign(message: Uint8Array):
|
|
99
|
+
sign(message: Uint8Array): Signature;
|
|
96
100
|
}
|
|
97
101
|
//# sourceMappingURL=xdsa.d.ts.map
|
package/dist/xdsa.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xdsa.d.ts","sourceRoot":"","sources":["../src/xdsa.ts"],"names":[],"mappings":"AAMA,
|
|
1
|
+
{"version":3,"file":"xdsa.d.ts","sourceRoot":"","sources":["../src/xdsa.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,aAAa,IAAI,aAAa,EAC9B,aAAa,IAAI,aAAa,EAC9B,aAAa,IAAI,aAAa,EAC9B,eAAe,IAAI,eAAe,EACnC,MAAM,+BAA+B,CAAC;AAGvC,4CAA4C;AAC5C,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,8CAA8C;AAC9C,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,2CAA2C;AAC3C,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAQD;AAED;;;GAGG;AACH,qBAAa,WAAW;IACtB,gBAAgB;IAChB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAEhC,gBAAgB;gBACJ,KAAK,EAAE,eAAe;IAIlC,kDAAkD;WACrC,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IAK/D,mDA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AAM;IAIf,0DAA0D;IAC1D,SAAS,IAAI,SAAS;IAItB,wDAAwD;IACxD,WAAW,IAAI,WAAW;IAI1B,kDAAkD;IAClD,IAAI,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS;CAGrC"}
|
package/dist/xhpke.d.ts
CHANGED
|
@@ -46,18 +46,18 @@ export declare class PublicKey {
|
|
|
46
46
|
/** Converts a public key into a 1216-byte array. */
|
|
47
47
|
toBytes(): Uint8Array;
|
|
48
48
|
/** Serializes a public key into a PEM string. */
|
|
49
|
-
toPem():
|
|
49
|
+
toPem(): string;
|
|
50
50
|
/** Returns a 256-bit unique identifier for this key (SHA256 of raw public key). */
|
|
51
|
-
fingerprint():
|
|
51
|
+
fingerprint(): Fingerprint;
|
|
52
52
|
/**
|
|
53
53
|
* Creates an HPKE sender context for multi-message encryption to this
|
|
54
54
|
* public key. Returns a stateful Sender and the 1120-byte encapsulated
|
|
55
55
|
* key that must be transmitted to the recipient.
|
|
56
56
|
*/
|
|
57
|
-
newSender(domain: Uint8Array):
|
|
57
|
+
newSender(domain: Uint8Array): {
|
|
58
58
|
sender: Sender;
|
|
59
59
|
encapKey: Uint8Array;
|
|
60
|
-
}
|
|
60
|
+
};
|
|
61
61
|
/**
|
|
62
62
|
* Seal (encrypt) a message to this public key.
|
|
63
63
|
*
|
|
@@ -66,7 +66,7 @@ export declare class PublicKey {
|
|
|
66
66
|
* @param domain - Application domain for context separation
|
|
67
67
|
* @returns Sealed data (encapsulated key + ciphertext)
|
|
68
68
|
*/
|
|
69
|
-
seal(msgToSeal: Uint8Array, msgToAuth: Uint8Array, domain: Uint8Array):
|
|
69
|
+
seal(msgToSeal: Uint8Array, msgToAuth: Uint8Array, domain: Uint8Array): Uint8Array;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* SecretKey contains an X-Wing private key for hybrid post-quantum encryption.
|
|
@@ -86,15 +86,15 @@ export declare class SecretKey {
|
|
|
86
86
|
/** Converts a private key into a 32-byte seed. */
|
|
87
87
|
toBytes(): Uint8Array;
|
|
88
88
|
/** Serializes a private key into a PEM string. */
|
|
89
|
-
toPem():
|
|
89
|
+
toPem(): string;
|
|
90
90
|
/** Retrieves the public counterpart of the secret key. */
|
|
91
|
-
publicKey():
|
|
91
|
+
publicKey(): PublicKey;
|
|
92
92
|
/** Returns a 256-bit unique identifier for this key (SHA256 of raw public key). */
|
|
93
|
-
fingerprint():
|
|
93
|
+
fingerprint(): Fingerprint;
|
|
94
94
|
/**
|
|
95
95
|
* Creates an HPKE receiver context for multi-message decryption.
|
|
96
96
|
*/
|
|
97
|
-
newReceiver(encapKey: Uint8Array, domain: Uint8Array):
|
|
97
|
+
newReceiver(encapKey: Uint8Array, domain: Uint8Array): Receiver;
|
|
98
98
|
/**
|
|
99
99
|
* Open (decrypt) a sealed message with this secret key.
|
|
100
100
|
*
|
|
@@ -103,7 +103,7 @@ export declare class SecretKey {
|
|
|
103
103
|
* @param domain - The same application domain used during sealing
|
|
104
104
|
* @returns The decrypted message
|
|
105
105
|
*/
|
|
106
|
-
open(sealed: Uint8Array, msgToAuth: Uint8Array, domain: Uint8Array):
|
|
106
|
+
open(sealed: Uint8Array, msgToAuth: Uint8Array, domain: Uint8Array): Uint8Array;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Sender is a stateful HPKE encryption context for multi-message
|
|
@@ -114,7 +114,7 @@ export declare class Sender {
|
|
|
114
114
|
/** @internal */
|
|
115
115
|
constructor(inner: WasmSender);
|
|
116
116
|
/** Encrypts a message using the next nonce in the sequence. */
|
|
117
|
-
seal(msgToSeal: Uint8Array, msgToAuth: Uint8Array):
|
|
117
|
+
seal(msgToSeal: Uint8Array, msgToAuth: Uint8Array): Uint8Array;
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* Receiver is a stateful HPKE decryption context for multi-message
|
|
@@ -125,6 +125,6 @@ export declare class Receiver {
|
|
|
125
125
|
/** @internal */
|
|
126
126
|
constructor(inner: WasmReceiver);
|
|
127
127
|
/** Decrypts a message using the next nonce in the sequence. */
|
|
128
|
-
open(msgToOpen: Uint8Array, msgToAuth: Uint8Array):
|
|
128
|
+
open(msgToOpen: Uint8Array, msgToAuth: Uint8Array): Uint8Array;
|
|
129
129
|
}
|
|
130
130
|
//# sourceMappingURL=xhpke.d.ts.map
|
package/dist/xhpke.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xhpke.d.ts","sourceRoot":"","sources":["../src/xhpke.ts"],"names":[],"mappings":"AAMA,
|
|
1
|
+
{"version":3,"file":"xhpke.d.ts","sourceRoot":"","sources":["../src/xhpke.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,cAAc,IAAI,aAAa,EAC/B,cAAc,IAAI,aAAa,EAC/B,gBAAgB,IAAI,eAAe,EACnC,WAAW,IAAI,UAAU,EACzB,aAAa,IAAI,YAAY,EAC9B,MAAM,+BAA+B,CAAC;AAGvC,iDAAiD;AACjD,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,8CAA8C;AAC9C,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,oDAAoD;AACpD,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAQD;AAED;;;GAGG;AACH,qBAAa,WAAW;IACtB,gBAAgB;IAChB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAEhC,gBAAgB;gBACJ,KAAK,EAAE,eAAe;IAIlC,kDAAkD;WACrC,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IAK/D,mDAAmD;IACnD,OAAO,IAAI,UAAU;CA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AM,EAAE,UAAU,GAAG,QAAQ;IAI/D;;;;;;;OAOG;IACH,IAAI,CACF,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,UAAU,GACjB,UAAU;CAGd;AAED;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IAEnC,gBAAgB;gBACJ,KAAK,EAAE,UAAU;IAI7B,+DAA+D;IAC/D,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU;CAG/D;AAED;;;GAGG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IAErC,gBAAgB;gBACJ,KAAK,EAAE,YAAY;IAI/B,+DAA+D;IAC/D,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU;CAG/D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkbio/crypto",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"author": "Péter Szilágyi <peter@dark.bio>",
|
|
5
5
|
"description": "Cryptography primitives and wrappers",
|
|
6
6
|
"repository": {
|
|
@@ -22,22 +22,23 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build:wasm": "wasm-pack build crates/wasm --target web --out-dir ../../src/wasm",
|
|
25
|
-
"build:ts": "tsc && vite build",
|
|
25
|
+
"build:ts": "node node_modules/typescript/bin/tsc && vite build",
|
|
26
26
|
"build": "npm run build:wasm && npm run build:ts",
|
|
27
27
|
"test": "vitest",
|
|
28
|
-
"test:browser": "vitest --browser.enabled --browser.name=chromium
|
|
29
|
-
"check": "tsc --noEmit"
|
|
28
|
+
"test:browser": "vitest --browser.enabled --browser.name=chromium",
|
|
29
|
+
"check": "node node_modules/typescript/bin/tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"cborg": "^
|
|
32
|
+
"cborg": "^6.1.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"playwright": "^
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"vite
|
|
40
|
-
"
|
|
35
|
+
"@typescript/typescript6": "^6.0.2",
|
|
36
|
+
"@vitest/browser-playwright": "^5.0.0",
|
|
37
|
+
"playwright": "^1.62.1",
|
|
38
|
+
"typescript": "^7.0.2",
|
|
39
|
+
"vite": "^8.2.2",
|
|
40
|
+
"vite-plugin-dts": "^5.1.0",
|
|
41
|
+
"vitest": "^5.0.0"
|
|
41
42
|
},
|
|
42
43
|
"keywords": [
|
|
43
44
|
"cryptography",
|