fix comments

This commit is contained in:
Ilya
2023-05-23 22:20:45 +03:00
parent f4e4eed9d5
commit 068065257f

View File

@@ -6,7 +6,7 @@ import (
"hash" "hash"
) )
type digest struct { type hasher struct {
buf *bytes.Buffer buf *bytes.Buffer
frameSize int frameSize int
} }
@@ -24,20 +24,20 @@ func New(frameSize int) (hash.Hash, error) {
if frameSize < 2 || frameSize > 16 { if frameSize < 2 || frameSize > 16 {
return nil, errors.New("incorrect frame size") return nil, errors.New("incorrect frame size")
} }
return &digest{ return &hasher{
buf: bytes.NewBuffer([]byte{}), buf: bytes.NewBuffer([]byte{}),
frameSize: frameSize, frameSize: frameSize,
}, nil }, nil
} }
// Write (via the embedded io.Writer interface) adds more data to the running hash. // Write (via the embedded io.Writer interface) adds more data to the running hash.
func (d *digest) Write(p []byte) (n int, err error) { func (h *hasher) Write(p []byte) (n int, err error) {
return d.buf.Write(p) return h.buf.Write(p)
} }
// Sum returns the Poseidon checksum of the data. // Sum returns the Poseidon digest of the data.
func (d *digest) Sum(b []byte) []byte { func (h *hasher) Sum(b []byte) []byte {
hahs, err := HashBytesX(d.buf.Bytes(), d.frameSize) hahs, err := HashBytesX(h.buf.Bytes(), h.frameSize)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -45,16 +45,16 @@ func (d *digest) Sum(b []byte) []byte {
} }
// Reset resets the Hash to its initial state. // Reset resets the Hash to its initial state.
func (d *digest) Reset() { func (h *hasher) Reset() {
d.buf.Reset() h.buf.Reset()
} }
// Size returns the number of bytes Sum will return. // Size returns the number of bytes Sum will return.
func (d *digest) Size() int { func (h *hasher) Size() int {
return 32 return 32
} }
// BlockSize returns the hash block size. // BlockSize returns the hash block size.
func (d *digest) BlockSize() int { func (h *hasher) BlockSize() int {
return spongeChunkSize return spongeChunkSize
} }