Efficient implementation of finite-field arithmetic