mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-23 22:15:52 +00:00
Internal: switch away from deprecated noble-curve util.randomPrivateKey
This commit is contained in:
parent
29cdf978c4
commit
e05ca9e2d2
@ -61,8 +61,7 @@ export async function generate(algo) {
|
||||
|
||||
case enums.publicKey.x448: {
|
||||
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
||||
const k = x448.utils.randomPrivateKey();
|
||||
const A = x448.getPublicKey(k);
|
||||
const { secretKey: k, publicKey: A } = x448.keygen();
|
||||
return { A, k };
|
||||
}
|
||||
default:
|
||||
@ -246,10 +245,9 @@ export async function generateEphemeralEncryptionMaterial(algo, recipientA) {
|
||||
}
|
||||
case enums.publicKey.x448: {
|
||||
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
||||
const ephemeralSecretKey = x448.utils.randomPrivateKey();
|
||||
const { secretKey: ephemeralSecretKey, publicKey: ephemeralPublicKey } = x448.keygen();
|
||||
const sharedSecret = x448.getSharedSecret(ephemeralSecretKey, recipientA);
|
||||
assertNonZeroArray(sharedSecret);
|
||||
const ephemeralPublicKey = x448.getPublicKey(ephemeralSecretKey);
|
||||
return { ephemeralPublicKey, sharedSecret };
|
||||
}
|
||||
default:
|
||||
|
||||
@ -67,8 +67,7 @@ export async function generate(algo) {
|
||||
|
||||
case enums.publicKey.ed448: {
|
||||
const ed448 = await util.getNobleCurve(enums.publicKey.ed448);
|
||||
const seed = ed448.utils.randomPrivateKey();
|
||||
const A = ed448.getPublicKey(seed);
|
||||
const { secretKey: seed, publicKey: A } = ed448.keygen();
|
||||
return { A, seed };
|
||||
}
|
||||
default:
|
||||
|
||||
@ -297,7 +297,7 @@ export {
|
||||
//////////////////////////
|
||||
async function jsGenKeyPair(name) {
|
||||
const nobleCurve = await util.getNobleCurve(enums.publicKey.ecdsa, name); // excluding curve25519Legacy, ecdh and ecdsa use the same curves
|
||||
const privateKey = nobleCurve.utils.randomPrivateKey();
|
||||
const { secretKey: privateKey } = nobleCurve.keygen();
|
||||
const publicKey = nobleCurve.getPublicKey(privateKey, false);
|
||||
return { publicKey, privateKey };
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user