...
1
2
3 package internal
4
5 import (
6 "github.com/cloudflare/circl/sign/dilithium/internal/common"
7 )
8
9
10 type Mat [K]VecL
11
12
13
14
15 func (m *Mat) Derive(seed *[32]byte) {
16 if !DeriveX4Available {
17 for i := uint16(0); i < K; i++ {
18 for j := uint16(0); j < L; j++ {
19 PolyDeriveUniform(&m[i][j], seed, (i<<8)+j)
20 }
21 }
22 return
23 }
24
25 idx := 0
26 var nonces [4]uint16
27 var ps [4]*common.Poly
28 for i := uint16(0); i < K; i++ {
29 for j := uint16(0); j < L; j++ {
30 nonces[idx] = (i << 8) + j
31 ps[idx] = &m[i][j]
32 idx++
33 if idx == 4 {
34 idx = 0
35 PolyDeriveUniformX4(ps, seed, nonces)
36 }
37 }
38 }
39 if idx != 0 {
40 for i := idx; i < 4; i++ {
41 ps[i] = nil
42 }
43 PolyDeriveUniformX4(ps, seed, nonces)
44 }
45 }
46
47
48
49
50
51
52 func PolyDotHat(p *common.Poly, a, b *VecL) {
53 var t common.Poly
54 *p = common.Poly{}
55 for i := 0; i < L; i++ {
56 t.MulHat(&a[i], &b[i])
57 p.Add(&t, p)
58 }
59 }
60
View as plain text