diff --git a/src/route/hkp.js b/src/route/hkp.js index dcf7a4a..25dca3a 100644 --- a/src/route/hkp.js +++ b/src/route/hkp.js @@ -97,7 +97,7 @@ class HKP { if (!util.isString(id)) { return false; } - return /^0x[a-fA-F0-9]{16,40}$/.test(id); + return /^(?:0x)?[a-fA-F0-9]{8,40}$/.test(id); } /** diff --git a/src/service/public-key.js b/src/service/public-key.js index 36efcde..0fb37b2 100644 --- a/src/service/public-key.js +++ b/src/service/public-key.js @@ -261,8 +261,12 @@ class PublicKey { } // query by key id (to prevent key id collision) if (keyId) { + keyId = keyId.toLowerCase(); + if (keyId.length === 8) { + keyId = new RegExp('[a-fA-F0-9]{8}' + keyId); + } queries.push({ - keyId: keyId.toLowerCase(), + keyId: keyId, 'userIds.verified': true }); } diff --git a/src/service/util.js b/src/service/util.js index b3330c5..15b28ad 100644 --- a/src/service/util.js +++ b/src/service/util.js @@ -50,7 +50,7 @@ exports.isKeyId = function(data) { if (!this.isString(data)) { return false; } - return /^[a-fA-F0-9]{16}$/.test(data); + return /^[a-fA-F0-9]{8,16}$/.test(data); }; /**