hpke 1.1.5 → 1.1.6

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/index.d.ts CHANGED
@@ -1900,14 +1900,15 @@ export declare const AEAD_ChaCha20Poly1305: AEADFactory;
1900
1900
  * Depends on one of the following Web Cryptography algorithm sets being supported in the runtime:
1901
1901
  *
1902
1902
  * - MLKEM768-X25519 key encapsulation
1903
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient for key derivation
1903
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation
1904
1904
  *
1905
1905
  * Or:
1906
1906
  *
1907
1907
  * - ML-KEM-768 key encapsulation
1908
1908
  * - X25519 key agreement
1909
1909
  * - SHA3-256 digest
1910
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for seed expansion
1910
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation and
1911
+ * composite-key seed expansion
1911
1912
  *
1912
1913
  * This is a factory function that must be passed to the {@link CipherSuite} constructor.
1913
1914
  *
@@ -1925,14 +1926,15 @@ export declare const KEM_MLKEM768_X25519: KEMFactory;
1925
1926
  * Depends on one of the following Web Cryptography algorithm sets being supported in the runtime:
1926
1927
  *
1927
1928
  * - MLKEM768-P256 key encapsulation
1928
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient for key derivation
1929
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation
1929
1930
  *
1930
1931
  * Or:
1931
1932
  *
1932
1933
  * - ML-KEM-768 key encapsulation
1933
1934
  * - ECDH with P-256 curve
1934
1935
  * - SHA3-256 digest
1935
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for seed expansion
1936
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation and
1937
+ * composite-key seed expansion
1936
1938
  *
1937
1939
  * This is a factory function that must be passed to the {@link CipherSuite} constructor.
1938
1940
  *
@@ -1950,14 +1952,15 @@ export declare const KEM_MLKEM768_P256: KEMFactory;
1950
1952
  * Depends on one of the following Web Cryptography algorithm sets being supported in the runtime:
1951
1953
  *
1952
1954
  * - MLKEM1024-P384 key encapsulation
1953
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient for key derivation
1955
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation
1954
1956
  *
1955
1957
  * Or:
1956
1958
  *
1957
1959
  * - ML-KEM-1024 key encapsulation
1958
1960
  * - ECDH with P-384 curve
1959
1961
  * - SHA3-256 digest
1960
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for seed expansion
1962
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation and
1963
+ * composite-key seed expansion
1961
1964
  *
1962
1965
  * This is a factory function that must be passed to the {@link CipherSuite} constructor.
1963
1966
  *
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAqEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,cAAM,aAAa;;gBAWf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,UAAU,EACf,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,UAAU;IAU7B;;;;OAIG;IACH,IAAI,IAAI,IAAI,IAAI,CAEf;IAED;;;;;OAKG;IACH,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAyBxE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,MAAM,CAAC,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI9E;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;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,EAAE,UAAU,CAAC,SAAS,CAQhD,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,EAAE,UAAU,CAAC,SAAS,CAQjD,CAAA;AA2ED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAY9B,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,EAAE,WAY9B,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,EAAE,WAanC,CAAA;AAmYD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAiCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB,EAAE,UAgC/B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAiChC,CAAA"}
package/index.js CHANGED
@@ -1519,22 +1519,23 @@ export function encode(string ) {
1519
1519
 
1520
1520
 
1521
1521
 
1522
- const L_HPKE_v1 = encode('HPKE-v1')
1523
- const L_HPKE = encode('HPKE')
1524
- const L_KEM = encode('KEM')
1525
- const L_sec = encode('sec')
1526
- const L_secret = encode('secret')
1527
- const L_key = encode('key')
1528
- const L_base_nonce = encode('base_nonce')
1529
- const L_exp = encode('exp')
1530
- const L_psk_id_hash = encode('psk_id_hash')
1531
- const L_info_hash = encode('info_hash')
1532
- const L_dkp_prk = encode('dkp_prk')
1533
- const L_candidate = encode('candidate')
1534
- const L_eae_prk = encode('eae_prk')
1535
- const L_shared_secret = encode('shared_secret')
1536
- const L_sk = encode('sk')
1537
- const L_DeriveKeyPair = encode('DeriveKeyPair')
1522
+ const L_HPKE_v1 = /* @__PURE__ */ encode('HPKE-v1')
1523
+ const L_HPKE = /* @__PURE__ */ encode('HPKE')
1524
+ const L_KEM = /* @__PURE__ */ encode('KEM')
1525
+ const L_sec = /* @__PURE__ */ encode('sec')
1526
+ const L_secret = /* @__PURE__ */ encode('secret')
1527
+ const L_key = /* @__PURE__ */ encode('key')
1528
+ const L_base_nonce = /* @__PURE__ */ encode('base_nonce')
1529
+ const L_exp = /* @__PURE__ */ encode('exp')
1530
+ const L_psk_id_hash = /* @__PURE__ */ encode('psk_id_hash')
1531
+ const L_info_hash = /* @__PURE__ */ encode('info_hash')
1532
+ const L_dkp_prk = /* @__PURE__ */ encode('dkp_prk')
1533
+ const L_candidate = /* @__PURE__ */ encode('candidate')
1534
+ const L_eae_prk = /* @__PURE__ */ encode('eae_prk')
1535
+ const L_shared_secret = /* @__PURE__ */ encode('shared_secret')
1536
+ const L_sk = /* @__PURE__ */ encode('sk')
1537
+ const L_public_key_recovery = /* @__PURE__ */ encode('HPKE public key recovery')
1538
+ const L_DeriveKeyPair = /* @__PURE__ */ encode('DeriveKeyPair')
1538
1539
 
1539
1540
  function lengthPrefixed(x ) {
1540
1541
  return concat(I2OSP(x.byteLength, 2), x)
@@ -2986,138 +2987,106 @@ async function CurveKeyFromD(
2986
2987
 
2987
2988
 
2988
2989
 
2989
- function mod(a , p ) {
2990
- const r = a % p
2991
- return r < 0n ? r + p : r
2992
- }
2993
-
2994
-
2995
- function modInverse(a , m ) {
2996
- a = ((a % m) + m) % m
2997
- let [t, newT] = [0n, 1n]
2998
- let [r, newR] = [m, a]
2999
-
3000
- while (newR !== 0n) {
3001
- const quotient = r / newR
3002
- ;[t, newT] = [newT, t - quotient * newT]
3003
- ;[r, newR] = [newR, r - quotient * newR]
3004
- }
3005
-
3006
- if (r > 1n) throw new Error('a is not invertible')
3007
- if (t < 0n) t = t + m
3008
- return t
3009
- }
3010
-
3011
- function jDouble(p , P , a ) {
3012
- const [X, Y, Z] = p
3013
- if (Y === 0n) return [1n, 1n, 0n]
3014
- const Y2 = mod(Y * Y, P)
3015
- const S = mod(4n * X * Y2, P)
3016
- const Z2 = mod(Z * Z, P)
3017
- const M = mod(3n * X * X + a * Z2 * Z2, P)
3018
- const X3 = mod(M * M - 2n * S, P)
3019
- return [X3, mod(M * (S - X3) - 8n * Y2 * Y2, P), mod(2n * Y * Z, P)]
3020
- }
3021
-
3022
- function jAdd(p , q , P , a ) {
3023
- if (p[2] === 0n) return q
3024
- if (q[2] === 0n) return p
3025
- const pZ2 = mod(p[2] * p[2], P)
3026
- const qZ2 = mod(q[2] * q[2], P)
3027
- const U1 = mod(p[0] * qZ2, P)
3028
- const U2 = mod(q[0] * pZ2, P)
3029
- const S1 = mod(p[1] * qZ2 * q[2], P)
3030
- const S2 = mod(q[1] * pZ2 * p[2], P)
3031
- if (U1 === U2) return S1 === S2 ? jDouble(p, P, a) : [1n, 1n, 0n]
3032
- const H = mod(U2 - U1, P)
3033
- const R = mod(S2 - S1, P)
3034
- const H2 = mod(H * H, P)
3035
- const H3 = mod(H * H2, P)
3036
- const U1H2 = mod(U1 * H2, P)
3037
- const X3 = mod(R * R - H3 - 2n * U1H2, P)
3038
- return [X3, mod(R * (U1H2 - X3) - S1 * H3, P), mod(H * p[2] * q[2], P)]
3039
- }
3040
-
3041
-
3042
-
3043
-
3044
-
3045
-
3046
2990
 
3047
2991
 
3048
- function scalarMult(k , G , prime , a , order ) {
3049
- if (k === 0n || k >= order) {
2992
+ async function importKeyNist(
2993
+ curve ,
2994
+ key ,
2995
+ name ,
2996
+ extractable ,
2997
+ includePublicKey ,
2998
+ ) {
2999
+ const d = OS2IP(key)
3000
+ if (d === 0n || d >= curve.order) {
3050
3001
  throw new Error('Invalid scalar')
3051
3002
  }
3052
3003
 
3053
3004
 
3054
- const precomp = new Array(8)
3055
- const Gj = [G.x, G.y, 1n]
3056
- const G2 = jDouble(Gj, prime, a)
3057
- precomp[0] = Gj
3058
- for (let i = 1; i < 8; i++) precomp[i] = jAdd(precomp[i - 1] , G2, prime, a)
3059
-
3060
-
3061
- const naf = []
3062
- let s = k
3063
- while (s > 0n) {
3064
- if (s & 1n) {
3065
- let d = Number(s & 15n)
3066
- if (d >= 8) d -= 16
3067
- naf.push(d)
3068
- s -= BigInt(d)
3069
- } else {
3070
- naf.push(0)
3071
- }
3072
- s >>= 1n
3073
- }
3074
-
3075
- let r = [1n, 1n, 0n]
3076
- for (let i = naf.length - 1; i >= 0; i--) {
3077
- r = jDouble(r, prime, a)
3078
- const d = naf[i]
3079
- if (d > 0) r = jAdd(r, precomp[(d - 1) >> 1] , prime, a)
3080
- else if (d < 0) {
3081
- const t = precomp[(-d - 1) >> 1]
3082
- r = jAdd(r, [t[0], mod(-t[1], prime), t[2]], prime, a)
3005
+ const pkcs8 = concat(curve.pkcs8, key)
3006
+ return await subtle(async (c) => {
3007
+ async function fromJwk(jwk , privateKey ) {
3008
+ privateKey ??= await c.importKey('jwk', jwk, curve.algorithm, extractable, ['deriveBits'])
3009
+ delete jwk.d
3010
+ return {
3011
+ privateKey,
3012
+ publicKey: includePublicKey
3013
+ ? await c.importKey('jwk', jwk, curve.algorithm, true, [])
3014
+ : undefined,
3015
+ }
3083
3016
  }
3084
- }
3085
-
3086
- const zI = modInverse(r[2], prime)
3087
- const zI2 = mod(zI * zI, prime)
3088
- return { x: mod(r[0] * zI2, prime), y: mod(r[1] * zI2 * zI, prime) }
3089
- }
3090
-
3091
-
3092
3017
 
3018
+ let privateKey
3093
3019
 
3020
+ const nativePublicKey = typeof c.getPublicKey === 'function'
3021
+ try {
3022
+ privateKey = await c.importKey(
3023
+ 'pkcs8',
3024
+ pkcs8 ,
3025
+ curve.algorithm,
3026
+ nativePublicKey ? extractable : true,
3027
+ ['deriveBits'],
3028
+ )
3029
+ if (nativePublicKey) {
3094
3030
 
3095
3031
 
3032
+ const recovered = await c.getPublicKey(privateKey, [])
3033
+ return { privateKey, publicKey: includePublicKey ? recovered : undefined }
3034
+ }
3035
+ const { x, y, d } = await c.exportKey('jwk', privateKey)
3036
+ return fromJwk(
3037
+ { kty: 'EC', crv: curve.algorithm.namedCurve, x, y, d },
3038
+ extractable ? privateKey : undefined,
3039
+ )
3040
+ } catch (cause) {
3096
3041
 
3097
3042
 
3098
3043
 
3099
3044
 
3045
+ if (
3046
+ !(cause instanceof DOMException) ||
3047
+ (cause.name !== 'DataError' && cause.name !== 'OperationError')
3048
+ ) {
3049
+ throw cause
3050
+ }
3051
+ }
3100
3052
 
3053
+ const generator = {
3054
+ kty: 'EC',
3055
+ crv: curve.algorithm.namedCurve,
3056
+ x: toB64u(bigIntToUint8Array(curve.Gx, curve.Nsk)),
3057
+ y: toB64u(bigIntToUint8Array(curve.Gy, curve.Nsk)),
3058
+ }
3059
+ const jwk = { ...generator, d: toB64u(slice(pkcs8, curve.pkcs8.length)) }
3060
+ const signingAlgorithm = { name: 'ECDSA', namedCurve: curve.algorithm.namedCurve }
3061
+ const signingKey = privateKey
3062
+ ? await c.importKey('pkcs8', pkcs8 , signingAlgorithm, false, ['sign'])
3063
+ : await c.importKey('jwk', jwk, signingAlgorithm, false, ['sign'])
3064
+ privateKey ??= await c.importKey('jwk', jwk, curve.algorithm, false, ['deriveBits'])
3101
3065
 
3102
3066
 
3103
- function getPrivateJwkNist(DHKEM , d ) {
3104
3067
 
3105
- const G = { x: DHKEM.Gx, y: DHKEM.Gy }
3106
- const publicPoint = scalarMult(d, G, DHKEM.prime, DHKEM.prime - 3n, DHKEM.order)
3068
+ const generatorKey = await c.importKey('jwk', generator, curve.algorithm, true, [])
3069
+ const x = new Uint8Array(
3070
+ await c.deriveBits({ name: 'ECDH', public: generatorKey }, privateKey, curve.Nsk << 3),
3071
+ )
3107
3072
 
3108
- const coordSize = (DHKEM.Npk - 1) / 2
3109
- const xBytes = bigIntToUint8Array(publicPoint.x, coordSize)
3110
- const yBytes = bigIntToUint8Array(publicPoint.y, coordSize)
3111
- const dBytes = bigIntToUint8Array(d, DHKEM.Nsk)
3112
3073
 
3113
3074
 
3114
- return {
3115
- kty: 'EC',
3116
- crv: DHKEM.algorithm.namedCurve,
3117
- x: toB64u(xBytes),
3118
- y: toB64u(yBytes),
3119
- d: toB64u(dBytes),
3120
- }
3075
+ const message = L_public_key_recovery
3076
+ const signatureAlgorithm = { name: 'ECDSA', hash: 'SHA-256' }
3077
+ const signature = await c.sign(signatureAlgorithm, signingKey, message)
3078
+ for (const prefix of [0x02, 0x03]) {
3079
+ const spki = concat(curve.spki, Uint8Array.of(prefix), x)
3080
+ const candidate = await c.importKey('spki', spki , signingAlgorithm, true, [
3081
+ 'verify',
3082
+ ])
3083
+ if (await c.verify(signatureAlgorithm, candidate, signature, message)) {
3084
+ const { x, y } = await c.exportKey('jwk', candidate)
3085
+ return fromJwk({ kty: 'EC', crv: generator.crv, d: jwk.d, x, y })
3086
+ }
3087
+ }
3088
+ throw new Error('Public key recovery failed')
3089
+ }, name)
3121
3090
  }
3122
3091
 
3123
3092
  async function DeserializePrivateKeyNist(
@@ -3125,15 +3094,7 @@ async function DeserializePrivateKeyNist(
3125
3094
  key ,
3126
3095
  extractable ,
3127
3096
  ) {
3128
- const d = OS2IP(key)
3129
- const jwk = getPrivateJwkNist(this, d)
3130
-
3131
- const privateKey = await subtle(
3132
- (c) => c.importKey('jwk', jwk, this.algorithm, extractable, ['deriveBits']),
3133
- this.name,
3134
- )
3135
-
3136
- return privateKey
3097
+ return (await importKeyNist(this, key, this.name, extractable, false)).privateKey
3137
3098
  }
3138
3099
 
3139
3100
 
@@ -3164,20 +3125,7 @@ async function GetKeyPairNist(
3164
3125
  extractable ,
3165
3126
  name ,
3166
3127
  ) {
3167
- const jwk = getPrivateJwkNist(curveConfig, OS2IP(sk))
3168
-
3169
- const privateKey = await subtle(
3170
- (c) => c.importKey('jwk', jwk, curveConfig.algorithm, extractable, ['deriveBits']),
3171
- name,
3172
- )
3173
-
3174
- delete jwk.d
3175
- const publicKey = await subtle(
3176
- (c) => c.importKey('jwk', jwk, curveConfig.algorithm, true, []),
3177
- name,
3178
- )
3179
-
3180
- return { privateKey, publicKey }
3128
+ return (await importKeyNist(curveConfig, sk, name, extractable, true))
3181
3129
  }
3182
3130
 
3183
3131
 
@@ -3200,7 +3148,8 @@ const P256 = {
3200
3148
  Nsk: 32,
3201
3149
  order: 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n,
3202
3150
  bitmask: 0xff,
3203
- prime: 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffffn,
3151
+ pkcs8: /* @__PURE__ */ Uint8Array.of(0x30, 0x41, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x04, 0x27, 0x30, 0x25, 0x02, 0x01, 0x01, 0x04, 0x20),
3152
+ spki: /* @__PURE__ */ Uint8Array.of(0x30, 0x39, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x22, 0x00),
3204
3153
  Gx: 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296n,
3205
3154
  Gy: 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5n,
3206
3155
  }
@@ -3255,8 +3204,8 @@ const P384 = {
3255
3204
  order:
3256
3205
  0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973n,
3257
3206
  bitmask: 0xff,
3258
- prime:
3259
- 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffffn,
3207
+ pkcs8: /* @__PURE__ */ Uint8Array.of(0x30, 0x4e, 0x02, 0x01, 0x00, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22, 0x04, 0x37, 0x30, 0x35, 0x02, 0x01, 0x01, 0x04, 0x30),
3208
+ spki: /* @__PURE__ */ Uint8Array.of(0x30, 0x46, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22, 0x03, 0x32, 0x00),
3260
3209
  Gx: 0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7n,
3261
3210
  Gy: 0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5fn,
3262
3211
  }
@@ -3311,8 +3260,8 @@ const P521 = {
3311
3260
  order:
3312
3261
  0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409n,
3313
3262
  bitmask: 0x01,
3314
- prime:
3315
- 0x01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn,
3263
+ pkcs8: /* @__PURE__ */ Uint8Array.of(0x30, 0x60, 0x02, 0x01, 0x00, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x23, 0x04, 0x49, 0x30, 0x47, 0x02, 0x01, 0x01, 0x04, 0x42),
3264
+ spki: /* @__PURE__ */ Uint8Array.of(0x30, 0x58, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x23, 0x03, 0x44, 0x00),
3316
3265
  Gx: 0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66n,
3317
3266
  Gy: 0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650n,
3318
3267
  }
@@ -3853,7 +3802,7 @@ const InvalidInvocation = (_ ) => {
3853
3802
  throw new Error('invalid invocation')
3854
3803
  }
3855
3804
  }
3856
- const priv = Symbol()
3805
+ const priv = /* @__PURE__ */ Symbol()
3857
3806
  class HybridKey {
3858
3807
  #algorithm
3859
3808
  #type
@@ -4250,6 +4199,7 @@ function createCompositeHybridKEM(parameters )
4250
4199
 
4251
4200
 
4252
4201
 
4202
+
4253
4203
 
4254
4204
 
4255
4205
  export const KEM_MLKEM768_X25519 = function () {
@@ -4309,6 +4259,7 @@ export const KEM_MLKEM768_X25519 = function ()
4309
4259
 
4310
4260
 
4311
4261
 
4262
+
4312
4263
 
4313
4264
 
4314
4265
  export const KEM_MLKEM768_P256 = function () {
@@ -4367,6 +4318,7 @@ export const KEM_MLKEM768_P256 = function ()
4367
4318
 
4368
4319
 
4369
4320
 
4321
+
4370
4322
 
4371
4323
 
4372
4324
  export const KEM_MLKEM1024_P384 = function () {
package/index.ts CHANGED
@@ -1519,22 +1519,23 @@ export function encode(string: string): Uint8Array {
1519
1519
  // Each is a freshly-allocated Uint8Array held as a constant to avoid repeating
1520
1520
  // the per-call `encode()` validation+allocation loop. These are only ever read
1521
1521
  // (and copied into concat() outputs), never mutated.
1522
- const L_HPKE_v1 = encode('HPKE-v1')
1523
- const L_HPKE = encode('HPKE')
1524
- const L_KEM = encode('KEM')
1525
- const L_sec = encode('sec')
1526
- const L_secret = encode('secret')
1527
- const L_key = encode('key')
1528
- const L_base_nonce = encode('base_nonce')
1529
- const L_exp = encode('exp')
1530
- const L_psk_id_hash = encode('psk_id_hash')
1531
- const L_info_hash = encode('info_hash')
1532
- const L_dkp_prk = encode('dkp_prk')
1533
- const L_candidate = encode('candidate')
1534
- const L_eae_prk = encode('eae_prk')
1535
- const L_shared_secret = encode('shared_secret')
1536
- const L_sk = encode('sk')
1537
- const L_DeriveKeyPair = encode('DeriveKeyPair')
1522
+ const L_HPKE_v1 = /* @__PURE__ */ encode('HPKE-v1')
1523
+ const L_HPKE = /* @__PURE__ */ encode('HPKE')
1524
+ const L_KEM = /* @__PURE__ */ encode('KEM')
1525
+ const L_sec = /* @__PURE__ */ encode('sec')
1526
+ const L_secret = /* @__PURE__ */ encode('secret')
1527
+ const L_key = /* @__PURE__ */ encode('key')
1528
+ const L_base_nonce = /* @__PURE__ */ encode('base_nonce')
1529
+ const L_exp = /* @__PURE__ */ encode('exp')
1530
+ const L_psk_id_hash = /* @__PURE__ */ encode('psk_id_hash')
1531
+ const L_info_hash = /* @__PURE__ */ encode('info_hash')
1532
+ const L_dkp_prk = /* @__PURE__ */ encode('dkp_prk')
1533
+ const L_candidate = /* @__PURE__ */ encode('candidate')
1534
+ const L_eae_prk = /* @__PURE__ */ encode('eae_prk')
1535
+ const L_shared_secret = /* @__PURE__ */ encode('shared_secret')
1536
+ const L_sk = /* @__PURE__ */ encode('sk')
1537
+ const L_public_key_recovery = /* @__PURE__ */ encode('HPKE public key recovery')
1538
+ const L_DeriveKeyPair = /* @__PURE__ */ encode('DeriveKeyPair')
1538
1539
 
1539
1540
  function lengthPrefixed(x: Uint8Array): Uint8Array {
1540
1541
  return concat(I2OSP(x.byteLength, 2), x)
@@ -2976,148 +2977,116 @@ async function CurveKeyFromD(
2976
2977
  // KEM (Key Encapsulation Mechanism) - DHKEM NIST Curve Implementations
2977
2978
  // ============================================================================
2978
2979
 
2979
- interface ECPoint {
2980
- x: bigint
2981
- y: bigint
2982
- }
2983
-
2984
- // Jacobian projective coordinates: (X, Y, Z) represents affine (X/Z², Y/Z³)
2985
- // Uses wNAF scalar multiplication - only one modular inverse at the very end.
2986
- type JP = [bigint, bigint, bigint] // [X, Y, Z]
2987
-
2988
- // Non-negative modular reduction
2989
- function mod(a: bigint, p: bigint): bigint {
2990
- const r = a % p
2991
- return r < 0n ? r + p : r
2992
- }
2993
-
2994
- // Modular inverse using Extended Euclidean Algorithm
2995
- function modInverse(a: bigint, m: bigint): bigint {
2996
- a = ((a % m) + m) % m
2997
- let [t, newT] = [0n, 1n]
2998
- let [r, newR] = [m, a]
2999
-
3000
- while (newR !== 0n) {
3001
- const quotient = r / newR
3002
- ;[t, newT] = [newT, t - quotient * newT]
3003
- ;[r, newR] = [newR, r - quotient * newR]
3004
- }
3005
-
3006
- if (r > 1n) throw new Error('a is not invertible')
3007
- if (t < 0n) t = t + m
3008
- return t
3009
- }
3010
-
3011
- function jDouble(p: JP, P: bigint, a: bigint): JP {
3012
- const [X, Y, Z] = p
3013
- if (Y === 0n) return [1n, 1n, 0n]
3014
- const Y2 = mod(Y * Y, P)
3015
- const S = mod(4n * X * Y2, P)
3016
- const Z2 = mod(Z * Z, P)
3017
- const M = mod(3n * X * X + a * Z2 * Z2, P)
3018
- const X3 = mod(M * M - 2n * S, P)
3019
- return [X3, mod(M * (S - X3) - 8n * Y2 * Y2, P), mod(2n * Y * Z, P)]
3020
- }
3021
-
3022
- function jAdd(p: JP, q: JP, P: bigint, a: bigint): JP {
3023
- if (p[2] === 0n) return q
3024
- if (q[2] === 0n) return p
3025
- const pZ2 = mod(p[2] * p[2], P)
3026
- const qZ2 = mod(q[2] * q[2], P)
3027
- const U1 = mod(p[0] * qZ2, P)
3028
- const U2 = mod(q[0] * pZ2, P)
3029
- const S1 = mod(p[1] * qZ2 * q[2], P)
3030
- const S2 = mod(q[1] * pZ2 * p[2], P)
3031
- if (U1 === U2) return S1 === S2 ? jDouble(p, P, a) : [1n, 1n, 0n]
3032
- const H = mod(U2 - U1, P)
3033
- const R = mod(S2 - S1, P)
3034
- const H2 = mod(H * H, P)
3035
- const H3 = mod(H * H2, P)
3036
- const U1H2 = mod(U1 * H2, P)
3037
- const X3 = mod(R * R - H3 - 2n * U1H2, P)
3038
- return [X3, mod(R * (U1H2 - X3) - S1 * H3, P), mod(H * p[2] * q[2], P)]
3039
- }
3040
-
3041
- // Scalar multiplication using wNAF with Jacobian coordinates: k * G
3042
- //
3043
- // This is used to compute the public key from a private scalar for NIST curves so that
3044
- // the private key can be imported via JWK. Importing via PKCS8 (which would avoid the need
3045
- // for computing the public key) is not viable cross-browser:
3046
- // - WebKit: https://bugs.webkit.org/show_bug.cgi?id=302707
3047
- // - Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=2000795
3048
- function scalarMult(k: bigint, G: ECPoint, prime: bigint, a: bigint, order: bigint): ECPoint {
3049
- if (k === 0n || k >= order) {
3050
- throw new Error('Invalid scalar')
3051
- }
3052
-
3053
- // Precompute odd multiples: 1G, 3G, 5G, 7G, 9G, 11G, 13G, 15G
3054
- const precomp: JP[] = new Array(8)
3055
- const Gj: JP = [G.x, G.y, 1n]
3056
- const G2 = jDouble(Gj, prime, a)
3057
- precomp[0] = Gj
3058
- for (let i = 1; i < 8; i++) precomp[i] = jAdd(precomp[i - 1]!, G2, prime, a)
3059
-
3060
- // wNAF encoding (w=4)
3061
- const naf: number[] = []
3062
- let s = k
3063
- while (s > 0n) {
3064
- if (s & 1n) {
3065
- let d = Number(s & 15n)
3066
- if (d >= 8) d -= 16
3067
- naf.push(d)
3068
- s -= BigInt(d)
3069
- } else {
3070
- naf.push(0)
3071
- }
3072
- s >>= 1n
3073
- }
3074
-
3075
- let r: JP = [1n, 1n, 0n]
3076
- for (let i = naf.length - 1; i >= 0; i--) {
3077
- r = jDouble(r, prime, a)
3078
- const d = naf[i]!
3079
- if (d > 0) r = jAdd(r, precomp[(d - 1) >> 1]!, prime, a)
3080
- else if (d < 0) {
3081
- const t = precomp[(-d - 1) >> 1]!
3082
- r = jAdd(r, [t[0], mod(-t[1], prime), t[2]], prime, a)
3083
- }
3084
- }
3085
-
3086
- const zI = modInverse(r[2], prime)
3087
- const zI2 = mod(zI * zI, prime)
3088
- return { x: mod(r[0] * zI2, prime), y: mod(r[1] * zI2 * zI, prime) }
3089
- }
3090
-
3091
2980
  interface NistCurveConfig {
3092
2981
  order: bigint
3093
2982
  bitmask: number
3094
- prime: bigint
3095
2983
  Gx: bigint
3096
2984
  Gy: bigint
2985
+ pkcs8: Uint8Array
2986
+ spki: Uint8Array
3097
2987
  algorithm: EcKeyAlgorithm
3098
2988
  Npk: number
3099
2989
  Nsk: number
3100
2990
  }
3101
2991
 
3102
- // Helper function to compute public key and create JWK for NIST curves
3103
- function getPrivateJwkNist(DHKEM: NistCurveConfig, d: bigint): JsonWebKey {
3104
- // Perform scalar multiplication: publicKey = d * G
3105
- const G: ECPoint = { x: DHKEM.Gx, y: DHKEM.Gy }
3106
- const publicPoint = scalarMult(d, G, DHKEM.prime, DHKEM.prime - 3n, DHKEM.order)
2992
+ async function importKeyNist(
2993
+ curve: NistCurveConfig,
2994
+ key: Uint8Array,
2995
+ name: string,
2996
+ extractable: boolean,
2997
+ includePublicKey: boolean,
2998
+ ): Promise<{ privateKey: CryptoKey; publicKey?: CryptoKey }> {
2999
+ const d = OS2IP(key)
3000
+ if (d === 0n || d >= curve.order) {
3001
+ throw new Error('Invalid scalar')
3002
+ }
3003
+
3004
+ // Copy before awaiting, including when key is a Node.js Buffer.
3005
+ const pkcs8 = concat(curve.pkcs8, key)
3006
+ return await subtle(async (c) => {
3007
+ async function fromJwk(jwk: JsonWebKey, privateKey?: CryptoKey) {
3008
+ privateKey ??= await c.importKey('jwk', jwk, curve.algorithm, extractable, ['deriveBits'])
3009
+ delete jwk.d
3010
+ return {
3011
+ privateKey,
3012
+ publicKey: includePublicKey
3013
+ ? await c.importKey('jwk', jwk, curve.algorithm, true, [])
3014
+ : undefined,
3015
+ }
3016
+ }
3017
+
3018
+ let privateKey: CryptoKey | undefined
3019
+ // @ts-expect-error
3020
+ const nativePublicKey = typeof c.getPublicKey === 'function'
3021
+ try {
3022
+ privateKey = await c.importKey(
3023
+ 'pkcs8',
3024
+ pkcs8 as BufferSource,
3025
+ curve.algorithm,
3026
+ nativePublicKey ? extractable : true,
3027
+ ['deriveBits'],
3028
+ )
3029
+ if (nativePublicKey) {
3030
+ // Also establish that scalar-only import recovered a usable public point.
3031
+ // @ts-expect-error
3032
+ const recovered = await c.getPublicKey(privateKey, [])
3033
+ return { privateKey, publicKey: includePublicKey ? recovered : undefined }
3034
+ }
3035
+ const { x, y, d } = await c.exportKey('jwk', privateKey)
3036
+ return fromJwk(
3037
+ { kty: 'EC', crv: curve.algorithm.namedCurve, x, y, d },
3038
+ extractable ? privateKey : undefined,
3039
+ )
3040
+ } catch (cause) {
3041
+ // WebKit requires public coordinates on import; Firefox cannot export them
3042
+ // from a scalar-only PKCS8 key. Other errors must not trigger recovery.
3043
+ // https://bugs.webkit.org/show_bug.cgi?id=302707
3044
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=2000795
3045
+ if (
3046
+ !(cause instanceof DOMException) ||
3047
+ (cause.name !== 'DataError' && cause.name !== 'OperationError')
3048
+ ) {
3049
+ throw cause
3050
+ }
3051
+ }
3107
3052
 
3108
- const coordSize = (DHKEM.Npk - 1) / 2
3109
- const xBytes = bigIntToUint8Array(publicPoint.x, coordSize)
3110
- const yBytes = bigIntToUint8Array(publicPoint.y, coordSize)
3111
- const dBytes = bigIntToUint8Array(d, DHKEM.Nsk)
3053
+ const generator: JsonWebKey = {
3054
+ kty: 'EC',
3055
+ crv: curve.algorithm.namedCurve,
3056
+ x: toB64u(bigIntToUint8Array(curve.Gx, curve.Nsk)),
3057
+ y: toB64u(bigIntToUint8Array(curve.Gy, curve.Nsk)),
3058
+ }
3059
+ const jwk = { ...generator, d: toB64u(slice(pkcs8, curve.pkcs8.length)) }
3060
+ const signingAlgorithm = { name: 'ECDSA', namedCurve: curve.algorithm.namedCurve }
3061
+ const signingKey = privateKey
3062
+ ? await c.importKey('pkcs8', pkcs8 as BufferSource, signingAlgorithm, false, ['sign'])
3063
+ : await c.importKey('jwk', jwk, signingAlgorithm, false, ['sign'])
3064
+ privateKey ??= await c.importKey('jwk', jwk, curve.algorithm, false, ['deriveBits'])
3065
+
3066
+ // ECDH(d, G) gives x(dG). WebKit preserves the supplied generator coordinates
3067
+ // on export, so the temporary private keys must never escape this function.
3068
+ const generatorKey = await c.importKey('jwk', generator, curve.algorithm, true, [])
3069
+ const x = new Uint8Array(
3070
+ await c.deriveBits({ name: 'ECDH', public: generatorKey }, privateKey, curve.Nsk << 3),
3071
+ )
3112
3072
 
3113
- // Create JWK for private key import (browsers need x, y, d for private key import)
3114
- return {
3115
- kty: 'EC',
3116
- crv: DHKEM.algorithm.namedCurve,
3117
- x: toB64u(xBytes),
3118
- y: toB64u(yBytes),
3119
- d: toB64u(dBytes),
3120
- }
3073
+ // Compressed SPKI import recovers each possible y. An ECDSA signature selects
3074
+ // the point corresponding to d, without performing EC arithmetic in JavaScript.
3075
+ const message = L_public_key_recovery as BufferSource
3076
+ const signatureAlgorithm = { name: 'ECDSA', hash: 'SHA-256' }
3077
+ const signature = await c.sign(signatureAlgorithm, signingKey, message)
3078
+ for (const prefix of [0x02, 0x03]) {
3079
+ const spki = concat(curve.spki, Uint8Array.of(prefix), x)
3080
+ const candidate = await c.importKey('spki', spki as BufferSource, signingAlgorithm, true, [
3081
+ 'verify',
3082
+ ])
3083
+ if (await c.verify(signatureAlgorithm, candidate, signature, message)) {
3084
+ const { x, y } = await c.exportKey('jwk', candidate)
3085
+ return fromJwk({ kty: 'EC', crv: generator.crv, d: jwk.d, x, y })
3086
+ }
3087
+ }
3088
+ throw new Error('Public key recovery failed')
3089
+ }, name)
3121
3090
  }
3122
3091
 
3123
3092
  async function DeserializePrivateKeyNist(
@@ -3125,15 +3094,7 @@ async function DeserializePrivateKeyNist(
3125
3094
  key: Uint8Array,
3126
3095
  extractable: boolean,
3127
3096
  ) {
3128
- const d = OS2IP(key)
3129
- const jwk = getPrivateJwkNist(this, d)
3130
-
3131
- const privateKey = await subtle(
3132
- (c) => c.importKey('jwk', jwk, this.algorithm, extractable, ['deriveBits']),
3133
- this.name,
3134
- )
3135
-
3136
- return privateKey
3097
+ return (await importKeyNist(this, key, this.name, extractable, false)).privateKey
3137
3098
  }
3138
3099
 
3139
3100
  /** @see [DeriveKeyPair](https://datatracker.ietf.org/doc/html/draft-ietf-hpke-hpke-04.html#section-7.1.3) */
@@ -3164,20 +3125,7 @@ async function GetKeyPairNist(
3164
3125
  extractable: boolean,
3165
3126
  name: string,
3166
3127
  ) {
3167
- const jwk = getPrivateJwkNist(curveConfig, OS2IP(sk))
3168
-
3169
- const privateKey = await subtle(
3170
- (c) => c.importKey('jwk', jwk, curveConfig.algorithm, extractable, ['deriveBits']),
3171
- name,
3172
- )
3173
-
3174
- delete jwk.d
3175
- const publicKey = await subtle(
3176
- (c) => c.importKey('jwk', jwk, curveConfig.algorithm, true, []),
3177
- name,
3178
- )
3179
-
3180
- return { privateKey, publicKey }
3128
+ return (await importKeyNist(curveConfig, sk, name, extractable, true)) as CryptoKeyPair
3181
3129
  }
3182
3130
 
3183
3131
  // ============================================================================
@@ -3200,7 +3148,8 @@ const P256: NistCurveConfig = {
3200
3148
  Nsk: 32,
3201
3149
  order: 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551n,
3202
3150
  bitmask: 0xff,
3203
- prime: 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffffn,
3151
+ pkcs8: /* @__PURE__ */ Uint8Array.of(0x30, 0x41, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x04, 0x27, 0x30, 0x25, 0x02, 0x01, 0x01, 0x04, 0x20), // prettier-ignore
3152
+ spki: /* @__PURE__ */ Uint8Array.of(0x30, 0x39, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x22, 0x00), // prettier-ignore
3204
3153
  Gx: 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296n,
3205
3154
  Gy: 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5n,
3206
3155
  }
@@ -3255,8 +3204,8 @@ const P384: NistCurveConfig = {
3255
3204
  order:
3256
3205
  0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973n,
3257
3206
  bitmask: 0xff,
3258
- prime:
3259
- 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffffn,
3207
+ pkcs8: /* @__PURE__ */ Uint8Array.of(0x30, 0x4e, 0x02, 0x01, 0x00, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22, 0x04, 0x37, 0x30, 0x35, 0x02, 0x01, 0x01, 0x04, 0x30), // prettier-ignore
3208
+ spki: /* @__PURE__ */ Uint8Array.of(0x30, 0x46, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22, 0x03, 0x32, 0x00), // prettier-ignore
3260
3209
  Gx: 0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7n,
3261
3210
  Gy: 0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5fn,
3262
3211
  }
@@ -3311,8 +3260,8 @@ const P521: NistCurveConfig = {
3311
3260
  order:
3312
3261
  0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409n,
3313
3262
  bitmask: 0x01,
3314
- prime:
3315
- 0x01ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn,
3263
+ pkcs8: /* @__PURE__ */ Uint8Array.of(0x30, 0x60, 0x02, 0x01, 0x00, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x23, 0x04, 0x49, 0x30, 0x47, 0x02, 0x01, 0x01, 0x04, 0x42), // prettier-ignore
3264
+ spki: /* @__PURE__ */ Uint8Array.of(0x30, 0x58, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x23, 0x03, 0x44, 0x00), // prettier-ignore
3316
3265
  Gx: 0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66n,
3317
3266
  Gy: 0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650n,
3318
3267
  }
@@ -3853,7 +3802,7 @@ const InvalidInvocation = (_: typeof priv) => {
3853
3802
  throw new Error('invalid invocation')
3854
3803
  }
3855
3804
  }
3856
- const priv = Symbol()
3805
+ const priv = /* @__PURE__ */ Symbol()
3857
3806
  class HybridKey implements Key {
3858
3807
  #algorithm: KeyAlgorithm
3859
3808
  #type: 'public' | 'private'
@@ -4234,14 +4183,15 @@ function createCompositeHybridKEM(parameters: CompositeHybridKEMParams): Composi
4234
4183
  * Depends on one of the following Web Cryptography algorithm sets being supported in the runtime:
4235
4184
  *
4236
4185
  * - MLKEM768-X25519 key encapsulation
4237
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient for key derivation
4186
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation
4238
4187
  *
4239
4188
  * Or:
4240
4189
  *
4241
4190
  * - ML-KEM-768 key encapsulation
4242
4191
  * - X25519 key agreement
4243
4192
  * - SHA3-256 digest
4244
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for seed expansion
4193
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation and
4194
+ * composite-key seed expansion
4245
4195
  *
4246
4196
  * This is a factory function that must be passed to the {@link CipherSuite} constructor.
4247
4197
  *
@@ -4293,14 +4243,15 @@ export const KEM_MLKEM768_X25519: KEMFactory = function (): CompositeHybridKEM |
4293
4243
  * Depends on one of the following Web Cryptography algorithm sets being supported in the runtime:
4294
4244
  *
4295
4245
  * - MLKEM768-P256 key encapsulation
4296
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient for key derivation
4246
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation
4297
4247
  *
4298
4248
  * Or:
4299
4249
  *
4300
4250
  * - ML-KEM-768 key encapsulation
4301
4251
  * - ECDH with P-256 curve
4302
4252
  * - SHA3-256 digest
4303
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for seed expansion
4253
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation and
4254
+ * composite-key seed expansion
4304
4255
  *
4305
4256
  * This is a factory function that must be passed to the {@link CipherSuite} constructor.
4306
4257
  *
@@ -4351,14 +4302,15 @@ export const KEM_MLKEM768_P256: KEMFactory = function (): CompositeHybridKEM | D
4351
4302
  * Depends on one of the following Web Cryptography algorithm sets being supported in the runtime:
4352
4303
  *
4353
4304
  * - MLKEM1024-P384 key encapsulation
4354
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient for key derivation
4305
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation
4355
4306
  *
4356
4307
  * Or:
4357
4308
  *
4358
4309
  * - ML-KEM-1024 key encapsulation
4359
4310
  * - ECDH with P-384 curve
4360
4311
  * - SHA3-256 digest
4361
- * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for seed expansion
4312
+ * - SHAKE256 (cSHAKE256 without any parameters) digest on the recipient side for key derivation and
4313
+ * composite-key seed expansion
4362
4314
  *
4363
4315
  * This is a factory function that must be passed to the {@link CipherSuite} constructor.
4364
4316
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hpke",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Hybrid Public Key Encryption (HPKE) for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
5
5
  "keywords": [
6
6
  "browser",