Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-korotya committed May 23, 2023
1 parent f4e4eed commit 0680652
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions poseidon/poseidon_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"hash"
)

type digest struct {
type hasher struct {
buf *bytes.Buffer
frameSize int
}
Expand All @@ -24,37 +24,37 @@ func New(frameSize int) (hash.Hash, error) {
if frameSize < 2 || frameSize > 16 {
return nil, errors.New("incorrect frame size")
}
return &digest{
return &hasher{
buf: bytes.NewBuffer([]byte{}),
frameSize: frameSize,
}, nil
}

// Write (via the embedded io.Writer interface) adds more data to the running hash.
func (d *digest) Write(p []byte) (n int, err error) {
return d.buf.Write(p)
func (h *hasher) Write(p []byte) (n int, err error) {
return h.buf.Write(p)
}

// Sum returns the Poseidon checksum of the data.
func (d *digest) Sum(b []byte) []byte {
hahs, err := HashBytesX(d.buf.Bytes(), d.frameSize)
// Sum returns the Poseidon digest of the data.
func (h *hasher) Sum(b []byte) []byte {
hahs, err := HashBytesX(h.buf.Bytes(), h.frameSize)
if err != nil {
panic(err)
}
return append(b, hahs.Bytes()...)
}

// Reset resets the Hash to its initial state.
func (d *digest) Reset() {
d.buf.Reset()
func (h *hasher) Reset() {
h.buf.Reset()
}

// Size returns the number of bytes Sum will return.
func (d *digest) Size() int {
func (h *hasher) Size() int {
return 32
}

// BlockSize returns the hash block size.
func (d *digest) BlockSize() int {
func (h *hasher) BlockSize() int {
return spongeChunkSize
}

0 comments on commit 0680652

Please sign in to comment.