Remove dependency on pyblake2.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2022-02-02 02:25:52 +00:00
parent df2a648ac4
commit 49a20a87d7
16 changed files with 29 additions and 45 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2b
from hashlib import blake2b
from zcash_test_vectors.output import render_args, render_tv
from zcash_test_vectors.f4jumble import f4jumble, f4jumble_inv, MAX_l_M

21
poetry.lock generated
View File

@ -48,14 +48,6 @@ category = "main"
optional = false
python-versions = ">=3.7"
[[package]]
name = "pyblake2"
version = "1.1.2"
description = "BLAKE2 hash function extension module"
category = "main"
optional = false
python-versions = "*"
[[package]]
name = "pycparser"
version = "2.21"
@ -78,7 +70,7 @@ cffi = ">=1.3.0"
[metadata]
lock-version = "1.1"
python-versions = "^3.7"
content-hash = "e010c1cdcddf9d8e5d49d7b1578d95e966b4271158567cebf4cca1c2ac0e5b89"
content-hash = "948efde6d090bec2749dc1b557f3147dc0e33a98d8b12ddc41c8a7ffb07ea8ba"
[metadata.files]
cffi = [
@ -189,17 +181,6 @@ numpy = [
{file = "numpy-1.21.0-pp37-pypy37_pp73-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3c40e6b860220ed862e8097b8f81c9af6d7405b723f4a7af24a267b46f90e461"},
{file = "numpy-1.21.0.zip", hash = "sha256:e80fe25cba41c124d04c662f33f6364909b985f2eb5998aaa5ae4b9587242cce"},
]
pyblake2 = [
{file = "pyblake2-1.1.2-cp27-cp27m-win32.whl", hash = "sha256:3757f7ad709b0e1b2a6b3919fa79fe3261f166fc375cd521f2be480f8319dde9"},
{file = "pyblake2-1.1.2-cp27-cp27m-win_amd64.whl", hash = "sha256:8043267fbc0b2f3748c6920591cd0b8b5609dcce60c504c32858aa36206386f2"},
{file = "pyblake2-1.1.2-cp34-cp34m-win32.whl", hash = "sha256:4d47b4a2c1d292b1e460bde1dda4d13aa792ed2ed70fcc263b6bc24632c8e902"},
{file = "pyblake2-1.1.2-cp34-cp34m-win_amd64.whl", hash = "sha256:982295a87907d50f4723db6bc724660da76b6547826d52160171d54f95b919ac"},
{file = "pyblake2-1.1.2-cp35-cp35m-win32.whl", hash = "sha256:baa2190bfe549e36163aa44664d4ee3a9080b236fc5d42f50dc6fd36bbdc749e"},
{file = "pyblake2-1.1.2-cp35-cp35m-win_amd64.whl", hash = "sha256:407e02c7f8f36fcec1b7aa114ddca0c1060c598142ea6f6759d03710b946a7e3"},
{file = "pyblake2-1.1.2-cp36-cp36m-win32.whl", hash = "sha256:fbc9fcde75713930bc2a91b149e97be2401f7c9c56d735b46a109210f58d7358"},
{file = "pyblake2-1.1.2-cp36-cp36m-win_amd64.whl", hash = "sha256:c53417ee0bbe77db852d5fd1036749f03696ebc2265de359fe17418d800196c4"},
{file = "pyblake2-1.1.2.tar.gz", hash = "sha256:5ccc7eb02edb82fafb8adbb90746af71460fbc29aa0f822526fc976dff83e93f"},
]
pycparser = [
{file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"},
{file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"},

View File

@ -26,7 +26,6 @@ python = "^3.7"
numpy = "1.21.0"
chacha20poly1305 = "0.0.3"
cryptography = "36.0.0"
pyblake2 = "1.1.2"
secp256k1 = "0.14.0"
[tool.poetry.scripts]

View File

@ -1,11 +1,10 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from hashlib import blake2b
import math
import struct
from pyblake2 import blake2b
from .output import render_args, render_tv
from .rand import Rand
from .utils import i2leosp

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2s
from hashlib import blake2s
from ..output import render_args, render_tv
from .group_hash import group_hash

View File

@ -1,11 +1,11 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from hashlib import blake2b
import math
from . import iso_pallas
from pyblake2 import blake2b
from .pallas import Fp, p, q, PALLAS_B, Point
from .iso_pallas import PALLAS_ISO_B, PALLAS_ISO_A
from ..utils import i2beosp, cldiv, beos2ip, i2leosp, lebs2ip

View File

@ -1,11 +1,11 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from chacha20poly1305 import ChaCha20Poly1305
from hashlib import blake2b
import os
import struct
from chacha20poly1305 import ChaCha20Poly1305
import os
from pyblake2 import blake2b
from ..transaction import MAX_MONEY
from ..output import render_args, render_tv
from ..rand import Rand

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2s
from hashlib import blake2s
from .jubjub import Point, JUBJUB_COFACTOR
from ..output import render_args, render_tv

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2b, blake2s
from hashlib import blake2b, blake2s
from .generators import PROVING_KEY_BASE, SPENDING_KEY_BASE, group_hash
from .jubjub import Fr

View File

@ -2,8 +2,8 @@
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from chacha20poly1305 import ChaCha20Poly1305
from hashlib import blake2b
import os
from pyblake2 import blake2b
import struct
from .generators import VALUE_COMMITMENT_VALUE_BASE, VALUE_COMMITMENT_RANDOMNESS_BASE

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2s
from hashlib import blake2s
from .pedersen import (
mixing_pedersen_hash,

View File

@ -1,8 +1,8 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from hashlib import blake2b
import os
from pyblake2 import blake2b
from .generators import SPENDING_KEY_BASE
from .jubjub import Fr, Point, r_j

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2b
from hashlib import blake2b
from .key_components import to_scalar, prf_expand, diversify_hash, DerivedAkNk, DerivedIvk
from .generators import SPENDING_KEY_BASE, PROVING_KEY_BASE
@ -42,8 +42,9 @@ class ExtendedBase(object):
return d if diversify_hash(d) else None
def fingerprint(self):
FVK = bytes(self.ak()) + bytes(self.nk()) + self.ovk()
return blake2b(person=b'ZcashSaplingFVFP', digest_size=32, data=FVK).digest()
digest = blake2b(person=b'ZcashSaplingFVFP', digest_size=32)
digest.update(bytes(self.ak()) + bytes(self.nk()) + self.ovk())
return digest.digest()
def tag(self):
return self.fingerprint()[:4]
@ -72,7 +73,9 @@ class ExtendedSpendingKey(DerivedAkNk, DerivedIvk, ExtendedBase):
@classmethod
def master(cls, S):
I = blake2b(person=b'ZcashIP32Sapling', data=S).digest()
digest = blake2b(person=b'ZcashIP32Sapling')
digest.update(S)
I = digest.digest()
I_L = I[:32]
I_R = I[32:]
sk_m = I_L
@ -122,8 +125,9 @@ class ExtendedSpendingKey(DerivedAkNk, DerivedIvk, ExtendedBase):
return self.__class__(ask_i, nsk_i, ovk_i, dk_i, c_i, self.depth()+1, self.tag(), i)
def internal(self):
FVK = encode_xfvk_parts(self.ak(), self.nk(), self.ovk(), self.dk())
I = blake2b(person=b'Zcash_SaplingInt', digest_size=32, data=FVK).digest()
digest = blake2b(person=b'Zcash_SaplingInt', digest_size=32)
digest.update(encode_xfvk_parts(self.ak(), self.nk(), self.ovk(), self.dk()))
I = digest.digest()
I_nsk = to_scalar(prf_expand(I, b'\x17'))
R = prf_expand(I, b'\x18')
nsk_internal = I_nsk + self.nsk()
@ -204,8 +208,9 @@ class ExtendedFullViewingKey(DerivedIvk, ExtendedBase):
return self.__class__(ak_i, nk_i, ovk_i, dk_i, c_i, self.depth()+1, self.tag(), i)
def internal(self):
FVK = encode_xfvk_parts(self.ak(), self.nk(), self.ovk(), self.dk())
I = blake2b(person=b'Zcash_SaplingInt', digest_size=32, data=FVK).digest()
digest = blake2b(person=b'Zcash_SaplingInt', digest_size=32)
digest.update(encode_xfvk_parts(self.ak(), self.nk(), self.ovk(), self.dk()))
I = digest.digest()
I_nsk = to_scalar(prf_expand(I, b'\x17'))
R = prf_expand(I, b'\x18')
nk_internal = PROVING_KEY_BASE * I_nsk + self.nk()

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2b
from hashlib import blake2b
import struct
from .transaction import (

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2b
from hashlib import blake2b
import struct
from .transaction import (

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
from pyblake2 import blake2b
from hashlib import blake2b
import struct
from .transaction import (