- Advanced Blockchain Development
- Imran Bashir Narayan Prusty
- 178字
- 2021-06-24 14:04:58
Public key
As the private key is mathematically linked to the public key, it is also possible to generate or derive the public key from the private key. Using the example of the preceding private key, the public key can be generated as shown here:
$ openssl rsa -pubout -in privatekey.pem -out publickey.pem
writing RSA key
The public key can be viewed using a file reader or any text viewer:
$ cat publickey.pem -----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCiThQcz8trznenpgZP1Bq8w8u0 74A2J2MQX4hCSHf6/hMjLfxdeJNnw0zlcMV2l08YkIA/gSronsv+vfYrZ66lv8cv 6aHAzL6G4/EAp4BJ7TnTaFUmjfrdH/Z0TN4lTPeJs9/wv7+L176GnD8j5K/9I4SF
dMKArq1xk4IYKiGx0QIDAQAB -----END PUBLIC KEY-----
In order to see more details of the various components, such as the modulus, prime numbers that are used in the encryption process, or exponents and coefficients of the generated private key, the following command can be used (only partial output is shown here as the actual output is very long):
$ openssl rsa -text -in privatekey.pem
Private-Key: (1024 bit)
modulus: 00:a2:4e:14:1c:cf:cb:6b:ce:77:a7:a6:06:4f:d4: 1a:bc:c3:cb:b4:ef:80:36:27:63:10:5f:88:42:48: 77:fa:fe:13:23:2d:fc:5d:78:93:67:c3:4c:e5:70: c5:76:97:4f:18:90:80:3f:81:2a:e8:9e:cb:fe:bd: f6:2b:67:ae:a5:bf:c7:2f:e9:a1:c0:cc:be:86:e3: f1:00:a7:80:49:ed:39:d3:68:55:26:8d:fa:dd:1f: f6:74:4c:de:25:4c:f7:89:b3:df:f0:bf:bf:8b:d7: be:86:9c:3f:23:e4:af:fd:23:84:85:74:c2:80:ae: ad:71:93:82:18:2a:21:b1:d1
publicExponent: 65537 (0x10001)
privateExponent: 00:94:1d:ec:fc:de:25:26:1d:25:d5:39:0e:49:8b: a7:5a:dc:d3:ea:2b:27:36:44:7b:83:55:ab:63:d1: fe:ac:6f:71:c7:89:0f:e5:bd:43:c8:4d:d2:bf:10: 4b:24:0e:b1:80:19:5e:f0:95:50:33:39:b7:b0:a2: 6b:24:f1:59:cf:34:f9:34:d3:67:ba:00:b1:6a:2a: f1:70:5d:66:3f:32:40:3f:76:aa:a5:c4:a3:c4:aa: 53:bf:8a:a0:a9:87:af:c2:05:b5:03:44:77:c4:a4: 19:cc:12:94:f9:b4:ce:da:15:d5:0f:5a:07:c6:ee: f9:98:36:37:c4:2c:2a:48:01
prime1: 00:d4:61:5d:38:c0:d4:84:8c:4c:bd:b5:82:74:cd: aa:f2:0c:07:2f:77:f5:46:db:f5:3f:ea:a8:90:19: a8:c1:79:2a:52:aa:81:04:4a:28:1b:ba:c2:a4:bb: ec:15:b5:16:20:59:61:28:98:bf:d7:e7:cb:7e:2b: 4d:5e:30:c6:59
prime2: 00:c3:a3:d4:47:d6:0b:79:bb:26:fd:28:e2:88:e4: a1:57:80:0a:b8:57:62:ee:de:c3:61:61:39:52:56: f5:ba:a3:ff:8b:6f:33:37:fc:ad:b7:80:57:28:8b: 3f:29:c1:72:91:01:9e:00:2e:8b:0c:76:72:c9:cc: 9c:9e:d0:c8:39