mirror of
https://github.com/aljazceru/python-nostr.git
synced 2025-12-19 07:14:23 +01:00
refactor: PrivateKey class signs events
This commit is contained in:
@@ -47,11 +47,6 @@ class Event():
|
||||
def compute_id(public_key: str, created_at: int, kind: int, tags: "list[list[str]]", content: str) -> str:
|
||||
return sha256(Event.serialize(public_key, created_at, kind, tags, content)).hexdigest()
|
||||
|
||||
def sign(self, private_key_hex: str) -> None:
|
||||
sk = PrivateKey(bytes.fromhex(private_key_hex))
|
||||
sig = sk.schnorr_sign(bytes.fromhex(self.id), None, raw=True)
|
||||
self.signature = sig.hex()
|
||||
|
||||
def verify(self) -> bool:
|
||||
pub_key = PublicKey(bytes.fromhex("02" + self.public_key), True) # add 02 for schnorr (bip340)
|
||||
event_id = Event.compute_id(self.public_key, self.created_at, self.kind, self.tags, self.content)
|
||||
|
||||
Reference in New Issue
Block a user