mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-11-24 06:25:50 +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: {
|
case enums.publicKey.x448: {
|
||||||
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
const x448 = await util.getNobleCurve(enums.publicKey.x448);
|
||||||
const k = x448.utils.randomPrivateKey();
|
const { secretKey: k, publicKey: A } = x448.keygen();
|
||||||
const A = x448.getPublicKey(k);
|
|
||||||
return { A, k };
|
return { A, k };
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -246,10 +245,9 @@ export async function generateEphemeralEncryptionMaterial(algo, recipientA) {
|
|||||||
}
|
}
|
||||||
case enums.publicKey.x448: {
|
case enums.publicKey.x448: {
|
||||||
const x448 = await util.getNobleCurve(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);
|
const sharedSecret = x448.getSharedSecret(ephemeralSecretKey, recipientA);
|
||||||
assertNonZeroArray(sharedSecret);
|
assertNonZeroArray(sharedSecret);
|
||||||
const ephemeralPublicKey = x448.getPublicKey(ephemeralSecretKey);
|
|
||||||
return { ephemeralPublicKey, sharedSecret };
|
return { ephemeralPublicKey, sharedSecret };
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -67,8 +67,7 @@ export async function generate(algo) {
|
|||||||
|
|
||||||
case enums.publicKey.ed448: {
|
case enums.publicKey.ed448: {
|
||||||
const ed448 = await util.getNobleCurve(enums.publicKey.ed448);
|
const ed448 = await util.getNobleCurve(enums.publicKey.ed448);
|
||||||
const seed = ed448.utils.randomPrivateKey();
|
const { secretKey: seed, publicKey: A } = ed448.keygen();
|
||||||
const A = ed448.getPublicKey(seed);
|
|
||||||
return { A, seed };
|
return { A, seed };
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -297,7 +297,7 @@ export {
|
|||||||
//////////////////////////
|
//////////////////////////
|
||||||
async function jsGenKeyPair(name) {
|
async function jsGenKeyPair(name) {
|
||||||
const nobleCurve = await util.getNobleCurve(enums.publicKey.ecdsa, name); // excluding curve25519Legacy, ecdh and ecdsa use the same curves
|
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);
|
const publicKey = nobleCurve.getPublicKey(privateKey, false);
|
||||||
return { publicKey, privateKey };
|
return { publicKey, privateKey };
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user