add SSE3 version for 2 chunks

This commit is contained in:
Potuz
2021-11-17 11:16:08 -03:00
parent cff4a01ea0
commit 18b83bf445
3 changed files with 15 additions and 0 deletions

View File

@@ -5,4 +5,5 @@
extern void sha256_4_avx(unsigned char* output, const unsigned char* input, uint64_t blocks);
extern void sha256_8_avx2(unsigned char* output, const unsigned char* input, uint64_t blocks);
extern void sha256_shani(unsigned char* output, const unsigned char* input, uint64_t blocks);
extern void sha256_1_avx(unsigned char* output, const unsigned char* input);
#endif

View File

@@ -143,3 +143,7 @@ func PotuzHasherShani(dst []byte, inp []byte, count uint64) {
func PotuzHasherAVX2(dst []byte, inp []byte, count uint64) {
C.sha256_8_avx2((*C.uchar)(&dst[0]), (*C.uchar)(&inp[0]), C.ulong(count))
}
func PotuzHasher2Chunks(dst []byte, inp []byte) {
C.sha256_1_avx((*C.uchar)(&dst[0]), (*C.uchar)(&inp[0]))
}

View File

@@ -124,3 +124,13 @@ func TestCustomHash_Avx2(t *testing.T) {
hash.PotuzHasherAVX2(root, hash0, 1)
assert.DeepEqual(t, hashOf1[:], root)
}
func TestCustomHash_SSE(t *testing.T) {
hash0 := make([]byte, 64)
root := make([]byte, 32)
hashOf1 := [32]byte{245, 165, 253, 66, 209, 106, 32, 48, 39, 152, 239, 110, 211, 9, 151, 155, 67, 0, 61, 35, 32, 217, 240, 232, 234, 152, 49, 169, 39, 89, 251, 75}
hash.PotuzHasher2Chunks(root, hash0)
assert.DeepEqual(t, hashOf1[:], root)
}