@@ -15,12 +15,6 @@ export async function generate(algo) {
1515}
1616
1717export async function sign ( signatureAlgo , hashAlgo , eccSecretKey , eccPublicKey , mldsaSecretKey , dataDigest ) {
18- if ( hashAlgo !== getRequiredHashAlgo ( signatureAlgo ) ) {
19- // The signature hash algo MUST be set to the specified algorithm, see
20- // https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-pqc#section-5.2.1.
21- throw new Error ( 'Unexpected hash algorithm for PQC signature' ) ;
22- }
23-
2418 switch ( signatureAlgo ) {
2519 case enums . publicKey . pqc_mldsa_ed25519 : {
2620 const { eccSignature } = await eccdsa . sign ( signatureAlgo , hashAlgo , eccSecretKey , eccPublicKey , dataDigest ) ;
@@ -34,12 +28,6 @@ export async function sign(signatureAlgo, hashAlgo, eccSecretKey, eccPublicKey,
3428}
3529
3630export async function verify ( signatureAlgo , hashAlgo , eccPublicKey , mldsaPublicKey , dataDigest , { eccSignature, mldsaSignature } ) {
37- if ( hashAlgo !== getRequiredHashAlgo ( signatureAlgo ) ) {
38- // The signature hash algo MUST be set to the specified algorithm, see
39- // https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-pqc#section-5.2.1.
40- throw new Error ( 'Unexpected hash algorithm for PQC signature' ) ;
41- }
42-
4331 switch ( signatureAlgo ) {
4432 case enums . publicKey . pqc_mldsa_ed25519 : {
4533 const eccVerifiedPromise = eccdsa . verify ( signatureAlgo , hashAlgo , eccPublicKey , dataDigest , eccSignature ) ;
@@ -52,16 +40,6 @@ export async function verify(signatureAlgo, hashAlgo, eccPublicKey, mldsaPublicK
5240 }
5341}
5442
55- export function getRequiredHashAlgo ( signatureAlgo ) {
56- // See https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-pqc#section-5.2.1.
57- switch ( signatureAlgo ) {
58- case enums . publicKey . pqc_mldsa_ed25519 :
59- return enums . hash . sha3_256 ;
60- default :
61- throw new Error ( 'Unsupported signature algorithm' ) ;
62- }
63- }
64-
6543export async function validateParams ( algo , eccPublicKey , eccSecretKey , mldsaPublicKey , mldsaSeed ) {
6644 const eccValidationPromise = eccdsa . validateParams ( algo , eccPublicKey , eccSecretKey ) ;
6745 const mldsaValidationPromise = mldsa . validateParams ( algo , mldsaPublicKey , mldsaSeed ) ;
0 commit comments