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

Method Read

crypto/sha3/sha3.go:163–184  ·  view source on GitHub ↗

Read squeezes an arbitrary number of bytes from the sponge.

(out []byte)

Source from the content-addressed store, hash-verified

161
162// Read squeezes an arbitrary number of bytes from the sponge.
163func (d *state) Read(out []byte) (n int, err error) {
164 // If we're still absorbing, pad and apply the permutation.
165 if d.state == spongeAbsorbing {
166 d.padAndPermute(d.dsbyte)
167 }
168
169 n = len(out)
170
171 // Now, do the squeezing.
172 for len(out) > 0 {
173 n := copy(out, d.buf)
174 d.buf = d.buf[n:]
175 out = out[n:]
176
177 // Apply the permutation if we've squeezed the sponge dry.
178 if len(d.buf) == 0 {
179 d.permute()
180 }
181 }
182
183 return
184}
185
186// Sum applies padding to the hash state and then squeezes out the desired
187// number of output bytes.

Callers 1

SumMethod · 0.45

Calls 2

padAndPermuteMethod · 0.95
permuteMethod · 0.95

Tested by

no test coverage detected