public static int multiply ( int x , int y , int primitive , int domain ) { int r = 0 ; while ( y > 0 ) { if ( ( y & 1 ) != 0 ) { r = r ^ x ; } y = y >> 1 ; x = x << 1 ; if ( x >= domain ) { x ^= primitive ; } } return r ; }
Implementation of multiplication with a primitive polynomial . The result will be a member of the same field as the inputs provided primitive is an appropriate irreducible polynomial for that field .