MCPcopy Create free account
hub / github.com/chain/txvm / TestTupleHashXOFNISTSample1

Function TestTupleHashXOFNISTSample1

crypto/sha3/tuple_hash_test.go:165–189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func TestTupleHashXOFNISTSample1(t *testing.T) {
166 outputLength := 32
167 tuples := [][]byte{
168 []byte{0x00, 0x01, 0x02},
169 []byte{0x10, 0x11, 0x12, 0x13, 0x14, 0x15},
170 }
171 S := []byte{}
172 r := TupleHashXOF128(tuples, S)
173 output := make([]byte, outputLength)
174 r.Read(output)
175 expected := strings.Replace("2F 10 3C D7 C3 23 20 35 34 95 C6 8D E1 A8 12 92 45 C6 32 5F 6F 2A 3D 60 8D 92 17 9C 96 E6 84 88", " ", "", -1)
176 if got := strings.ToUpper(hex.EncodeToString(output)); got != expected {
177 t.Errorf("TestTupleHashXOFNISTSample1: got %s, want %s", got, expected)
178 }
179
180 h := NewTupleHashXOF128(S)
181 for _, item := range tuples {
182 h.WriteItem(item)
183 }
184 copy(output, zero[:])
185 h.Read(output)
186 if got := strings.ToUpper(hex.EncodeToString(output)); got != expected {
187 t.Errorf("TestTupleHashXOFNISTSample1: got %s, want %s", got, expected)
188 }
189}
190
191func TestTupleHashXOFNISTSample2(t *testing.T) {
192 outputLength := 32

Callers

nothing calls this directly

Calls 4

TupleHashXOF128Function · 0.85
NewTupleHashXOF128Function · 0.85
WriteItemMethod · 0.65
ReadMethod · 0.45

Tested by

no test coverage detected