Skip to content

Commit

Permalink
WIP wrapped hash
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub committed Oct 23, 2023
1 parent 7a6d821 commit 54c2c35
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion std/recursion/wrapped_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
type shortNativeHash struct {
bitLength int
wrapped hash.Hash

buf []byte
}

// NewShort returns a native hash function which reads elements in the current native
Expand Down Expand Up @@ -62,11 +64,14 @@ func newShortFromParam(hf hash.Hash, bitLength int) hash.Hash {
return &shortNativeHash{
bitLength: bitLength,
wrapped: hf,

buf: make([]byte, hf.BlockSize()),
}
}

func (h *shortNativeHash) Write(p []byte) (n int, err error) {
return h.wrapped.Write(p)
h.buf = append(h.buf[:0], p...)
return h.wrapped.Write(h.buf)
}

func (h *shortNativeHash) Sum(b []byte) []byte {
Expand Down

0 comments on commit 54c2c35

Please sign in to comment.