Browse Source

fix comments

fix/bbjj-err
Ilya 1 year ago
parent
commit
068065257f
1 changed files with 11 additions and 11 deletions
  1. +11
    -11
      poseidon/poseidon_wrapper.go

+ 11
- 11
poseidon/poseidon_wrapper.go

@ -6,7 +6,7 @@ import (
"hash"
)
type digest struct {
type hasher struct {
buf *bytes.Buffer
frameSize int
}
@ -24,20 +24,20 @@ 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)
}
@ -45,16 +45,16 @@ func (d *digest) Sum(b []byte) []byte {
}
// 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
}

Loading…
Cancel
Save