grafana/k6 · error

public exponent too small

Error message

public exponent too small

What it means

Error "public exponent too small" thrown in grafana/k6.

Source

Thrown at internal/js/modules/k6/webcrypto/rsa.go:151

	if err != nil {
		return nil, err
	}

	return &CryptoKeyPair{
		PrivateKey: privateKey,
		PublicKey:  publicKey,
	}, nil
}

// validatePublicExponent validates the public exponent.
// it's done same way how golang's rsa package does it + additional check for evenness.
func validatePublicExponent(e int) error {
	if e%2 == 0 {
		return errors.New("public exponent is even")
	}

	if e < 2 {
		return errors.New("public exponent too small")
	}
	if e > 1<<31-1 {
		return errors.New("public exponent too large")
	}

	return nil
}

func generateRSAKeyPair(
	modulusLength int,
	publicExponent int,
) (any, any, error) {
	privateKey, err := rsa.GenerateKey(rand.Reader, modulusLength)
	if err != nil {
		return nil, nil, NewError(OperationError, "could not generate RSA key pair")
	}

	privateKey.E = publicExponent

View on GitHub (pinned to 93accf6570)

When it happens

Trigger: Thrown at internal/js/modules/k6/webcrypto/rsa.go:151 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/8f38ef6dc1821ba6. Report an issue: GitHub.