Some EC math from bc-csharp.