ERRO[0001] Uncaught (in promise) NotSupportedError

I am trying to use the webcrypto experimental module with the k6/experimental/grpc module. When I attempt to use async/await , which I believe are supported since v0.43.0, I receive this error:

ERRO[0001] Uncaught (in promise) NotSupportedError

here is my code

import grpc from "k6/experimental/grpc";
import { check, sleep } from "k6";
import { crypto  } from 'k6/experimental/webcrypto'

export default async function() {
    client.connect(__ENV.GRPC_SERVER_ADDRESS, { timeout: "5s", plaintext: true });
    // Create a crypto signer
    const signer = await crypto.subtle.generateKey({
      name: 'EdDSA',
      modulusLength: 256,
      usages: ['sign', 'verify'],
    });
    const payload = {
        bucketId: bucketId,
        record: {
          name: name,
          cid: cid,
          signature: {
            algorithm: "ED_25519",
            signer: key.publicKey,
            value: await crypto.subtle.sign(
              {
                name: 'HMAC',
                hash: { name: 'SHA-256' },
              },
              signer.privateKey,
              proto.Record.encode(putRequest.record).finish(),
            ),
          },
        }
        
    }
    const  putResponse = client.invoke('myapi.MyFabtasticApi/Put', payload);

    console.log(putResponse)
    client.close();
    sleep(1);
}

Am I doing something incorrectly, or does experimental/grpc not support async/await ? More important how I can make it work?

Hi @samvel33651 !

Welcome to the community forums! :wave:

The issue that you’re facing isn’t related to the async/await support. It happens because the k6/experimental/webcrypto module doesn’t support the EdDSA algorithm:

Like the snippet below:

import { crypto  } from 'k6/experimental/webcrypto'

export default async function() {
    await crypto.subtle.generateKey({
      name: 'EdDSA',
      modulusLength: 256,
      usages: ['sign', 'verify'],
    }).catch((err) => {
      console.log(err);
    });
}

Produces:

INFO[0000] {"code":0,"name":"NotSupportedError","message":"unsupported algorithm: EDDSA"}  source=console

Looking into the webcrypto module’s open issues Issues · grafana/xk6-webcrypto · GitHub I can’t see that we even have a planned task to support the Edwards-curve Digital Signature Algorithm (EdDSA).

I might think that is because that algorithm wasn’t part of the webcrypto API PBKDF2 to ECDSA/EdDSA key · Issue #212 · w3c/webcrypto · GitHub :thinking:

So, unfortunately, I can only confirm that it doesn’t work.

I’d recommend trying to open a new issue at Issues · grafana/xk6-webcrypto · GitHub

Cheers :frowning_face:

2 Likes

Hi @samvel33651 :wave:

Welcome :tada:

The error you’re experiencing is due to the fact that we haven’t implemented support for the ECDSA algorithm in the k6/experimental/webcrypto module just yet. It is still an experimental module, and we unfortunately haven’t gotten to it, yet.

For context:

  • The WebCrypto specification does include ECDSA (and ECDH). They are supported for the sign , verify , generateKey , importKey , and exportKey operations.
  • We have an existing issue tracking its implementation.
  • At the moment, we throw an UnsupportedError to indicate that support for the algorithm is not implemented yet.
  • The README of the project has a table indicating what is supported and what isn’t, but I think we didn’t include that in the docs, which we probably should.

Implementing support for the ECDSA algorithm hasn’t been prioritized to this day, and we don’t have an ETA for it yet. Please let us know in the GitHub issue you care about seeing this implemented by adding a :+1: to it.

Let me know if that’s helpful :bowing_man:

2 Likes

@olegbespalov Thanks for the answer.

@oleiade Thanks for the answer.

Hey @samvel33651

Sorry for the confusion: it appears I read the name of the algorithm you asked about as ecdsa, when it was eddsa.

Thus, my comment above is invalidated by the fact that eddsa support is not included in the WebCrypto specification we have been basing our implementation. Therefore, we won’t include support for it.

:bowing_man: