From 915089010117955b0a9f29fbcd60418275bf5a6c Mon Sep 17 00:00:00 2001 From: Warlock-Dalbaeb Date: Tue, 15 Aug 2017 01:42:16 +0700 Subject: [PATCH 1/3] 4 byte --- vanity.hpp | 1 + vanitygen.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/vanity.hpp b/vanity.hpp index a5cedda..525e325 100644 --- a/vanity.hpp +++ b/vanity.hpp @@ -10,6 +10,7 @@ #include #include #include +typedef unsigned int __attribute__((__mode__(SI))) ui4b_t; //32 / 8 = 4 byte static std::mutex thread_mutex; static i2p::data::SigningKeyType type; diff --git a/vanitygen.cpp b/vanitygen.cpp index adb61e4..5993221 100644 --- a/vanitygen.cpp +++ b/vanitygen.cpp @@ -68,7 +68,7 @@ Orignal is sensei of crypto ;) */ std::cout << "Thread " << id_thread << " binded" << std::endl; - uint8_t b[391]; + ui4b_t b[391]; memcpy (b, buf, 391); int len = strlen (prefix); From e9c0e71936056e316633db8e53157c26700c4abc Mon Sep 17 00:00:00 2001 From: Warlock-Dalbaeb Date: Tue, 15 Aug 2017 01:49:18 +0700 Subject: [PATCH 2/3] union aligned --- vanitygen.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/vanitygen.cpp b/vanitygen.cpp index 5993221..7284509 100644 --- a/vanitygen.cpp +++ b/vanitygen.cpp @@ -68,16 +68,20 @@ Orignal is sensei of crypto ;) */ std::cout << "Thread " << id_thread << " binded" << std::endl; - ui4b_t b[391]; - memcpy (b, buf, 391); + union{ + uint8_t b[391]; + uint32_t ll; + }local; + + memcpy (local.b, buf, 391); int len = strlen (prefix); SHA256_CTX ctx, ctx1; SHA256_Init(&ctx); - SHA256_Update(&ctx, b, MutateByte); + SHA256_Update(&ctx, local.b, MutateByte); - uint32_t * nonce = (uint32_t *)(b+MutateByte); // in nonce copy of MutateByte of b; + uint32_t * nonce = (uint32_t *)(local.b+MutateByte); // in nonce copy of MutateByte of b; (*nonce)+=id_thread*throughput; uint8_t hash[32]; @@ -86,7 +90,7 @@ Orignal is sensei of crypto ;) while(throughput-- and !found){ memcpy (&ctx1, &ctx, sizeof (SHA256_CTX)); - SHA256_Update(&ctx1, b + MutateByte, 71); + SHA256_Update(&ctx1, local.b + MutateByte, 71); SHA256_Final(hash, &ctx1); ByteStreamToBase32 (hash, 32, addr, len); From 4558971345e12552a4eb7f4b2cff8e3c1efdcbb4 Mon Sep 17 00:00:00 2001 From: Warlock-Dalbaeb Date: Tue, 15 Aug 2017 01:49:57 +0700 Subject: [PATCH 3/3] union aligned --- vanity.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/vanity.hpp b/vanity.hpp index 525e325..a5cedda 100644 --- a/vanity.hpp +++ b/vanity.hpp @@ -10,7 +10,6 @@ #include #include #include -typedef unsigned int __attribute__((__mode__(SI))) ui4b_t; //32 / 8 = 4 byte static std::mutex thread_mutex; static i2p::data::SigningKeyType type;