polyByteEncode appends the 384-byte encoding of f to b. It implements ByteEncode₁₂, according to FIPS 203 (DRAFT), Algorithm 4.
(b []byte, f [n]uint16)
| 82 | // |
| 83 | // It implements ByteEncode₁₂, according to FIPS 203 (DRAFT), Algorithm 4. |
| 84 | func polyByteEncode(b []byte, f [n]uint16) []byte { |
| 85 | out, B := sliceForAppend(b, encodingSize12) |
| 86 | for i := 0; i < n; i += 2 { |
| 87 | x := uint32(f[i]) | uint32(f[i+1])<<12 |
| 88 | B[0] = uint8(x) |
| 89 | B[1] = uint8(x >> 8) |
| 90 | B[2] = uint8(x >> 16) |
| 91 | B = B[3:] |
| 92 | } |
| 93 | return out |
| 94 | } |
| 95 | |
| 96 | // sliceForAppend takes a slice and a requested number of bytes. It returns a |
| 97 | // slice with the contents of the given slice followed by that many bytes and a |
no test coverage detected