File tree 4 files changed +43
-0
lines changed
4 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ go get -u github.com/cloudflare/circl
74
74
#### XOF: eXtendable Output Functions
75
75
- [ FIPS 202] ( https://doi.org/10.6028/NIST.FIPS.202 ) : SHAKE128 and SHAKE256
76
76
- [ BLAKE2X] ( https://www.blake2.net/blake2x.pdf ) : BLAKE2XB and BLAKE2XS
77
+ - [ KangarooTwelve] ( https://keccak.team/kangarootwelve.html ) : KangarooTwelve
77
78
78
79
#### Zero-knowledge Proofs
79
80
- [ Schnorr] ( ./zk/dl ) : Prove knowledge of the Discrete Logarithm.
Original file line number Diff line number Diff line change @@ -79,6 +79,29 @@ func (s *State) Reset() {
79
79
s .chunk = 0
80
80
}
81
81
82
+ func (s * State ) Clone () State {
83
+ stalk := s .stalk .Clone ().(* sha3.State )
84
+ ret := State {
85
+ initialTodo : s .initialTodo ,
86
+ stalk : * stalk ,
87
+ context : s .context ,
88
+ offset : s .offset ,
89
+ chunk : s .chunk ,
90
+ lanes : s .lanes ,
91
+ }
92
+
93
+ if s .leaf != nil {
94
+ ret .leaf = s .leaf .Clone ().(* sha3.State )
95
+ }
96
+
97
+ if s .buf != nil {
98
+ ret .buf = make ([]byte , len (s .buf ))
99
+ copy (ret .buf , s .buf )
100
+ }
101
+
102
+ return ret
103
+ }
104
+
82
105
func Draft10Sum (hash []byte , msg []byte , c []byte ) {
83
106
// TODO Tweak number of lanes depending on the length of the message
84
107
s := NewDraft10 (c )
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
10
10
"io"
11
11
12
12
"github.com/cloudflare/circl/internal/sha3"
13
+ "github.com/cloudflare/circl/xof/k12"
14
+
13
15
"golang.org/x/crypto/blake2b"
14
16
"golang.org/x/crypto/blake2s"
15
17
)
@@ -38,6 +40,7 @@ const (
38
40
SHAKE256
39
41
BLAKE2XB
40
42
BLAKE2XS
43
+ K12D10
41
44
)
42
45
43
46
func (x ID ) New () XOF {
@@ -54,6 +57,9 @@ func (x ID) New() XOF {
54
57
case BLAKE2XS :
55
58
x , _ := blake2s .NewXOF (blake2s .OutputLengthUnknown , nil )
56
59
return blake2xs {x }
60
+ case K12D10 :
61
+ x := k12 .NewDraft10 ([]byte {})
62
+ return k12d10 {& x }
57
63
default :
58
64
panic ("crypto: requested unavailable XOF function" )
59
65
}
@@ -70,3 +76,10 @@ func (s blake2xb) Clone() XOF { return blake2xb{s.XOF.Clone()} }
70
76
type blake2xs struct { blake2s.XOF }
71
77
72
78
func (s blake2xs ) Clone () XOF { return blake2xs {s .XOF .Clone ()} }
79
+
80
+ type k12d10 struct { * k12.State }
81
+
82
+ func (s k12d10 ) Clone () XOF {
83
+ x := s .State .Clone ()
84
+ return k12d10 {& x }
85
+ }
Original file line number Diff line number Diff line change @@ -53,6 +53,12 @@ var allVectors = []vector{
53
53
out : "0650cde4df888a06eada0f0fecb3c17594304b4a03fdd678182f27db1238b174" ,
54
54
outLen : 32 ,
55
55
},
56
+ {
57
+ id : xof .K12D10 ,
58
+ in : "The quick brown fox jumps over the lazy dog" ,
59
+ out : "b4f249b4f77c58df170aa4d1723db1127d82f1d98d25ddda561ada459cd11a48" ,
60
+ outLen : 32 ,
61
+ },
56
62
}
57
63
58
64
func TestXof (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments