-
Notifications
You must be signed in to change notification settings - Fork 11
Description
this case occurs with probability
ecrecover(e, v, r, s) accepts any e, 27/28 for v and r, s in [1, Secp256k1.N), where N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
suppose public key has pubKey.x >= N and in that case ecrecover will return address(0). so the protocol can't verify the signature. which means you lose control of the smart contract.
scribe/src/libs/LibSchnorr.sol
Lines 81 to 82 in 7d2106a
| // Set r = Pₓ | |
| uint r = pubKey.x; |
r, s range:
- https://github.com/ethereum/go-ethereum/blob/06883c16861fc034e1471c4f911cd309612b1f7f/core/vm/contracts.go#L255
- https://github.com/ethereum/go-ethereum/blob/06883c16861fc034e1471c4f911cd309612b1f7f/crypto/crypto.go#L271
fix: if (!(pubKey.isOnCurve() && pubKey.x < LibSecp256k1.Q())) {
also need to reject pubKey.x >= Secp256k1.N for group public key on backend and at constructor?
scribe/src/libs/LibSchnorr.sol
Lines 36 to 38 in 7d2106a
| if (!pubKey.isOnCurve()) { | |
| return false; | |
| } |