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