It should be mentioned the above code was derived from `recoverPubKey`, which may be incorrectly documented or could be misleading.  I'm manually re-verifying this now, and I'll show my workings below.

**edit:**  The relevant lines from [`2.3.4`](http://www.secg.org/download/aid-780/sec1-v2.pdf   ):

> If Y = 0x02, set ˜yP = 0, and if Y = 0x03, set ˜yP = 1.
> yP = β if β ≡ ˜yP (mod 2), and set yP = p − β if β 6≡ ˜yP (mod 2).

Reduced (and in pseudo-js):

```
if (Y == 0x02) {
  ˜yP = 0
} else { // Y == 0x03
  ˜yP = 1
}

if (β % 2 === ˜yP % 2) {
  yP = β
} else {
  yP = p − β
}
```

`mod 2` is equivalent to checking if the number is odd, so to make use of what we have available, we can take the logical negation of `BigInteger.isEven()`.
Which can be logically reduced to:

```
if (Y == 0x02) {
  ˜yP = 0
} else { // Y == 0x03
  ˜yP = 1
}

if (β.isEven() ^ ˜yP.isEven()) {
  yP = p − β
} else {
  yP = β
}
```

So yes:
```
(beta.isEven() ^ isYEven) ? p.substract(beta) : beta
```

Is a correct translation.
And it appears that `ecdsa.js:189`:
```
  // The less significant bit specifies whether the y coordinate
  // of the compressed point is even or not.
  var isYEven = i & 1
```

Is incorrect, as `isYEven` should only be true when the least significant bit is **NOT** set (aka, 0x02).  Leading to this confusion.

Will push a fix later today.