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
f77d01d
commit 83119db
Showing
12 changed files
with
675 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// +build cuda | ||
// Copyright 2019 cruzbit developers | ||
// Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. | ||
|
||
package cruzbit | ||
|
||
//#cgo LDFLAGS: -L./cuda/build -lcuda | ||
// | ||
// #include <stdint.h> | ||
// | ||
// extern int cuda_init(); | ||
// extern int miner_update(int miner_num, const void *first, size_t first_len, const void *last, | ||
// size_t last_len, const void *target); | ||
// extern int64_t miner_mine(int miner_num, int64_t start_nonce); | ||
// | ||
import "C" | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
const CUDA_ENABLED = true | ||
|
||
// CudaInit is called on startup. | ||
func CudaInit() int { | ||
return int(C.cuda_init()) | ||
} | ||
|
||
// CudaMinerUpdate is called by a miner goroutine when the underlying header changes. | ||
func CudaMinerUpdate(minerNum int, headerBytes []byte, headerBytesLen, startNonceOffset, endNonceOffset int, target BlockID) int64 { | ||
return int64(C.miner_update(C.int(minerNum), unsafe.Pointer(&headerBytes[0]), C.size_t(startNonceOffset), | ||
unsafe.Pointer(&headerBytes[endNonceOffset]), C.size_t(headerBytesLen-endNonceOffset), | ||
unsafe.Pointer(&target[0]))) | ||
} | ||
|
||
// CudaMine is called on every solution attempt by a miner goroutine. | ||
// It will perform N hashing attempts where N is the maximum number of threads your device is capable of executing. | ||
// Returns a solving nonce; otherwise 0x7FFFFFFFFFFFFFFF. | ||
func CudaMinerMine(minerNum int, startNonce int64) int64 { | ||
return int64(C.miner_mine(C.int(minerNum), C.int64_t(startNonce))) | ||
} |
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,9 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
project(cuda) | ||
find_package(CUDA REQUIRED) | ||
set(CUDA_SEPARABLE_COMPILATION ON) | ||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -Xcompiler -fPIC) | ||
CUDA_ADD_LIBRARY(cuda SHARED | ||
mine.cu | ||
sha3.cu | ||
) |
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 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Markku-Juhani O. Saarinen | ||
|
||
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,63 @@ | ||
# This is a CUDA port of tiny_sha3 which also includes mining specific calls for cruzbit. Original project's README follows. -asdvxgxasjab 19-Jul-19 | ||
|
||
# tiny_sha3 | ||
Very small, readable implementation of the FIPS 202 and SHA3 hash function. | ||
Public domain. | ||
|
||
### Updated 27-Dec-15: | ||
|
||
Added SHAKE128 and SHAKE256 code and test vectors. The code can actually do | ||
a XOF of arbitrary size (like "SHAKE512"). | ||
|
||
|
||
### Updated 03-Sep-15: | ||
|
||
Made the implementation portable. The API is now pretty much the | ||
same that OpenSSL uses. | ||
|
||
|
||
### Updated 07-Aug-15: | ||
|
||
Now that SHA3 spec is out, I've updated the package to match with the | ||
new padding rules. There is literally one line difference between | ||
Keccak 3.0 and SHA-3 implementations: | ||
|
||
``` | ||
temp[inlen++] = 0x06; // XXX Padding Changed from Keccak 3.0 | ||
``` | ||
|
||
The 0x06 constant there used to be 0x01. But this of course totally | ||
breaks compatibility and test vectors had to be revised. | ||
|
||
SHA-3 Spec: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf | ||
|
||
Cheers, | ||
- markku | ||
|
||
|
||
### Original README.TXT from 19-Nov-11: | ||
|
||
Hi. | ||
|
||
The SHA-3 competition is nearing it's end and I would personally like | ||
to support Keccak as the winner. I have a PhD in hash function cryptanalysis | ||
so don't take my word for it, go ahead and look into the code ! | ||
|
||
Since I couldn't find a *compact* and/or *readable* implementation of Keccak | ||
anywhere, here's one I cooked up as a service to the curious. | ||
|
||
This implementation is intended for study of the algorithm, not for | ||
production use. | ||
|
||
The code works correctly on 64-bit little-endian platforms with gcc. | ||
Like your Linux box. The main.c module contains self-tests for all | ||
officially supported hash sizes. | ||
|
||
If you're looking for production code, the official multi-megabyte package | ||
covers everyting you could possibly need and too much much more: | ||
http://keccak.noekeon.org/ | ||
|
||
Cheers, | ||
- Markku 19-Nov-11 | ||
|
||
Dr. Markku-Juhani O. Saarinen <mjos@iki.fi> |
Oops, something went wrong.