Scalar¶
- class blsct.Scalar(value: Any = None)¶
Represents an element of the finite field \(\mathbb{F}_r\), where \(r\) is the order of the generator point of the BLS12-381 G1 group.
A wrapper of MclScalar in navio-core.
Instantiating a Scalar without a parameter is equivalent to calling Scalar.random().
>>> from blsct import Scalar >>> Scalar() Scalar(5131bedc360ef599553bc6f020c251183ae8504b7b4fe0991e1e5864cc4e422) >>> Scalar(123) Scalar(7b) >>> Scalar.zero() Scalar(0) >>> Scalar.random() Scalar(693a3c156e22d2305c30e4297e3f974201a081e0910f7303ebc5f36f00161c43) >>> a = Scalar() >>> b = Scalar() >>> a == a True >>> a == b False >>> a.to_int() 5339113002865401837 >>> ser = a.serialize() >>> deser = Scalar.deserialize(ser) >>> ser == deser.serialize() True
- classmethod deserialize(hex: str) Self¶
Deserialize the scalar from a hexadecimal string
- pretty_print() str¶
Convert the scalar to a string representation
- classmethod random() Self¶
Generate a random scalar
- serialize() str¶
Serialize the scalar to a hexadecimal string
- to_int() int¶
Convert the scalar to an integer
- classmethod zero() Self¶
Return a zero scalar