From 958fb640dc2130201d2159df3be93a4b7f163d18 Mon Sep 17 00:00:00 2001 From: upalinski Date: Fri, 10 Nov 2023 11:21:02 +0300 Subject: [PATCH] export compressChunk method --- bao.go | 4 ++-- blake3.go | 2 +- compress_amd64.go | 6 +++--- compress_generic.go | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bao.go b/bao.go index 213a3bb..c9ae45d 100644 --- a/bao.go +++ b/bao.go @@ -54,7 +54,7 @@ func BaoEncode(dst io.WriterAt, data io.Reader, dataLen int64, outboard bool) ([ if err != nil { return 0, [8]uint32{} } else if bufLen <= ChunkSize { - cv := ChainingValue(compressChunk(read(chunkBuf[:bufLen]), &Iv, counter, flags)) + cv := ChainingValue(CompressChunk(read(chunkBuf[:bufLen]), &Iv, counter, flags)) counter++ if !outboard { write(chunkBuf[:bufLen], off) @@ -105,7 +105,7 @@ func BaoDecode(dst io.Writer, data, outboard io.Reader, root [32]byte) (bool, er if err != nil { return false } else if bufLen <= ChunkSize { - n := compressChunk(read(data, buf[:bufLen]), &Iv, counter, flags) + n := CompressChunk(read(data, buf[:bufLen]), &Iv, counter, flags) counter++ return cv == ChainingValue(n) } diff --git a/blake3.go b/blake3.go index 0d4e6ae..c552786 100644 --- a/blake3.go +++ b/blake3.go @@ -192,7 +192,7 @@ func Sum512(b []byte) (out [64]byte) { hashBlock(&out, b) return } else if len(b) <= ChunkSize { - n = compressChunk(b, &Iv, 0, 0) + n = CompressChunk(b, &Iv, 0, 0) n.flags |= FlagRoot } else { h := *defaultHasher diff --git a/compress_amd64.go b/compress_amd64.go index 1d5b2ab..353f659 100644 --- a/compress_amd64.go +++ b/compress_amd64.go @@ -31,7 +31,7 @@ func compressBufferAVX512(buf *[maxSIMD * ChunkSize]byte, buflen int, key *[8]ui if buflen%ChunkSize != 0 { // use non-asm for remainder partialChunk := buf[buflen-buflen%ChunkSize : buflen] - cvs[numChunks] = ChainingValue(compressChunk(partialChunk, key, counter+numChunks, flags)) + cvs[numChunks] = ChainingValue(CompressChunk(partialChunk, key, counter+numChunks, flags)) numChunks++ } return mergeSubtrees(&cvs, numChunks, key, flags) @@ -49,7 +49,7 @@ func compressBufferAVX2(buf *[maxSIMD * ChunkSize]byte, buflen int, key *[8]uint if buflen%ChunkSize != 0 { // use non-asm for remainder partialChunk := buf[buflen-buflen%ChunkSize : buflen] - cvs[numChunks] = ChainingValue(compressChunk(partialChunk, key, counter+numChunks, flags)) + cvs[numChunks] = ChainingValue(CompressChunk(partialChunk, key, counter+numChunks, flags)) numChunks++ } return mergeSubtrees(&cvs, numChunks, key, flags) @@ -66,7 +66,7 @@ func compressBuffer(buf *[maxSIMD * ChunkSize]byte, buflen int, key *[8]uint32, } } -func compressChunk(chunk []byte, key *[8]uint32, counter uint64, flags uint32) Node { +func CompressChunk(chunk []byte, key *[8]uint32, counter uint64, flags uint32) Node { n := Node{ cv: *key, counter: counter, diff --git a/compress_generic.go b/compress_generic.go index c4c970c..e8aa5ba 100644 --- a/compress_generic.go +++ b/compress_generic.go @@ -110,12 +110,12 @@ func ChainingValue(n Node) (cv [8]uint32) { func compressBufferGeneric(buf *[maxSIMD * ChunkSize]byte, buflen int, key *[8]uint32, counter uint64, flags uint32) (n Node) { if buflen <= ChunkSize { - return compressChunk(buf[:buflen], key, counter, flags) + return CompressChunk(buf[:buflen], key, counter, flags) } var cvs [maxSIMD][8]uint32 var numCVs uint64 for bb := bytes.NewBuffer(buf[:buflen]); bb.Len() > 0; numCVs++ { - cvs[numCVs] = ChainingValue(compressChunk(bb.Next(ChunkSize), key, counter+numCVs, flags)) + cvs[numCVs] = ChainingValue(CompressChunk(bb.Next(ChunkSize), key, counter+numCVs, flags)) } return mergeSubtrees(&cvs, numCVs, key, flags) }