mirror of
https://github.com/arnaucube/go-iden3-crypto.git
synced 2026-02-07 11:36:41 +01:00
fix comments
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user