-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a63edf3
commit f28b57f
Showing
35 changed files
with
256 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#Types. | ||
from typing import Any | ||
|
||
#CTypes. | ||
from ctypes import cdll, c_int, c_char, \ | ||
Array, c_char_p, c_void_p, create_string_buffer, byref | ||
|
||
#OS standard lib. | ||
import os | ||
|
||
#Import the RandomX library. | ||
#pylint: disable=invalid-name | ||
RandomXLib: Any | ||
if os.name == "nt": | ||
RandomXLib = cdll.LoadLibrary("PythonTests/Libs/mc_randomx/RandomX/build/randomx") | ||
else: | ||
RandomXLib = cdll.LoadLibrary("PythonTests/Libs/mc_randomx/RandomX/build/librandomx.so") | ||
|
||
#Define the function types. | ||
RandomXLib.randomx_get_flags.randomx_get_flags = None | ||
RandomXLib.randomx_get_flags.restype = c_int | ||
|
||
RandomXLib.randomx_alloc_cache.argtypes = [c_int] | ||
RandomXLib.randomx_alloc_cache.restype = c_void_p | ||
|
||
RandomXLib.randomx_init_cache.argtypes = [c_void_p, c_char_p, c_int] | ||
RandomXLib.randomx_init_cache.restype = None | ||
|
||
RandomXLib.randomx_create_vm.argtypes = [c_int, c_void_p, c_void_p] | ||
RandomXLib.randomx_create_vm.restype = c_void_p | ||
|
||
RandomXLib.randomx_vm_set_cache.argtypes = [c_void_p, c_void_p] | ||
RandomXLib.randomx_vm_set_cache.restype = None | ||
|
||
RandomXLib.randomx_calculate_hash.argtypes = [c_void_p, c_char_p, c_int, c_void_p] | ||
RandomXLib.randomx_calculate_hash.restype = None | ||
|
||
flags: c_int = RandomXLib.randomx_get_flags() | ||
cache: c_void_p = RandomXLib.randomx_alloc_cache(flags) | ||
RandomXLib.randomx_init_cache(cache, None, 0) | ||
vm: c_void_p = RandomXLib.randomx_create_vm(flags, cache, None) | ||
|
||
def setRandomXKey( | ||
key: bytes | ||
) -> None: | ||
RandomXLib.randomx_init_cache(cache, c_char_p(key), c_int(len(key))) | ||
RandomXLib.randomx_vm_set_cache(vm, cache) | ||
|
||
def RandomX( | ||
data: bytes | ||
) -> bytes: | ||
hashResult: Array[c_char] = create_string_buffer(48) | ||
RandomXLib.randomx_calculate_hash(vm, c_char_p(data), c_int(len(data)), byref(hashResult)) | ||
|
||
result: bytes = bytes() | ||
for b in hashResult: | ||
result += b | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"blockchain": [{"transactions": [], "elements": [], "aggregate": "C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "header": {"version": 0, "last": "74E8778118160833C86ACC64952C9BC44F2E4AEA4BAB21A8C49A56EC22FC97AAF6EE9D0D2A2BD9B8204711A4DE30EC07", "contents": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "significant": 1, "sketchSalt": "00000000", "sketchCheck": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "miner": "95CCC3FEFF7E76B0C40F2790DB6988823D9B7A7819B241EED4187A0A4356441CE3342DF1911566A9E56CCA909D8A3AE7033AA53930B7C29A0137B3B36E24186776FC7E67CBE4C5EFFAAC61F52B9AF361594C42ED351CDE7624D949D520B71028", "time": 1200, "proof": 30, "signature": "A741CC8FCBAC767A3F680361729FC69E464708DDF009BBAF5043E89CD64BAE677EF144BE587FD8B4115A9B79761DD3E0"}, "hash": "FDFF5716D4C88705F2B17E5E4EE2F2F356324204E3EB1C5273F9DA86E86CA23CD88A3F4A9373C03A5838323F721DE965"}, {"transactions": [{"hash": "49E0C9ED8396782F3D464164E2385FE7DB38018063DE36738E83FB6B11A3015093872BF887C8981085CFE1674B081C10", "holders": [0]}], "elements": [], "aggregate": "98D5FDE32C4FC65F2FD182CEB6978E6EC5F3EC14220BE865A4967DBD1AA82FB67851CB4747609D32134464716174527A", "header": {"version": 0, "last": "FDFF5716D4C88705F2B17E5E4EE2F2F356324204E3EB1C5273F9DA86E86CA23CD88A3F4A9373C03A5838323F721DE965", "contents": "549D8BB691D77510453A0ECDB2F59C684160ACDC7E8948C99DABCEF06858D57EF4E082253966FDEE1725B360744BC978", "significant": 1, "sketchSalt": "00000000", "sketchCheck": "399B811189E47FB3C56942BE16BACE4D9A9BFE8FF84E0BFF054499C1A33723706161D00CAA172E46C9382F19C4F27415", "miner": 0, "time": 2400, "proof": 71, "signature": "B273C62F0FB4076E3685C48680C134E89ED258CF58AA225CBE02B52E3847175EB26FFC9E7937BC5DB6DECC202D1E1DFB"}, "hash": "FE8C5ED9FE639A4B1EB7EB2FCBB51D3D97CE639C2D7DBB8250F18FAFFCFE4A7C908A28B4AD5CFD704402C081F33DEFF5"}], "data": {"descendant": "Data", "inputs": [{"hash": "000000000000000000000000000000003B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"}], "outputs": [], "hash": "49E0C9ED8396782F3D464164E2385FE7DB38018063DE36738E83FB6B11A3015093872BF887C8981085CFE1674B081C10", "data": "", "signature": "02F39E94E5FC6C7E52956DBA2453DAF6073EDF055D115B8279BC060AFA21CA06627BC630F5848B5612C7CEA7F0B8E62A8054E8393DA1CFB1FDE420D5E090E20D", "proof": 4, "argon": "DE19CE192BCA6F72E13623D63FE60878F7A9E10F21C6ECCD9F2B092B1BF543A50EBDFFD73DD9ACC6FF8724D351444C7C"}} | ||
{"blockchain": [{"transactions": [], "elements": [], "aggregate": "C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "header": {"version": 0, "last": "A381B334EE43CA7A7E6BC3836CDF090DE361A003699D2F1F5477674E700BF6B36856982776DA913E3BF13EB3CB6BDD1B", "contents": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "significant": 1, "sketchSalt": "00000000", "sketchCheck": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "miner": "95CCC3FEFF7E76B0C40F2790DB6988823D9B7A7819B241EED4187A0A4356441CE3342DF1911566A9E56CCA909D8A3AE7033AA53930B7C29A0137B3B36E24186776FC7E67CBE4C5EFFAAC61F52B9AF361594C42ED351CDE7624D949D520B71028", "time": 1200, "proof": 44, "signature": "8CF042324180498A5A6770D60067E14879A38780F99BC13C0090FE1EE9C43E7EBE7C980ABBA4896D580CBA53E3CA6F0F"}, "hash": "FDC5113BBCA00BE1353C487EE93BE44AC313F9729C2B7BE0229B6C828ABDE629DDF37BD1E2034C60E5E4E811586394D1"}, {"transactions": [{"hash": "49E0C9ED8396782F3D464164E2385FE7DB38018063DE36738E83FB6B11A3015093872BF887C8981085CFE1674B081C10", "holders": [0]}], "elements": [], "aggregate": "98D5FDE32C4FC65F2FD182CEB6978E6EC5F3EC14220BE865A4967DBD1AA82FB67851CB4747609D32134464716174527A", "header": {"version": 0, "last": "FDC5113BBCA00BE1353C487EE93BE44AC313F9729C2B7BE0229B6C828ABDE629DDF37BD1E2034C60E5E4E811586394D1", "contents": "549D8BB691D77510453A0ECDB2F59C684160ACDC7E8948C99DABCEF06858D57EF4E082253966FDEE1725B360744BC978", "significant": 1, "sketchSalt": "00000000", "sketchCheck": "399B811189E47FB3C56942BE16BACE4D9A9BFE8FF84E0BFF054499C1A33723706161D00CAA172E46C9382F19C4F27415", "miner": 0, "time": 2400, "proof": 67, "signature": "879BE3D8C5CA5C196FF54B012EDD27E0FD42ACAE8D74DAA5F40CA8FDE26FF49678AECE93C8CEC130EC682DEFA638B079"}, "hash": "FDA1F012FE22B8E96CF79D4EE172CA2FC6E977E4C10DC5494472896420FD30AA8D18B68FE3DF228869C2531776AE04CA"}], "data": {"descendant": "Data", "inputs": [{"hash": "000000000000000000000000000000003B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"}], "outputs": [], "hash": "49E0C9ED8396782F3D464164E2385FE7DB38018063DE36738E83FB6B11A3015093872BF887C8981085CFE1674B081C10", "data": "", "signature": "02F39E94E5FC6C7E52956DBA2453DAF6073EDF055D115B8279BC060AFA21CA06627BC630F5848B5612C7CEA7F0B8E62A8054E8393DA1CFB1FDE420D5E090E20D", "proof": 4, "argon": "DE19CE192BCA6F72E13623D63FE60878F7A9E10F21C6ECCD9F2B092B1BF543A50EBDFFD73DD9ACC6FF8724D351444C7C"}} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.