Skip to content

Commit 2b97de1

Browse files
committed
RSA: crypto.derive
1 parent 38957b2 commit 2b97de1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/Runtime Environment/Crypto.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,25 @@ print(dumpvar(priv))
398398
--> }
399399
```
400400

401+
### `crypto.derive`
402+
Derives a public key from a private key.
403+
#### Parameters
404+
1. `mode` — Must be "rsa".
405+
2. `key` — The private key containing `p` and `q`.
406+
#### Returns
407+
The public key corresponding to the private key.
408+
```pluto
409+
local { bigint, crypto } = require "pluto:*"
410+
411+
local priv = {
412+
p = new bigint("115443384115231951475820445136871322101870729500298182134363293112660251666017"),
413+
q = new bigint("98365361248415863235179644468056200977592391948608651522703704315152579004021"),
414+
}
415+
local pub = crypto.derive("rsa", priv)
416+
print(pub.n) --> 11355630182234424425429331560518598643298965915936825610957270519615363349759012613228119611304846673085167794661819394470107090216347491908311079792054357
417+
print(pub.e) --> 65537
418+
```
419+
401420
### `crypto.exportkey`
402421
Exports a private key.
403422
#### Parameters

0 commit comments

Comments
 (0)