PublicKey¶
- class blsct.PublicKey(obj: Any = None)¶
Represents an element in the BLS12-381 G1 curve group that is used as a public key.
>>> from blsct import Point, PublicKey, Scalar >>> s = Scalar.random() >>> PublicKey.from_scalar(s) PublicKey(a4a04797481bd531f9cb56...) >>> p = Point.random() >>> PublicKey.from_point(p) PublicKey(b09a14601bee3102a6db45...) >>> pk = PublicKey.random() >>> pk.pretty_print() '1 70896870760eba69c20a1f0d740855a91560a...' >>> vk = Scalar() >>> pk.generate_nonce(vk) PublicKey(91458dc61b63095b1d5f13...) >>> pk.get_point() Point(a70896870760eba69c20a1f0d7...) f9420ac559ebc) >>> pk2 = PublicKey.random() >>> pk == pk2 False >>> pk == pk True >>> ser = pk.serialize() >>> deser = PublicKey.deserialize(ser) >>> ser == deser.serialize() True
- classmethod deserialize(hex: str) Self¶
Deserialize the PublicKey from a hexadecimal string
- generate_nonce(view_key: Scalar) Self¶
Generate a nonce PublicKey from blinding public key and view key
- pretty_print() str¶
Convert the PublicKey to a human-readable string representation
- classmethod random() Self¶
Get a random public key
- serialize() str¶
Serialize the PublicKey to a hexadecimal string