projectdiscovery/nuclei · error

encode ecdsa public key: %w

Error message

encode ecdsa public key: %w

What it means

Error "encode ecdsa public key: %w" thrown in projectdiscovery/nuclei.

Source

Thrown at pkg/templates/signer/tmpl_signer.go:90

	fragment, _ := t.userFragment()
	return fragment
}

func (t *TemplateSigner) userFragment() (string, error) {
	// wrap with sync.Once to reduce unnecessary md5 hashing
	t.Do(func() {
		t.fragment, t.fragmentErr = publicKeyFragment(t.handler.ecdsaPubKey)
	})
	return t.fragment, t.fragmentErr
}

func publicKeyFragment(publicKey *ecdsa.PublicKey) (string, error) {
	if publicKey == nil {
		return "", nil
	}
	publicKeyBytes, err := publicKey.Bytes()
	if err != nil {
		return "", fmt.Errorf("encode ecdsa public key: %w", err)
	}
	if len(publicKeyBytes) < 3 || publicKeyBytes[0] != 4 || (len(publicKeyBytes)-1)%2 != 0 {
		return "", fmt.Errorf("invalid uncompressed ecdsa public key")
	}
	xCoordinateLength := (len(publicKeyBytes) - 1) / 2
	// Keep the old fragment stable: big.Int.Bytes omitted leading zero bytes.
	xCoordinateBytes := bytes.TrimLeft(publicKeyBytes[1:1+xCoordinateLength], "\x00")
	hashed := md5.Sum(xCoordinateBytes)
	return fmt.Sprintf("%x", hashed), nil
}

// Sign signs the given template with the template signer and returns the signature
func (t *TemplateSigner) Sign(data []byte, tmpl SignableTemplate) (string, error) {
	existingSignature, content := ExtractSignatureAndContent(data)
	content = normalizeTemplateContentForSignature(content)

	// Executable templates can only be re-signed by the current signer.
	hasJavascript := false

View on GitHub (pinned to 265b3a3dec)

When it happens

Trigger: Thrown at pkg/templates/signer/tmpl_signer.go:90 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/86a1c21aeb80b9a9. Report an issue: GitHub.