Skip to content

Commit

Permalink
Add YespowerMGPC Algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolin1579 committed Jul 17, 2024
1 parent 58cca80 commit f2668a0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Miningcore/Crypto/Hashing/Algorithms/YespowerMGPC.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Miningcore.Contracts;
using Miningcore.Native;

namespace Miningcore.Crypto.Hashing.Algorithms;

[Identifier("yespowermgpc")]
public unsafe class YespowerMGPC : IHashAlgorithm
{
public void Digest(ReadOnlySpan<byte> data, Span<byte> result, params object[] extra)
{
Contract.Requires<ArgumentException>(result.Length >= 32);

fixed (byte* input = data)
{
fixed (byte* output = result)
{
Multihash.yespowerMGPC(input, output, (uint) data.Length);
}
}
}
}
3 changes: 3 additions & 0 deletions src/Miningcore/Native/Multihash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ public static unsafe class Multihash
[DllImport("libmultihash", EntryPoint = "yespowerR16_export", CallingConvention = CallingConvention.Cdecl)]
public static extern void yespowerR16(byte* input, void* output, uint inputLength);

[DllImport("libmultihash", EntryPoint = "yespowerMGPC_export", CallingConvention = CallingConvention.Cdecl)]
public static extern void yespowerMGPC(byte* input, void* output, uint inputLength);

[DllImport("libmultihash", EntryPoint = "yespowerTIDE_export", CallingConvention = CallingConvention.Cdecl)]
public static extern void yespowerTIDE(byte* input, void* output, uint inputLength);

Expand Down
5 changes: 5 additions & 0 deletions src/Native/libmultihash/exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ extern "C" MODULE_API void yespowerIC_export(const char *input, char *output, ui
yespowerIC_hash(input, output, input_len);
}

extern "C" MODULE_API void yespowerMGPC_export(const char *input, char *output, uint32_t input_len)
{
yespowerMGPC_hash(input, output, input_len);
}

extern "C" MODULE_API void yespowerR16_export(const char *input, char *output, uint32_t input_len)
{
yespowerR16_hash(input, output, input_len);
Expand Down

0 comments on commit f2668a0

Please sign in to comment.