forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in ion_hash (pull request #14)
Create ion_hash in contrib directory Approved-by: Cevap
- Loading branch information
Showing
31 changed files
with
22,201 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014-2015 The Dash (Darkcoin) Developers | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,29 @@ | ||
ion_hash (python) v1.3.1 | ||
=========================== | ||
|
||
Python module for Ion's X11 hashing. | ||
|
||
|
||
Install | ||
------- | ||
|
||
Python 2.7+ or 3.5+ is required as well as a gcc. | ||
|
||
$ sudo python setup.py install | ||
|
||
|
||
Test | ||
------- | ||
|
||
After installation, test hash. | ||
|
||
$ python test.py | ||
|
||
Credits | ||
------- | ||
|
||
* Module written by @chaeplin https://github.com/chaeplin/xcoin-hash | ||
* Module maintained by @eduffield https://github.com/darkcoinproject/xcoin-hash | ||
* Module maintained by @flare https://github.com/nightlydarkcoin/xcoin-hash | ||
* Module maintained by @vertoe https://github.com/vertoe/darkcoin_hash | ||
* Module forked and customized for ion by @ckti https://bitbucket.org/cktii2p/ion_hash |
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,85 @@ | ||
#include "ion.h" | ||
#include <stdlib.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
|
||
#include "sha3/sph_blake.h" | ||
#include "sha3/sph_bmw.h" | ||
#include "sha3/sph_groestl.h" | ||
#include "sha3/sph_jh.h" | ||
#include "sha3/sph_keccak.h" | ||
#include "sha3/sph_skein.h" | ||
#include "sha3/sph_luffa.h" | ||
#include "sha3/sph_cubehash.h" | ||
#include "sha3/sph_shavite.h" | ||
#include "sha3/sph_simd.h" | ||
#include "sha3/sph_echo.h" | ||
|
||
|
||
void ion_hash(const char* input, int len, char* output) | ||
{ | ||
sph_blake512_context ctx_blake; | ||
sph_bmw512_context ctx_bmw; | ||
sph_groestl512_context ctx_groestl; | ||
sph_skein512_context ctx_skein; | ||
sph_jh512_context ctx_jh; | ||
sph_keccak512_context ctx_keccak; | ||
|
||
sph_luffa512_context ctx_luffa1; | ||
sph_cubehash512_context ctx_cubehash1; | ||
sph_shavite512_context ctx_shavite1; | ||
sph_simd512_context ctx_simd1; | ||
sph_echo512_context ctx_echo1; | ||
|
||
//these uint512 in the c++ source of the client are backed by an array of uint32 | ||
uint32_t hashA[16], hashB[16]; | ||
|
||
sph_blake512_init(&ctx_blake); | ||
sph_blake512 (&ctx_blake, input, len); | ||
sph_blake512_close (&ctx_blake, hashA); | ||
|
||
sph_bmw512_init(&ctx_bmw); | ||
sph_bmw512 (&ctx_bmw, hashA, 64); | ||
sph_bmw512_close(&ctx_bmw, hashB); | ||
|
||
sph_groestl512_init(&ctx_groestl); | ||
sph_groestl512 (&ctx_groestl, hashB, 64); | ||
sph_groestl512_close(&ctx_groestl, hashA); | ||
|
||
sph_skein512_init(&ctx_skein); | ||
sph_skein512 (&ctx_skein, hashA, 64); | ||
sph_skein512_close (&ctx_skein, hashB); | ||
|
||
sph_jh512_init(&ctx_jh); | ||
sph_jh512 (&ctx_jh, hashB, 64); | ||
sph_jh512_close(&ctx_jh, hashA); | ||
|
||
sph_keccak512_init(&ctx_keccak); | ||
sph_keccak512 (&ctx_keccak, hashA, 64); | ||
sph_keccak512_close(&ctx_keccak, hashB); | ||
|
||
sph_luffa512_init (&ctx_luffa1); | ||
sph_luffa512 (&ctx_luffa1, hashB, 64); | ||
sph_luffa512_close (&ctx_luffa1, hashA); | ||
|
||
sph_cubehash512_init (&ctx_cubehash1); | ||
sph_cubehash512 (&ctx_cubehash1, hashA, 64); | ||
sph_cubehash512_close(&ctx_cubehash1, hashB); | ||
|
||
sph_shavite512_init (&ctx_shavite1); | ||
sph_shavite512 (&ctx_shavite1, hashB, 64); | ||
sph_shavite512_close(&ctx_shavite1, hashA); | ||
|
||
sph_simd512_init (&ctx_simd1); | ||
sph_simd512 (&ctx_simd1, hashA, 64); | ||
sph_simd512_close(&ctx_simd1, hashB); | ||
|
||
sph_echo512_init (&ctx_echo1); | ||
sph_echo512 (&ctx_echo1, hashB, 64); | ||
sph_echo512_close(&ctx_echo1, hashA); | ||
|
||
memcpy(output, hashA, 32); | ||
|
||
} | ||
|
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,14 @@ | ||
#ifndef ION_H | ||
#define ION_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void ion_hash(const char* input, int len, char* output); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
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,57 @@ | ||
#include <Python.h> | ||
|
||
#include "ion.h" | ||
|
||
static PyObject *ion_getpowhash(PyObject *self, PyObject *args) | ||
{ | ||
char *output; | ||
PyObject *value; | ||
#if PY_MAJOR_VERSION >= 3 | ||
PyBytesObject *input; | ||
#else | ||
PyStringObject *input; | ||
#endif | ||
if (!PyArg_ParseTuple(args, "S", &input)) | ||
return NULL; | ||
Py_INCREF(input); | ||
output = PyMem_Malloc(32); | ||
|
||
#if PY_MAJOR_VERSION >= 3 | ||
ion_hash((char *)PyBytes_AsString((PyObject*) input), (int)PyBytes_Size((PyObject*) input), output); | ||
#else | ||
ion_hash((char *)PyString_AsString((PyObject*) input), (int)PyString_Size((PyObject*) input), output); | ||
#endif | ||
Py_DECREF(input); | ||
#if PY_MAJOR_VERSION >= 3 | ||
value = Py_BuildValue("y#", output, 32); | ||
#else | ||
value = Py_BuildValue("s#", output, 32); | ||
#endif | ||
PyMem_Free(output); | ||
return value; | ||
} | ||
|
||
static PyMethodDef DashMethods[] = { | ||
{ "getPoWHash", ion_getpowhash, METH_VARARGS, "Returns the proof of work hash using ion hash" }, | ||
{ NULL, NULL, 0, NULL } | ||
}; | ||
|
||
#if PY_MAJOR_VERSION >= 3 | ||
static struct PyModuleDef DashModule = { | ||
PyModuleDef_HEAD_INIT, | ||
"ion_hash", | ||
"...", | ||
-1, | ||
DashMethods | ||
}; | ||
|
||
PyMODINIT_FUNC PyInit_ion_hash(void) { | ||
return PyModule_Create(&DashModule); | ||
} | ||
|
||
#else | ||
|
||
PyMODINIT_FUNC inition_hash(void) { | ||
(void) Py_InitModule("ion_hash", DashMethods); | ||
} | ||
#endif |
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,22 @@ | ||
from distutils.core import setup, Extension | ||
|
||
ion_hash_module = Extension('ion_hash', | ||
sources = ['ionmodule.c', | ||
'ion.c', | ||
'sha3/blake.c', | ||
'sha3/bmw.c', | ||
'sha3/groestl.c', | ||
'sha3/jh.c', | ||
'sha3/keccak.c', | ||
'sha3/skein.c', | ||
'sha3/cubehash.c', | ||
'sha3/echo.c', | ||
'sha3/luffa.c', | ||
'sha3/simd.c', | ||
'sha3/shavite.c'], | ||
include_dirs=['.', './sha3']) | ||
|
||
setup (name = 'ion_hash', | ||
version = '1.3.1', | ||
description = 'Binding for Dash X11 proof of work hashing.', | ||
ext_modules = [ion_hash_module]) |
Oops, something went wrong.