Arithmetic over finite fields in Ruby