@@ -174,6 +174,31 @@ You can import an ``ECKey`` from string, bytes and a JWK (in dict).
174174 " d" : " Hndv7ZZjs_ke8o9zXYo3iq-Yr8SewI5vrqd0pAvEPqg"
175175 })
176176
177+ Derive an "EC" Key
178+ ~~~~~~~~~~~~~~~~~~
179+
180+ ``joserfc `` provides deterministic key derivation helpers for EC key.
181+ This method allows applications to derive a *stable * JWK from an application
182+ secret (for example, ``SECRET_KEY `` in a web framework), while still producing
183+ valid cryptographic keys for use in JWS/JWE.
184+
185+ .. code-block :: python
186+
187+ from joserfc.jwk import ECKey
188+
189+ ECKey.derive_key(" your-secret-key" , " P-256" )
190+ ECKey.derive_key(" your-secret-key" , " P-256" , kdf_name = " HKDF" )
191+
192+ Supported key derivation functions:
193+
194+ - **HKDF ** (recommended)
195+ - **PBKDF2 ** (password-based, may require higher iteration counts)
196+
197+ .. warning ::
198+ Deterministic keys are useful for applications that want a stable default JWK,
199+ but **they should not be used where random key generation is required **.
200+
201+
177202.. _OKPKey :
178203
179204OKPKey
@@ -224,6 +249,24 @@ You can import an ``OKPKey`` from string, bytes and a JWK (in dict).
224249 " kid" : " 5V_IcL-iX5IbaNz9vg0CjXtWLZiJ94-ESnHI-HN1L2Y"
225250 })
226251
252+ Derive an "OKP" Key
253+ ~~~~~~~~~~~~~~~~~~~
254+
255+ Just like above ``ECKey ``, ``joserfc `` provides a ``OKPKey.derive_key `` method
256+ to derive a *stable * JWK.
257+
258+ .. code-block :: python
259+
260+ from joserfc.jwk import OKPKey
261+
262+ OKPKey.derive_key(" your-secret-key" , " Ed25519" )
263+ OKPKey.derive_key(" your-secret-key" , " Ed25519" , kdf_name = " HKDF" )
264+
265+ Supported key derivation functions:
266+
267+ - **HKDF ** (recommended)
268+ - **PBKDF2 ** (password-based, may require higher iteration counts)
269+
227270Key Set
228271-------
229272
0 commit comments