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