MCPcopy Create free account
hub / github.com/C2SP/CCTV / polyByteEncode

Function polyByteEncode

ML-KEM/modulus/modulus.go:84–94  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

82//
83// It implements ByteEncode₁₂, according to FIPS 203 (DRAFT), Algorithm 4.
84func 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

Callers 1

genVectorFunction · 0.85

Calls 1

sliceForAppendFunction · 0.85

Tested by

no test coverage detected