mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-11 10:56:14 +03:00
Changes for bls 0.2.3 (#354)
* Start of changes for bls 0.2.3 * Make remaining changes for new blspy * Add migration for 1.0b9 Co-authored-by: Gene Hoffman <hoffmang@hoffmang.com>
This commit is contained in:
parent
2c2dbbc4e1
commit
774307dce1
3935
electron-react/package-lock.json
generated
3935
electron-react/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@
|
||||
"react-redux": "^7.2.0",
|
||||
"react-router": "^5.1.2",
|
||||
"react-router-dom": "^5.1.2",
|
||||
"react-scripts": "^3.4.1",
|
||||
"react-scripts": "^3.4.2",
|
||||
"redux": "^4.0.5",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"stringify": "^5.2.0",
|
||||
|
4
setup.py
4
setup.py
@ -1,5 +1,9 @@
|
||||
from setuptools import setup
|
||||
|
||||
"""
|
||||
This is a temporary comment
|
||||
to bust the pip cache on GH Actions
|
||||
"""
|
||||
|
||||
dependencies = [
|
||||
"aiter==0.13.20191203", # Used for async generator tools
|
||||
|
@ -208,7 +208,8 @@ def chia_init(root_path: Path):
|
||||
]
|
||||
|
||||
PATH_MANIFEST_LIST: List[Tuple[Path, List[str]]] = [
|
||||
(Path(os.path.expanduser("~/.chia/beta-%s" % _)), MANIFEST) for _ in ["1.0b8"]
|
||||
(Path(os.path.expanduser("~/.chia/beta-%s" % _)), MANIFEST)
|
||||
for _ in ["1.0b9", "1.0b8"]
|
||||
]
|
||||
|
||||
for old_path, manifest in PATH_MANIFEST_LIST:
|
||||
|
@ -222,7 +222,7 @@ def sign(args):
|
||||
for sk, _ in private_keys:
|
||||
if sk.get_g1().get_fingerprint() == fingerprint:
|
||||
for c in path:
|
||||
sk = sk.derive_child(c)
|
||||
sk = AugSchemeMPL.derive_child_sk(sk, c)
|
||||
print("Public key:", sk.get_g1())
|
||||
print("Signature:", AugSchemeMPL.sign(sk, bytes(message, "utf-8")))
|
||||
return
|
||||
|
@ -857,7 +857,7 @@ class Blockchain:
|
||||
if not block.header.data.aggregated_signature:
|
||||
return Err.BAD_AGGREGATE_SIGNATURE
|
||||
|
||||
validates = AugSchemeMPL.agg_verify(
|
||||
validates = AugSchemeMPL.aggregate_verify(
|
||||
pairs_pks, pairs_msgs, block.header.data.aggregated_signature
|
||||
)
|
||||
if not validates:
|
||||
|
@ -316,7 +316,7 @@ class MempoolManager:
|
||||
continue
|
||||
|
||||
# Verify aggregated signature
|
||||
validates = AugSchemeMPL.agg_verify(
|
||||
validates = AugSchemeMPL.aggregate_verify(
|
||||
pks, msgs, new_spend.aggregated_signature
|
||||
)
|
||||
if not validates:
|
||||
|
@ -2,7 +2,7 @@ from pathlib import Path
|
||||
from secrets import token_bytes
|
||||
from typing import Optional, List
|
||||
import logging
|
||||
from blspy import PrivateKey, G1Element
|
||||
from blspy import AugSchemeMPL, G1Element, PrivateKey
|
||||
from chiapos import DiskPlotter
|
||||
from datetime import datetime
|
||||
from src.types.proof_of_space import ProofOfSpace
|
||||
@ -94,7 +94,7 @@ def create_plots(
|
||||
assert len(test_private_keys) == num
|
||||
sk: PrivateKey = test_private_keys[i]
|
||||
else:
|
||||
sk = PrivateKey.from_seed(token_bytes(32))
|
||||
sk = AugSchemeMPL.key_gen(token_bytes(32))
|
||||
|
||||
# The plot public key is the combination of the harvester and farmer keys
|
||||
plot_public_key = ProofOfSpace.generate_plot_public_key(
|
||||
|
@ -9,7 +9,7 @@ from pathlib import Path
|
||||
from typing import Dict, List, Tuple, Optional
|
||||
from argparse import Namespace
|
||||
|
||||
from blspy import G1Element, G2Element, AugSchemeMPL, PrivateKey
|
||||
from blspy import G1Element, G2Element, AugSchemeMPL
|
||||
|
||||
from chiavdf import prove
|
||||
from chiabip158 import PyBIP158
|
||||
@ -105,7 +105,7 @@ class BlockTools:
|
||||
args.tmp2_dir = plot_dir
|
||||
args.final_dir = plot_dir
|
||||
test_private_keys = [
|
||||
PrivateKey.from_seed(std_hash(bytes([i]))) for i in range(args.num)
|
||||
AugSchemeMPL.key_gen(std_hash(bytes([i]))) for i in range(args.num)
|
||||
]
|
||||
try:
|
||||
# No datetime in the filename, to get deterministic filenames and not replot
|
||||
|
@ -9,7 +9,7 @@ import keyring as keyring_main
|
||||
import pkg_resources
|
||||
|
||||
from bitstring import BitArray
|
||||
from blspy import PrivateKey, G1Element
|
||||
from blspy import AugSchemeMPL, G1Element, PrivateKey
|
||||
from keyrings.cryptfile.cryptfile import CryptFileKeyring
|
||||
from src.util.hash import std_hash
|
||||
|
||||
@ -180,7 +180,7 @@ class Keychain:
|
||||
seed = mnemonic_to_seed(mnemonic, passphrase)
|
||||
entropy = bytes_from_mnemonic(mnemonic)
|
||||
index = self._get_free_private_key_index()
|
||||
key = PrivateKey.from_seed(seed)
|
||||
key = AugSchemeMPL.key_gen(seed)
|
||||
fingerprint = key.get_g1().get_fingerprint()
|
||||
|
||||
if fingerprint in [pk.get_fingerprint() for pk in self.get_all_public_keys()]:
|
||||
@ -208,7 +208,7 @@ class Keychain:
|
||||
for pp in passphrases:
|
||||
mnemonic = bytes_to_mnemonic(ent)
|
||||
seed = mnemonic_to_seed(mnemonic, pp)
|
||||
key = PrivateKey.from_seed(seed)
|
||||
key = AugSchemeMPL.key_gen(seed)
|
||||
if key.get_g1() == pk:
|
||||
return (key, ent)
|
||||
index += 1
|
||||
@ -232,7 +232,7 @@ class Keychain:
|
||||
for pp in passphrases:
|
||||
mnemonic = bytes_to_mnemonic(ent)
|
||||
seed = mnemonic_to_seed(mnemonic, pp)
|
||||
key = PrivateKey.from_seed(seed)
|
||||
key = AugSchemeMPL.key_gen(seed)
|
||||
if key.get_g1() == pk:
|
||||
all_keys.append((key, ent))
|
||||
index += 1
|
||||
|
@ -42,7 +42,7 @@ class WalletTool:
|
||||
if sk is not None:
|
||||
self.private_key = sk
|
||||
else:
|
||||
self.private_key = PrivateKey.from_seed(token_bytes(32))
|
||||
self.private_key = AugSchemeMPL.key_gen(token_bytes(32))
|
||||
self.generator_lookups: Dict = {}
|
||||
self.name = "MyChiaWallet"
|
||||
self.puzzle_pk_cache: Dict = {}
|
||||
|
@ -1,4 +1,6 @@
|
||||
from blspy import PrivateKey
|
||||
from typing import List
|
||||
from blspy import AugSchemeMPL, PrivateKey
|
||||
|
||||
from src.util.ints import uint32
|
||||
|
||||
# EIP 2334 bls key derivation
|
||||
@ -8,26 +10,27 @@ from src.util.ints import uint32
|
||||
# 0, 1, 2, 3, 4, farmer, pool, wallet, local, backup key numbers
|
||||
|
||||
|
||||
def _derive_path(sk: PrivateKey, path: List[int]) -> PrivateKey:
|
||||
for index in path:
|
||||
sk = AugSchemeMPL.derive_child_sk(sk, index)
|
||||
return sk
|
||||
|
||||
|
||||
def master_sk_to_farmer_sk(master: PrivateKey) -> PrivateKey:
|
||||
return master.derive_child(12381).derive_child(8444).derive_child(0).derive_child(0)
|
||||
return _derive_path(master, [12381, 8444, 0, 0])
|
||||
|
||||
|
||||
def master_sk_to_pool_sk(master: PrivateKey) -> PrivateKey:
|
||||
return master.derive_child(12381).derive_child(8444).derive_child(1).derive_child(0)
|
||||
return _derive_path(master, [12381, 8444, 1, 0])
|
||||
|
||||
|
||||
def master_sk_to_wallet_sk(master: PrivateKey, index: uint32) -> PrivateKey:
|
||||
return (
|
||||
master.derive_child(12381)
|
||||
.derive_child(8444)
|
||||
.derive_child(2)
|
||||
.derive_child(index)
|
||||
)
|
||||
return _derive_path(master, [12381, 8444, 2, index])
|
||||
|
||||
|
||||
def master_sk_to_local_sk(master: PrivateKey) -> PrivateKey:
|
||||
return master.derive_child(12381).derive_child(8444).derive_child(3).derive_child(0)
|
||||
return _derive_path(master, [12381, 8444, 3, 0])
|
||||
|
||||
|
||||
def master_sk_to_backup_sk(master: PrivateKey) -> PrivateKey:
|
||||
return master.derive_child(12381).derive_child(8444).derive_child(4).derive_child(0)
|
||||
return _derive_path(master, [12381, 8444, 4, 0])
|
||||
|
@ -281,7 +281,9 @@ class WalletStateManager:
|
||||
break
|
||||
type = target_wallet.rl_info.type
|
||||
if type == "user":
|
||||
rl_pubkey = G1Element.from_bytes(target_wallet.rl_info.user_pubkey)
|
||||
rl_pubkey = G1Element.from_bytes(
|
||||
target_wallet.rl_info.user_pubkey
|
||||
)
|
||||
else:
|
||||
rl_pubkey = G1Element.from_bytes(
|
||||
target_wallet.rl_info.admin_pubkey
|
||||
|
@ -5,7 +5,7 @@ from secrets import token_bytes
|
||||
|
||||
import aiosqlite
|
||||
import pytest
|
||||
from blspy import PrivateKey, AugSchemeMPL
|
||||
from blspy import AugSchemeMPL
|
||||
|
||||
from src.full_node.blockchain import Blockchain, ReceiveBlockResult
|
||||
from src.types.full_block import FullBlock
|
||||
@ -246,7 +246,7 @@ class TestBlockValidation:
|
||||
Header(
|
||||
blocks[9].header.data,
|
||||
AugSchemeMPL.sign(
|
||||
PrivateKey.from_seed(bytes([5] * 32)), token_bytes(32)
|
||||
AugSchemeMPL.key_gen(bytes([5] * 32)), token_bytes(32)
|
||||
),
|
||||
),
|
||||
blocks[9].transactions_generator,
|
||||
|
@ -1,4 +1,4 @@
|
||||
from blspy import PrivateKey
|
||||
from blspy import AugSchemeMPL
|
||||
|
||||
from src.types.coin_solution import CoinSolution
|
||||
from src.types.spend_bundle import SpendBundle
|
||||
@ -9,7 +9,7 @@ from tests.util.key_tool import KeyTool
|
||||
from src.util.ints import uint32
|
||||
from src.wallet.derive_keys import master_sk_to_wallet_sk
|
||||
|
||||
MASTER_KEY = PrivateKey.from_seed(bytes([1] * 32))
|
||||
MASTER_KEY = AugSchemeMPL.key_gen(bytes([1] * 32))
|
||||
|
||||
|
||||
def puzzle_program_for_index(index: uint32):
|
||||
|
@ -3,7 +3,7 @@ import asyncio
|
||||
import pytest
|
||||
|
||||
from secrets import token_bytes
|
||||
from blspy import PrivateKey
|
||||
from blspy import AugSchemeMPL
|
||||
from chiapos import DiskPlotter
|
||||
from src.rpc.farmer_rpc_client import FarmerRpcClient
|
||||
from src.rpc.harvester_rpc_client import HarvesterRpcClient
|
||||
@ -102,7 +102,7 @@ class TestRpc:
|
||||
filename,
|
||||
18,
|
||||
stream_plot_info(
|
||||
bt.pool_pk, bt.farmer_pk, PrivateKey.from_seed(bytes([4] * 32))
|
||||
bt.pool_pk, bt.farmer_pk, AugSchemeMPL.key_gen(bytes([4] * 32))
|
||||
),
|
||||
token_bytes(32),
|
||||
128,
|
||||
|
@ -128,7 +128,7 @@ if __name__ == "__main__":
|
||||
"""
|
||||
wallet_tool = WalletTool()
|
||||
benchmark_all_operators()
|
||||
secret_key: PrivateKey = PrivateKey.from_seed(bytes([2] * 32))
|
||||
secret_key: PrivateKey = AugSchemeMPL.key_gen(bytes([2] * 32))
|
||||
puzzles = []
|
||||
solutions = []
|
||||
private_keys = []
|
||||
|
@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
import json
|
||||
from secrets import token_bytes
|
||||
from blspy import PrivateKey
|
||||
from blspy import PrivateKey, AugSchemeMPL
|
||||
from src.util.keychain import (
|
||||
Keychain,
|
||||
generate_mnemonic,
|
||||
@ -44,7 +44,7 @@ class TesKeychain(unittest.TestCase):
|
||||
assert len(kc.get_all_private_keys()) == 2
|
||||
|
||||
seed_2 = mnemonic_to_seed(mnemonic, "")
|
||||
seed_key_2 = PrivateKey.from_seed(seed_2)
|
||||
seed_key_2 = AugSchemeMPL.key_gen(seed_2)
|
||||
kc.delete_key_by_fingerprint(seed_key_2.get_g1().get_fingerprint())
|
||||
assert kc._get_free_private_key_index() == 0
|
||||
assert len(kc.get_all_private_keys()) == 1
|
||||
@ -91,7 +91,7 @@ class TesKeychain(unittest.TestCase):
|
||||
)
|
||||
tv_child_int = 11812940737387919040225825939013910852517748782307378293770044673328955938106
|
||||
assert master_sk == PrivateKey.from_bytes(tv_master_int.to_bytes(32, "big"))
|
||||
child_sk = master_sk.derive_child(0)
|
||||
child_sk = AugSchemeMPL.derive_child_sk(master_sk, 0)
|
||||
assert child_sk == PrivateKey.from_bytes(tv_child_int.to_bytes(32, "big"))
|
||||
|
||||
def test_bip39_test_vectors_trezor(self):
|
||||
|
@ -3,7 +3,7 @@ from secrets import token_bytes
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
import aiosqlite
|
||||
from blspy import PrivateKey
|
||||
from blspy import AugSchemeMPL
|
||||
from src.util.ints import uint32
|
||||
from src.wallet.wallet_puzzle_store import WalletPuzzleStore
|
||||
from src.wallet.derivation_record import DerivationRecord
|
||||
@ -36,7 +36,7 @@ class TestPuzzleStore:
|
||||
DerivationRecord(
|
||||
uint32(i),
|
||||
token_bytes(32),
|
||||
PrivateKey.from_seed(token_bytes(32)).get_g1(),
|
||||
AugSchemeMPL.key_gen(token_bytes(32)).get_g1(),
|
||||
WalletType.STANDARD_WALLET,
|
||||
uint32(1),
|
||||
)
|
||||
@ -45,7 +45,7 @@ class TestPuzzleStore:
|
||||
DerivationRecord(
|
||||
uint32(i),
|
||||
token_bytes(32),
|
||||
PrivateKey.from_seed(token_bytes(32)).get_g1(),
|
||||
AugSchemeMPL.key_gen(token_bytes(32)).get_g1(),
|
||||
WalletType.RATE_LIMITED,
|
||||
uint32(2),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user