SDK: Factor out pubkey on-curve test to a helper