Skip to content

Commit

Permalink
rename ClassgroupElement.from_bytes() to not clash with the Streamabl…
Browse files Browse the repository at this point in the history
…e class
  • Loading branch information
arvidn committed Oct 18, 2023
1 parent e15b9a0 commit 23cb848
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion chia/full_node/weight_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ def _validate_vdf_batch(
) -> bool:
for vdf_proof_bytes, class_group_bytes, info in vdf_list:
vdf = VDFProof.from_bytes(vdf_proof_bytes)
class_group = ClassgroupElement.from_bytes(class_group_bytes)
class_group = ClassgroupElement.create(class_group_bytes)
vdf_info = VDFInfo.from_bytes(info)
if not vdf.is_valid(constants, class_group, vdf_info):
return False
Expand Down
5 changes: 3 additions & 2 deletions chia/timelord/timelord.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,9 @@ async def _do_process_communication(
proof_bytes: bytes = stdout_bytes_io.read()

# Verifies our own proof just in case

form_size = ClassgroupElement.get_size()
output = ClassgroupElement.from_bytes(y_bytes[:form_size])
output = ClassgroupElement.create(y_bytes[:form_size])
# default value so that it's always set for state_changed later
ips: float = 0
if not self.bluebox_mode:
Expand Down Expand Up @@ -1180,7 +1181,7 @@ async def _manage_discriminant_queue_sanitizer_slow(self, pool: ProcessPoolExecu
log.info(f"Finished compact proof: {picked_info.height}. Time: {delta}s. IPS: {ips}.")
output = proof[:100]
proof_part = proof[100:200]
if ClassgroupElement.from_bytes(output) != picked_info.new_proof_of_time.output:
if ClassgroupElement.create(output) != picked_info.new_proof_of_time.output:
log.error("Expected vdf output different than produced one. Stopping.")
return
vdf_proof = VDFProof(uint8(0), proof_part, True)
Expand Down
4 changes: 2 additions & 2 deletions chia/types/blockchain_format/classgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ClassgroupElement(Streamable):
data: bytes100

@staticmethod
def from_bytes(data: bytes) -> ClassgroupElement:
def create(data: bytes) -> ClassgroupElement:
if len(data) < 100:
data += b"\x00" * (100 - len(data))
return ClassgroupElement(bytes100(data))
Expand All @@ -27,7 +27,7 @@ def from_bytes(data: bytes) -> ClassgroupElement:
def get_default_element() -> "ClassgroupElement":
# Bit 3 in the first byte of serialized compressed form indicates if
# it's the default generator element.
return ClassgroupElement.from_bytes(b"\x08")
return ClassgroupElement.create(b"\x08")

@staticmethod
def get_size() -> int:
Expand Down
2 changes: 1 addition & 1 deletion chia/util/vdf_prover.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def get_vdf_info_and_proof(
number_iters,
)

output = ClassgroupElement.from_bytes(result[:form_size])
output = ClassgroupElement.create(result[:form_size])
proof_bytes = result[form_size : 2 * form_size]
return VDFInfo(challenge_hash, number_iters, output), VDFProof(uint8(0), proof_bytes, normalized_to_identity)
2 changes: 1 addition & 1 deletion tests/blockchain/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from tests.util.blockchain import create_blockchain

log = logging.getLogger(__name__)
bad_element = ClassgroupElement.from_bytes(b"\x00")
bad_element = ClassgroupElement.create(b"\x00")


@asynccontextmanager
Expand Down

0 comments on commit 23cb848

Please sign in to comment.