Skip to content

Commit c44b19a

Browse files
committed
1 parent 5c3b988 commit c44b19a

22 files changed

+558
-59
lines changed

vendor/cryptopp/config_align.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
#define CRYPTOPP_BOOL_ALIGN16 0
4040
#endif
4141

42+
// Required to remove crash when build with msvc
43+
// Discussion: https://groups.google.com/g/cryptopp-users/c/4FhTDREatGo/m/x1wUF1V7BQAJ
44+
#if defined(_MSC_VER)
45+
#undef CRYPTOPP_BOOL_ALIGN16
46+
#define CRYPTOPP_BOOL_ALIGN16 1
47+
#endif
48+
4249
// How to allocate 16-byte aligned memory (for SSE2)
4350
// posix_memalign see https://forum.kde.org/viewtopic.php?p=66274
4451
#if defined(CRYPTOPP_MSC_VERSION)

vendor/cryptopp/config_asm.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@
252252
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
253253
// Do not use APPLE_CLANG_VERSION; use __ARM_FEATURE_XXX instead.
254254
#if !defined(CRYPTOPP_ARM_ASIMD_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_ASIMD)
255-
# if defined(__aarch32__) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
255+
# if defined(__aarch32__) || defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
256256
# if defined(__ARM_NEON) || defined(__ARM_ASIMD) || defined(__ARM_FEATURE_NEON) || defined(__ARM_FEATURE_ASIMD) || \
257257
(CRYPTOPP_GCC_VERSION >= 40800) || (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || \
258258
(CRYPTOPP_APPLE_CLANG_VERSION >= 40000) || (CRYPTOPP_MSC_VERSION >= 1916)
@@ -265,7 +265,7 @@
265265
// ARMv8 and ASIMD. -march=armv8-a+crc or above must be present
266266
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
267267
#if !defined(CRYPTOPP_ARM_CRC32_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_CRC32)
268-
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
268+
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
269269
# if defined(__ARM_FEATURE_CRC32) || (CRYPTOPP_GCC_VERSION >= 40800) || \
270270
(CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
271271
(CRYPTOPP_MSC_VERSION >= 1916)
@@ -277,10 +277,10 @@
277277
// ARMv8 and AES. -march=armv8-a+crypto or above must be present
278278
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
279279
#if !defined(CRYPTOPP_ARM_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_AES)
280-
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
280+
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
281281
# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
282282
(CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
283-
(CRYPTOPP_MSC_VERSION >= 1916)
283+
(CRYPTOPP_MSC_VERSION >= 1916))
284284
# define CRYPTOPP_ARM_AES_AVAILABLE 1
285285
# endif // Compilers
286286
# endif // Platforms
@@ -289,10 +289,10 @@
289289
// ARMv8 and PMULL. -march=armv8-a+crypto or above must be present
290290
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
291291
#if !defined(CRYPTOPP_ARM_PMULL_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_PMULL)
292-
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
292+
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
293293
# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
294294
(CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
295-
(CRYPTOPP_MSC_VERSION >= 1916)
295+
(CRYPTOPP_MSC_VERSION >= 1916))
296296
# define CRYPTOPP_ARM_PMULL_AVAILABLE 1
297297
# endif // Compilers
298298
# endif // Platforms
@@ -301,10 +301,10 @@
301301
// ARMv8 and SHA-1, SHA-256. -march=armv8-a+crypto or above must be present
302302
// Requires GCC 4.8, Clang 3.3 or Visual Studio 2017
303303
#if !defined(CRYPTOPP_ARM_SHA_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SHA)
304-
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
304+
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
305305
# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_GCC_VERSION >= 40800) || \
306306
(CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 40300) || \
307-
(CRYPTOPP_MSC_VERSION >= 1916)
307+
(CRYPTOPP_MSC_VERSION >= 1916))
308308
# define CRYPTOPP_ARM_SHA1_AVAILABLE 1
309309
# define CRYPTOPP_ARM_SHA2_AVAILABLE 1
310310
# endif // Compilers
@@ -320,7 +320,7 @@
320320
// ARMv8 and SHA-512, SHA-3. -march=armv8.2-a+crypto or above must be present
321321
// Requires GCC 8.0, Clang 11.0, Apple Clang 12.0 or Visual Studio 20??
322322
#if !defined(CRYPTOPP_ARM_SHA3_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SHA)
323-
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
323+
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
324324
# if defined(__ARM_FEATURE_SHA3) || (CRYPTOPP_GCC_VERSION >= 80000) || \
325325
(CRYPTOPP_APPLE_CLANG_VERSION >= 120000) || (CRYPTOPP_LLVM_CLANG_VERSION >= 110000)
326326
# define CRYPTOPP_ARM_SHA512_AVAILABLE 1
@@ -333,7 +333,7 @@
333333
// Requires GCC 8.0, Clang ??? or Visual Studio 20??
334334
// Do not use APPLE_CLANG_VERSION; use __ARM_FEATURE_XXX instead.
335335
#if !defined(CRYPTOPP_ARM_SM3_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ARM_SM3)
336-
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64)
336+
# if defined(__aarch32__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
337337
# if defined(__ARM_FEATURE_SM3) || (CRYPTOPP_GCC_VERSION >= 80000)
338338
# define CRYPTOPP_ARM_SM3_AVAILABLE 1
339339
# define CRYPTOPP_ARM_SM4_AVAILABLE 1
@@ -344,7 +344,7 @@
344344
// Limit the <arm_neon.h> include.
345345
#if !defined(CRYPTOPP_ARM_NEON_HEADER)
346346
# if defined(CRYPTOPP_ARM_NEON_AVAILABLE) || defined (CRYPTOPP_ARM_ASIMD_AVAILABLE)
347-
# if !defined(_M_ARM64)
347+
# if !defined(_M_ARM64) &&!defined(_M_ARM64EC)
348348
# define CRYPTOPP_ARM_NEON_HEADER 1
349349
# endif
350350
# endif

vendor/cryptopp/config_cpu.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#define CRYPTOPP_BOOL_X86 ...
5353
#elif (defined(__ILP32__) || defined(_ILP32)) && defined(__x86_64__)
5454
#define CRYPTOPP_BOOL_X32 1
55-
#elif (defined(_M_X64) || defined(__x86_64__))
55+
#elif ((defined(_M_X64) && !defined(_M_ARM64EC)) || defined(__x86_64__))
5656
#define CRYPTOPP_BOOL_X64 1
5757
#elif (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__))
5858
#define CRYPTOPP_BOOL_X86 1
@@ -79,7 +79,7 @@
7979
// Microsoft added ARM64 define December 2017.
8080
#define CRYPTOPP_BOOL_ARMV8 1
8181
#endif
82-
#if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
82+
#if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
8383
#define CRYPTOPP_BOOL_ARM64 1
8484
#elif defined(__arm__) || defined(_M_ARM)
8585
#define CRYPTOPP_BOOL_ARM32 1

vendor/cryptopp/config_os.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
// https://www.cryptopp.com/wiki/Release_Process#Self_Tests
3030
// The problems with Clang pretending to be other compilers is
3131
// discussed at http://github.com/weidai11/cryptopp/issues/147.
32-
#if (defined(_MSC_VER) && defined(__clang__))
33-
# error: "Unsupported configuration"
32+
#if (defined(_MSC_VER) && defined(__clang__) && \
33+
!(defined( __clang_analyzer__)) && !defined(__INTEL_LLVM_COMPILER))
34+
//# error: "Unsupported configuration"
3435
#endif
3536

3637
// Windows platform

vendor/cryptopp/config_ver.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,28 @@
8484
# define CRYPTOPP_INTEL_VERSION (__INTEL_COMPILER)
8585
#endif
8686

87-
#if defined(_MSC_VER) && !defined(__clang__)
88-
# undef CRYPTOPP_LLVM_CLANG_VERSION
89-
# define CRYPTOPP_MSC_VERSION (_MSC_VER)
87+
#if defined(_MSC_VER)
88+
#include <yvals_core.h> // needed for _MSVC_STL_VERSION
89+
# if !defined(__clang__)
90+
# undef CRYPTOPP_LLVM_CLANG_VERSION
91+
# define CRYPTOPP_MSC_VERSION (_MSC_VER)
92+
# endif
93+
#endif
94+
95+
#if defined(_MSVC_STL_VERSION) // VS2017 (14.1) and above
96+
# define CRYPTOPP_MSSTL_VERSION _MSVC_STL_VERSION
97+
#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 650 // VS2015 (14.0)
98+
# define CRYPTOPP_MSSTL_VERSION 140
99+
#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 610 // VS2013 (12.0)
100+
# define CRYPTOPP_MSSTL_VERSION 120
101+
#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 540 // VS2012 (11.0)
102+
# define CRYPTOPP_MSSTL_VERSION 110
103+
#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 520 // VS2010 (10.0)
104+
# define CRYPTOPP_MSSTL_VERSION 100
105+
#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 505 // VS2008SP1 (9.0)
106+
# define CRYPTOPP_MSSTL_VERSION 91
107+
#elif defined(_CPPLIB_VER) && _CPPLIB_VER >= 503 // VS2008 (also 9.0)
108+
# define CRYPTOPP_MSSTL_VERSION 90
90109
#endif
91110

92111
// To control <x86intrin.h> include. May need a guard, like GCC 4.5 and above

vendor/cryptopp/cpu.cpp

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
// For IsProcessorFeaturePresent on Microsoft Arm64 platforms,
2424
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
25-
#if defined(_WIN32) && defined(_M_ARM64)
25+
#if defined(_WIN32) && (defined(_M_ARM64) || defined(_M_ARM64EC))
2626
# include <Windows.h>
2727
# include <processthreadsapi.h>
2828
#endif
@@ -147,6 +147,14 @@ inline bool IsVIA(const word32 output[4])
147147
(output[3] /*EDX*/ == 0x32414956));
148148
}
149149

150+
inline bool IsZhaoxin(const word32 output[4])
151+
{
152+
// This is the " Shanghai " string.
153+
return ((output[1] /*EBX*/ == 0x68532020) &&
154+
(output[2] /*ECX*/ == 0x20206961) &&
155+
(output[3] /*EDX*/ == 0x68676E61));
156+
}
157+
150158
#endif // X86, X32 and X64
151159

152160
#if defined(__APPLE__)
@@ -694,15 +702,34 @@ void DetectX86Features()
694702
}
695703
}
696704
}
697-
else if (IsVIA(cpuid0))
705+
else if (IsVIA(cpuid0) || IsZhaoxin(cpuid0))
698706
{
707+
CRYPTOPP_CONSTANT(RDRAND_FLAG = (1 << 30));
708+
CRYPTOPP_CONSTANT(RDSEED_FLAG = (1 << 18));
709+
CRYPTOPP_CONSTANT(ADX_FLAG = (1 << 19));
710+
CRYPTOPP_CONSTANT(SHA_FLAG = (1 << 29));
711+
CRYPTOPP_CONSTANT(AVX2_FLAG = (1 << 5));
712+
699713
// Two bits: available and enabled
700714
CRYPTOPP_CONSTANT( RNG_FLAGS = (0x3 << 2));
701715
CRYPTOPP_CONSTANT( ACE_FLAGS = (0x3 << 6));
702716
CRYPTOPP_CONSTANT(ACE2_FLAGS = (0x3 << 8));
703717
CRYPTOPP_CONSTANT( PHE_FLAGS = (0x3 << 10));
704718
CRYPTOPP_CONSTANT( PMM_FLAGS = (0x3 << 12));
705719

720+
g_hasRDRAND = (cpuid1[ECX_REG] & RDRAND_FLAG) != 0;
721+
722+
if (cpuid0[EAX_REG] >= 7)
723+
{
724+
if (CpuId(7, 0, cpuid2))
725+
{
726+
g_hasRDSEED = (cpuid2[EBX_REG] & RDSEED_FLAG) != 0;
727+
g_hasADX = (cpuid2[EBX_REG] & ADX_FLAG) != 0;
728+
g_hasSHA = (cpuid2[EBX_REG] & SHA_FLAG) != 0;
729+
g_hasAVX2 = (cpuid2[EBX_REG] & AVX2_FLAG) != 0;
730+
}
731+
}
732+
706733
CpuId(0xC0000000, 0, cpuid2);
707734
word32 extendedFeatures = cpuid2[0];
708735

@@ -716,9 +743,10 @@ void DetectX86Features()
716743
g_hasPadlockPMM = (cpuid2[EDX_REG] & PMM_FLAGS) != 0;
717744
}
718745

719-
if (extendedFeatures >= 0xC0000005)
720-
{
721-
CpuId(0xC0000005, 0, cpuid2);
746+
CpuId(0x80000000, 0, cpuid2);
747+
extendedFeatures = cpuid2[EAX_REG];
748+
if (extendedFeatures >= 0x80000005) {
749+
CpuId(0x80000005, 0, cpuid2);
722750
g_cacheLineSize = GETBYTE(cpuid2[ECX_REG], 0);
723751
}
724752
}
@@ -846,19 +874,24 @@ inline bool CPU_QueryARMv7()
846874
#if defined(__ANDROID__) && defined(__arm__)
847875
if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
848876
((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0))
877+
# define LOCALRET true
849878
return true;
850879
#elif defined(__linux__) && defined(__arm__)
851880
if ((getauxval(AT_HWCAP) & HWCAP_ARMv7) != 0 ||
852881
(getauxval(AT_HWCAP) & HWCAP_NEON) != 0)
853-
return true;
882+
# define LOCALRET true
854883
#elif defined(__APPLE__) && defined(__arm__)
855884
// Apple hardware is ARMv7 or above.
856885
return true;
857-
#elif defined(_WIN32) && defined(_M_ARM64)
886+
#elif defined(_WIN32) && (defined(_M_ARM64) || defined(_M_ARM64EC))
858887
// Windows 10 ARM64 is only supported on Armv8a and above
859-
return true;
888+
# define LOCALRET true
860889
#endif
861-
return false;
890+
#ifndef LOCALRET
891+
# define LOCALRET false
892+
#endif
893+
return LOCALRET;
894+
#undef LOCALRET
862895
}
863896

864897
inline bool CPU_QueryNEON()
@@ -884,7 +917,7 @@ inline bool CPU_QueryNEON()
884917
// Core feature set for Aarch32 and Aarch64.
885918
if (IsAppleMachineARMv8())
886919
return true;
887-
#elif defined(_WIN32) && defined(_M_ARM64)
920+
#elif defined(_WIN32) && (defined(_M_ARM64) || defined(_M_ARM64EC))
888921
// Windows 10 ARM64 is only supported on Armv8a and above
889922
if (IsProcessorFeaturePresent(PF_ARM_V8_INSTRUCTIONS_AVAILABLE) != 0)
890923
return true;
@@ -912,7 +945,7 @@ inline bool CPU_QueryCRC32()
912945
// M1 processor
913946
if (IsAppleMachineARMv82())
914947
return true;
915-
#elif defined(_WIN32) && defined(_M_ARM64)
948+
#elif defined(_WIN32) && (defined(_M_ARM64) || defined(_M_ARM64EC))
916949
if (IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE) != 0)
917950
return true;
918951
#endif
@@ -939,7 +972,7 @@ inline bool CPU_QueryPMULL()
939972
// M1 processor
940973
if (IsAppleMachineARMv82())
941974
return true;
942-
#elif defined(_WIN32) && defined(_M_ARM64)
975+
#elif defined(_WIN32) && (defined(_M_ARM64) || defined(_M_ARM64EC))
943976
if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != 0)
944977
return true;
945978
#endif
@@ -966,7 +999,7 @@ inline bool CPU_QueryAES()
966999
// M1 processor
9671000
if (IsAppleMachineARMv82())
9681001
return true;
969-
#elif defined(_WIN32) && defined(_M_ARM64)
1002+
#elif defined(_WIN32) && (defined(_M_ARM64) || defined(_M_ARM64EC))
9701003
if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != 0)
9711004
return true;
9721005
#endif
@@ -993,7 +1026,7 @@ inline bool CPU_QuerySHA1()
9931026
// M1 processor
9941027
if (IsAppleMachineARMv82())
9951028
return true;
996-
#elif defined(_WIN32) && defined(_M_ARM64)
1029+
#elif defined(_WIN32) && (defined(_M_ARM64) || defined(_M_ARM64EC))
9971030
if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != 0)
9981031
return true;
9991032
#endif
@@ -1020,7 +1053,7 @@ inline bool CPU_QuerySHA256()
10201053
// M1 processor
10211054
if (IsAppleMachineARMv82())
10221055
return true;
1023-
#elif defined(_WIN32) && defined(_M_ARM64)
1056+
#elif defined(_WIN32) && (defined(_M_ARM64) || defined(_M_ARM64EC))
10241057
if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != 0)
10251058
return true;
10261059
#endif

vendor/cryptopp/donna.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,76 @@ ed25519_sign_open(const byte *message, size_t messageLength, const byte publicKe
129129
int
130130
ed25519_sign_open(std::istream& stream, const byte publicKey[32], const byte signature[64]);
131131

132+
//**************************** bip32-ed25519 ****************************//
133+
134+
/// \brief Extend the Ed25519 key.
135+
/// \param secretKey byte array for the extended private key
136+
/// \param secretKey byte array with the private key (seed)
137+
/// \return 0 on success, non-0 otherwise
138+
int bip32_ed25519_extend(byte secretKey[64], const byte seed[32]);
139+
140+
/// \brief Creates a public key from an extended secret key
141+
/// \param publicKey byte array for the public key
142+
/// \param secretKey byte array with the extended private key
143+
/// \return 0 on success, non-0 otherwise
144+
/// \details ed25519_publickey() generates a public key from an extended
145+
/// secret key. Internally ed25519_publickey() performs a scalar
146+
/// multiplication using the secret key and then writes the result to
147+
/// <tt>publicKey</tt>.
148+
int bip32_ed25519_publickey(byte publicKey[32], const byte secretKey[64]);
149+
150+
/// \brief Creates a signature on a message
151+
/// \param message byte array with the message
152+
/// \param messageLength size of the message, in bytes
153+
/// \param publicKey byte array with the public key
154+
/// \param secretKey byte array with the extended private key
155+
/// \param signature byte array for the signature
156+
/// \return 0 on success, non-0 otherwise
157+
/// \details ed25519_sign() generates a signature on a message using
158+
/// the public and private keys. The various buffers can be exact
159+
/// sizes, and do not require extra space like when using the
160+
/// NaCl library functions.
161+
/// \details At the moment the hash function for signing is fixed at
162+
/// SHA512.
163+
int bip32_ed25519_sign(const byte* message, size_t messageLength, const byte secretKey[64], const byte publicKey[32], byte signature[64]);
164+
165+
/// \brief Creates a signature on a message
166+
/// \param stream std::istream derived class
167+
/// \param publicKey byte array with the public key
168+
/// \param secretKey byte array with the extended private key
169+
/// \param signature byte array for the signature
170+
/// \return 0 on success, non-0 otherwise
171+
/// \details ed25519_sign() generates a signature on a message using
172+
/// the public and private keys. The various buffers can be exact
173+
/// sizes, and do not require extra space like when using the
174+
/// NaCl library functions.
175+
/// \details This ed25519_sign() overload handles large streams. It
176+
/// was added for signing and verifying files that are too large
177+
/// for a memory allocation.
178+
/// \details At the moment the hash function for signing is fixed at
179+
/// SHA512.
180+
int bip32_ed25519_sign(std::istream& stream, const byte secretKey[64], const byte publicKey[32], byte signature[64]);
181+
182+
/// \brief Add the lower bytes of two secret keys as scalar values.
183+
/// \param secretKey1 byte array with the extended private key
184+
/// \param secretKey2 byte array with the extended private key
185+
/// \param res 32 byte array for the result
186+
/// \details Add the lower 32 bytes of two extended secret keys as two large scalars.
187+
/// The result is a 32 byte array. This may be used during child key
188+
/// derivation when the keys are part of BIP32 style wallets.
189+
/// \details We only need the leftmost 32 bytes of the extended secret key.
190+
int bip32_ed25519_scalar_add(const byte secretKey1[64], const byte secretKey2[64], byte res[32]);
191+
192+
/// \brief Add two public keys as curve 25519 points.
193+
/// \param publicKey1 byte array with the first public key to add.
194+
/// \param publicKey2 byte array with the second public key to add.
195+
/// \param res byte array with the public key result.
196+
/// \return A public key that is the result of the summation.
197+
/// \details Add two public keys as two points on the elliptic curve 25519. This is
198+
/// useful during child key derivation when the keys are part of BIP32 style
199+
/// wallets.
200+
int bip32_ed25519_point_add(const byte publicKey1[32], const byte publicKey2[32], byte res[32]);
201+
132202
//****************************** Internal ******************************//
133203

134204
#ifndef CRYPTOPP_DOXYGEN_PROCESSING

0 commit comments

Comments
 (0)