str4d / zcash-pow Goto Github PK
View Code? Open in Web Editor NEWThe proof-of-work algorithm for Zcash
The proof-of-work algorithm for Zcash
Hello,
is this implementation still in sync with the one used by the official C++ version? ( https://github.com/zcash/zcash )
Or more specifically: do the test vectors lead to the same solutions?
Am looking to help the project and I wanted to start understanding equihash using the python version first.
I think print-soln.py
is not setting the blake 2b digest length correctly. It is using n/8
(=25) on line 34 where other code, especially test-pow.py
is using (512/n)*n/8
(=50). As discussed in the zcash paper, this will give different hashes because the digest length is captured into the blake2b personalization.
When I run it on my system:
[firexware@firexware-pc python]$ chmod +x pow.py
[firexware@firexware-pc python]$ ./pow.py
File "./pow.py", line 41
if DEBUG: print 'Generating first list'
^
SyntaxError: Missing parentheses in call to 'print'
To fix it, change the first line to:
#!/usr/bin/env python2
(edit: forgot the 2)
Please make a python3 version 🙏
Hi ,
When i use print-soln with this command
./print-soln.py 200 9 218212
or
./print-soln.py 200 9 040000002196d61ff5b780728164a5f79d12d5c10a1f1436bcccc26f11bb781000000000177808bbff5a354013843ac855c65dd4cf8a40dca25ca2babffcfaf43e13fa130000000000000000000000000000000000000000000000000000000000000000eb2c085a6146151c04c7d48cf5c0a8f701dd4d200000000000000000000000000000000000000000
In both of them this error will be shown
Traceback (most recent call last):
File "./print-soln.py", line 86, in
print_hashes(*generate_hashes(args.n, args.k, unhexlify(args.header)))
File "./print-soln.py", line 51, in generate_hashes
num_bytes = ord(header[140]) if ord(header[140]) < 253 else struct.unpack('<H', header[141:143])[0]
IndexError: string index out of range
thanks.
In zcash/zcash#1172 we removed the requirement that n/(k+1) mod 8 = 0
in order to support a wider range of parameters. The same modifications should be made here to ensure compatibility.
(Note that the test vectors will be unchanged by this and all still match the C++ router, because they use parameters that satisfy the above requirement.)
./print-soln.py 200 9 "04000000e54c27544050668f272ec3b460e1cde745c6b21239a81dae637fde4704000000844bc0c55696ef9920eeda11c1eb41b0c2e7324b46cc2e7aa0c2aa7736448d7a000000000000000000000000000000000000000000000000000000000000000068241a587e7e061d250e000000000000010000000000000000000000000000000000000000000000"
Traceback (most recent call last):
File "./print-soln.py", line 60, in
print_hashes(*generate_hashes(args.n, args.k, unhexlify(args.header)))
File "./print-soln.py", line 36, in generate_hashes
numIndices = ord(header[140]) if ord(header[140]) < 256 else struct.unpack('<H', header[141:143])
IndexError: string index out of range
Suspect it might have something to do with the ridiculously small args I gave…
zooko@spark ~/playground/zcash-pow/reference/python $ python pow.py -n 1 -k 2 -d 1
Miner starting
- n: 1
- k: 2
- d: 1
Traceback (most recent call last):
File "pow.py", line 188, in <module>
mine(args.n, args.k, args.d)
File "pow.py", line 147, in mine
x = gbp_basic(curr_digest, n, k)
File "pow.py", line 65, in gbp_basic
if not has_collision(X[j][0], X[k][0], i, collision_length):
File "pow.py", line 28, in has_collision
return reduce(lambda x, y: x and y, res)
TypeError: reduce() of empty sequence with no initial value
I took it out of lines 70-71 in pow.py
Ran test-pow.py and it works just fine??
I get an error using the verbosity mode in zcash-pow. The progressbar fails to plot for some reason:
Miner starting
- n: 96
- k: 5
- d: 3
Nonce: 0
Generating first list
100% (131072 of 131072) |##############################################################################################################################################| Elapsed Time: 0:00:01 Time: 0:00:01
Round 1:
- Sorting list
- Finding collisions
100% (131072 of 131072) |##############################################################################################################################################| Elapsed Time: 0:00:01 Time: 0:00:01
Round 2:
- Sorting list
- Finding collisions
100% (130948 of 130948) |##############################################################################################################################################| Elapsed Time: 0:00:01 Time: 0:00:01
Round 3:
- Sorting list
- Finding collisions
100% (131030 of 131030) |##############################################################################################################################################| Elapsed Time: 0:00:01 Time: 0:00:01
Round 4:
- Sorting list
- Finding collisions
100% (131085 of 131085) |##############################################################################################################################################| Elapsed Time: 0:00:02 Time: 0:00:02
Final round:
- Sorting list
- Finding collisions
Traceback (most recent call last):
File "./pow.py", line 236, in <module>
mine(args.n, args.k, args.d)
File "./pow.py", line 186, in mine
solns = gbp_basic(curr_digest, n, k)
File "./pow.py", line 112, in gbp_basic
for i in bar(range(0, len(X)-1)):
File "/usr/local/lib/python2.7/dist-packages/progressbar/bar.py", line 376, in __next__
self.start()
File "/usr/local/lib/python2.7/dist-packages/progressbar/bar.py", line 539, in start
self.update(self.min_value, force=True)
File "/usr/local/lib/python2.7/dist-packages/progressbar/bar.py", line 496, in update
StdRedirectMixin.update(self, value=value)
File "/usr/local/lib/python2.7/dist-packages/progressbar/bar.py", line 119, in update
if self.redirect_stdout and sys.stdout.tell():
IOError: [Errno 29] Illegal seek
I cloned the repository, installed progressbar2 via pip and executed:
./pow.py -v
I tried to run it and this happened:
[firexware@firexware-pc python]$ ./pow.py
Miner starting
- n: 96
- k: 5
- d: 3
Traceback (most recent call last):
File "./pow.py", line 217, in <module>
mine(args.n, args.k, args.d)
File "./pow.py", line 162, in mine
solns = gbp_basic(curr_digest, n, k)
File "./pow.py", line 44, in gbp_basic
for i in bar(range(0, 2**(collision_length+1))):
UnboundLocalError: local variable 'bar' referenced before assignment
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.