Skip to content

Commit 7d07c29

Browse files
committed
experimental: provide SHA-256 transform to libsecp
1 parent dc4ad9f commit 7d07c29

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/crypto/sha256.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ void TransformD64(unsigned char* out, const unsigned char* in)
435435

436436
} // namespace sha256
437437

438-
typedef void (*TransformType)(uint32_t*, const unsigned char*, size_t);
439438
typedef void (*TransformD64Type)(unsigned char*, const unsigned char*);
440439

441440
template<TransformType tr>
@@ -779,3 +778,8 @@ void SHA256D64(unsigned char* out, const unsigned char* in, size_t blocks)
779778
--blocks;
780779
}
781780
}
781+
782+
TransformType GetSha256TransformFn()
783+
{
784+
return Transform;
785+
}

src/crypto/sha256.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <cstdlib>
1010
#include <string>
1111

12+
typedef void (*TransformType)(uint32_t*, const unsigned char*, size_t);
13+
1214
/** A hasher class for SHA-256. */
1315
class CSHA256
1416
{
@@ -50,4 +52,7 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem
5052
*/
5153
void SHA256D64(unsigned char* output, const unsigned char* input, size_t blocks);
5254

55+
/* TODO: Complete me */
56+
TransformType GetSha256TransformFn();
57+
5358
#endif // BITCOIN_CRYPTO_SHA256_H

src/key.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ static void ECC_Start() {
583583
assert(ret);
584584
}
585585

586+
secp256k1_set_sha256_transform_callback(GetSha256TransformFn());
586587
secp256k1_context_sign = ctx;
587588
}
588589

0 commit comments

Comments
 (0)