diff options
author | Matthew Miller <matthew@millerti.me> | 2020-05-21 19:21:28 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-05-21 19:21:28 -0700 |
commit | 282334daf1a3b618d34a0a3ac060bdea82101226 (patch) | |
tree | d1a51c0cf4da8877277fc9578fb5624c36863737 /packages/server/src | |
parent | 54482eb74590feaee0c44829630e750fb724a5dd (diff) |
Note some performance issues with verifyPacked
Diffstat (limited to 'packages/server/src')
-rw-r--r-- | packages/server/src/attestation/verifications/verifyPacked.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/packages/server/src/attestation/verifications/verifyPacked.ts b/packages/server/src/attestation/verifications/verifyPacked.ts index 614320b..98b4e66 100644 --- a/packages/server/src/attestation/verifications/verifyPacked.ts +++ b/packages/server/src/attestation/verifications/verifyPacked.ts @@ -116,6 +116,15 @@ export default function verifyAttestationPacked(attestationObject: AttestationOb const pkcsPublicKey = convertCOSEtoPKCS(COSEPublicKey); const signatureBaseHash = toHash(signatureBase, hashAlg); + /** + * Instantiating the curve here is _very_ computationally heavy - a bit of profiling + * (in compiled JS, not TS) reported an average of ~125ms to execute this line. The elliptic + * README states, "better do it once and reuse it", so maybe there's a better way to handle + * this in a server context, when we can re-use an existing instance. + * + * For now, it's worth noting that this line is probably the reason why it can take + * 5-6 seconds to run tests. + */ const ec = new elliptic.ec(COSECRV[(crv as number)]); const key = ec.keyFromPublic(pkcsPublicKey); |