fish2018/pansou · error

PoW验证数据无效: x

Error message

PoW验证数据无效: x

What it means

computePowResult parses the challenge base x from hex via big.Int.SetString and requires it to be a non-negative integer. This error is returned when challenge.X is empty, not valid hex, or parses to a negative number, so the repeated-squaring y = x^(2^t) mod N cannot proceed.

Solutions

  1. Log challenge.X and the raw challenge response to see the actual value format
  2. Re-fetch a fresh challenge; truncated/corrupted bodies are the typical cause
  3. If the value is decimal or prefixed (0x), convert/strip before SetString(X, 16)
  4. Pre-validate X client-side: non-empty hex, parses, value >= 0

Example fix

// before
y, ok := new(big.Int).SetString(challenge.X, 16)
// after
xHex := strings.TrimPrefix(strings.ToLower(challenge.X), "0x")
y, ok := new(big.Int).SetString(xHex, 16)
if !ok || y.Sign() < 0 {
    return "", fmt.Errorf("PoW验证数据无效: x")
}
Defensive patterns

Strategy: validation

Validate before calling

func validHexNonNegative(s string) bool {
    x, ok := new(big.Int).SetString(strings.TrimPrefix(s, "0x"), 16)
    return ok && x.Sign() >= 0
}
if !validHexNonNegative(ch.X) { /* re-fetch challenge before solving */ }

Type guard

func isValidPowBase(c *ChallengePageData) bool {
    x, ok := new(big.Int).SetString(c.X, 16)
    return ok && x != nil && x.Sign() >= 0
}

Try / catch

y, err := p.computePowResult(challenge)
if err != nil {
    if strings.Contains(err.Error(), ": x") {
        return p.refetchAndSolve(scraper, requestURL)
    }
    return err
}

Prevention

When it happens

Trigger: computePowResult is called with a ChallengePageData whose X field fails hex parsing or yields y.Sign() < 0 (e.g. X="", X="zz", or X="-a1").

Common situations: Upstream changed the challenge JSON so the base is now decimal or base64-encoded instead of hex; the challenge body was truncated in transit; test fixtures with placeholder values are fed to the solver.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/8c1c33fee9e37d85. Report an issue: GitHub.

Appendix: source

Thrown at plugin/gying/gying.go:1745

	}

	form := url.Values{}
	form.Set("action", "verify")
	form.Set("id", challenge.ID)
	form.Set("y", y)

	return p.submitChallengeVerification(scraper, requestURL, form)
}

func (p *GyingPlugin) computePowResult(challenge *ChallengePageData) (string, error) {
	modulus, ok := new(big.Int).SetString(challenge.N, 16)
	if !ok || modulus.Sign() <= 0 {
		return "", fmt.Errorf("PoW验证数据无效: N")
	}

	y, ok := new(big.Int).SetString(challenge.X, 16)
	if !ok || y.Sign() < 0 {
		return "", fmt.Errorf("PoW验证数据无效: x")
	}
	if challenge.T <= 0 {
		return "", fmt.Errorf("PoW验证数据无效: t")
	}

	if DebugLog {
		fmt.Printf("[Gying] PoW Challenge计算开始: id=%s t=%d nBits=%d\n",
			challenge.ID, challenge.T, modulus.BitLen())
	}

	start := time.Now()
	for i := 0; i < challenge.T; i++ {
		y.Mul(y, y)
		y.Mod(y, modulus)
	}
	elapsed := time.Since(start)

	if DebugLog {

View on GitHub (pinned to beaa561337)