bn: use binary search to speed up curve ops