move generic functions out of secp256k1 module and parameterize; cleanup