aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/scrypt.h
diff options
context:
space:
mode:
authorshaolinfry <[email protected]>2017-02-18 11:13:07 +0000
committerRoss Nicoll <[email protected]>2021-05-30 22:54:48 +0100
commit202871da44b51902d5bc22c50e930b2117f097b0 (patch)
treefbf71c25599a55811332e58fe6323b23f9f17f9b /src/crypto/scrypt.h
parentMerge pull request #2210 from rnicoll/1.21-block-subsidy (diff)
downloaddiscoin-202871da44b51902d5bc22c50e930b2117f097b0.tar.xz
discoin-202871da44b51902d5bc22c50e930b2117f097b0.zip
Litecoin: Add scrypt N=1024 PoW
Diffstat (limited to 'src/crypto/scrypt.h')
-rw-r--r--src/crypto/scrypt.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/crypto/scrypt.h b/src/crypto/scrypt.h
new file mode 100644
index 000000000..6ba31aee6
--- /dev/null
+++ b/src/crypto/scrypt.h
@@ -0,0 +1,49 @@
+#ifndef BITCOIN_CRYPTO_SCRYPT_H
+#define BITCOIN_CRYPTO_SCRYPT_H
+
+#include <stdlib.h>
+#include <stdint.h>
+
+static const int SCRYPT_SCRATCHPAD_SIZE = 131072 + 63;
+
+void scrypt_1024_1_1_256(const char *input, char *output);
+void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad);
+
+#if defined(USE_SSE2)
+#include <string>
+#if defined(_M_X64) || defined(__x86_64__) || defined(_M_AMD64) || (defined(MAC_OSX) && defined(__i386__))
+#define USE_SSE2_ALWAYS 1
+#define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_sse2((input), (output), (scratchpad))
+#else
+#define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_detected((input), (output), (scratchpad))
+#endif
+
+std::string scrypt_detect_sse2();
+void scrypt_1024_1_1_256_sp_sse2(const char *input, char *output, char *scratchpad);
+extern void (*scrypt_1024_1_1_256_sp_detected)(const char *input, char *output, char *scratchpad);
+#else
+#define scrypt_1024_1_1_256_sp(input, output, scratchpad) scrypt_1024_1_1_256_sp_generic((input), (output), (scratchpad))
+#endif
+
+void
+PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
+ size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen);
+
+#ifndef __FreeBSD__
+static inline uint32_t le32dec(const void *pp)
+{
+ const uint8_t *p = (uint8_t const *)pp;
+ return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
+ ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
+}
+
+static inline void le32enc(void *pp, uint32_t x)
+{
+ uint8_t *p = (uint8_t *)pp;
+ p[0] = x & 0xff;
+ p[1] = (x >> 8) & 0xff;
+ p[2] = (x >> 16) & 0xff;
+ p[3] = (x >> 24) & 0xff;
+}
+#endif
+#endif // BITCOIN_CRYPTO_SCRYPT_H