sigEncode static method
sigEncode(c̃, z, h)
Implementation
static BuBytes sigEncode(
List<int> cTilde,
PolyVec z,
List<List<int>> h, // list of positions of 1's per polynomial
int gamma1,
int omega,
int k,
) {
final l = z.k;
final zBytes = gamma1 == (1 << 17) ? 576 : 640;
final out = BuBytes.fill(cTilde.length + l * zBytes + omega + k, 0);
var off = 0;
out.setRange(off, off + cTilde.length, cTilde);
off += cTilde.length;
for (var i = 0; i < l; i++) {
final packed = bitPack(z.polys[i], gamma1 - 1, gamma1);
out.setRange(off, off + zBytes, packed);
off += zBytes;
}
final hint = List<int>.filled(omega + k, 0);
var idx = 0;
for (var i = 0; i < k; i++) {
for (final pos in h[i]) {
hint[idx++] = pos;
assert(pos < 256);
}
assert(idx < 256);
hint[omega + i] = idx;
}
out.setRange(off, off + hint.length, hint);
return out;
}