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

Function TestTupleHashNISTSample3

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

Source from the content-addressed store, hash-verified

61}
62
63func TestTupleHashNISTSample3(t *testing.T) {
64 outputLength := 32
65 tuples := [][]byte{
66 []byte{0x00, 0x01, 0x02},
67 []byte{0x10, 0x11, 0x12, 0x13, 0x14, 0x15},
68 []byte{0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28},
69 }
70 S := []byte("My Tuple App")
71 output := make([]byte, outputLength)
72 TupleHash128(tuples, S, output)
73 expected := strings.Replace("E6 0F 20 2C 89 A2 63 1E DA 8D 4C 58 8C A5 FD 07 F3 9E 51 51 99 8D EC CF 97 3A DB 38 04 BB 6E 84", " ", "", -1)
74 if got := strings.ToUpper(hex.EncodeToString(output)); got != expected {
75 t.Errorf("TestTupleHashNISTSample3: got %s, want %s", got, expected)
76 }
77
78 h := NewTupleHash128(outputLength, S)
79 for _, item := range tuples {
80 h.WriteItem(item)
81 }
82 copy(output, zero[:])
83 h.Sum(output[:0])
84 if got := strings.ToUpper(hex.EncodeToString(output)); got != expected {
85 t.Errorf("TestTupleHashNISTSample3: got %s, want %s", got, expected)
86 }
87}
88
89func TestTupleHashNISTSample4(t *testing.T) {
90 outputLength := 64

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