Git Product home page Git Product logo

zcash-pow's Issues

Digest length used in print-soln

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.

Use python2 by default

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)

have problem with print-soln

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.

Remove the n/(k+1) restriction

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.)

I am learning Zcash how it work by reading code,but this codes seems does not work.

./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

exception inside `has_collision`

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

Failure in progressbar plot in the final round routine

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 

local variable 'bar' referenced before assignment

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.