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

Function TestTupleHashNISTSample2

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

Source from the content-addressed store, hash-verified

36}
37
38func TestTupleHashNISTSample2(t *testing.T) {
39 outputLength := 32
40 tuples := [][]byte{
41 []byte{0x00, 0x01, 0x02},
42 []byte{0x10, 0x11, 0x12, 0x13, 0x14, 0x15},
43 }
44 S := []byte("My Tuple App")
45 output := make([]byte, outputLength)
46 TupleHash128(tuples, S, output)
47 expected := strings.Replace("75 CD B2 0F F4 DB 11 54 E8 41 D7 58 E2 41 60 C5 4B AE 86 EB 8C 13 E7 F5 F4 0E B3 55 88 E9 6D FB", " ", "", -1)
48 if got := strings.ToUpper(hex.EncodeToString(output)); got != expected {
49 t.Errorf("TestTupleHashNISTSample2: got %s, want %s", got, expected)
50 }
51
52 h := NewTupleHash128(outputLength, S)
53 for _, item := range tuples {
54 h.WriteItem(item)
55 }
56 copy(output, zero[:])
57 h.Sum(output[:0])
58 if got := strings.ToUpper(hex.EncodeToString(output)); got != expected {
59 t.Errorf("TestTupleHashNISTSample2: got %s, want %s", got, expected)
60 }
61}
62
63func TestTupleHashNISTSample3(t *testing.T) {
64 outputLength := 32

Callers

nothing calls this directly

Calls 4

TupleHash128Function · 0.85
NewTupleHash128Function · 0.85
WriteItemMethod · 0.65
SumMethod · 0.45

Tested by

no test coverage detected