MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / finiteFieldMultiply

Function finiteFieldMultiply

modules/data/qrcode/qrcodegen.c:308–316  ·  view source on GitHub ↗

Returns the product of the two given field elements modulo GF(2^8/0x11D). All inputs are valid. This could be implemented as a 256*256 lookup table.

Source from the content-addressed store, hash-verified

306// Returns the product of the two given field elements modulo GF(2^8/0x11D).
307// All inputs are valid. This could be implemented as a 256*256 lookup table.
308testable uint8_t finiteFieldMultiply(uint8_t x, uint8_t y) {
309 // Russian peasant multiplication
310 uint8_t z = 0;
311 for (int i = 7; i >= 0; i--) {
312 z = (z << 1) ^ ((z >> 7) * 0x11D);
313 z ^= ((y >> i) & 1) * x;
314 }
315 return z;
316}
317
318
319

Callers 2

calcReedSolomonGeneratorFunction · 0.85
calcReedSolomonRemainderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected