Class: BLS::Fp
Overview
Finite field over q.
Constant Summary collapse
- ORDER =
BLS::Curve::P
- MAX_BITS =
Curve::P.bit_length
- BYTES_LEN =
(MAX_BITS / 8.0).ceil
- ZERO =
Fp.new(0)
- ONE =
Fp.new(1)
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value) ⇒ Fp
constructor
A new instance of Fp.
- #to_bytes ⇒ Object
- #to_hex ⇒ Object
Methods included from Field
#==, #add, #div, #invert, #multiply, #negate, #pow, #square, #subtract, #to_s, #zero?
Constructor Details
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
81 82 83 |
# File 'lib/bls/field.rb', line 81 def value @value end |
Instance Method Details
#to_bytes ⇒ Object
92 93 94 |
# File 'lib/bls/field.rb', line 92 def to_bytes [to_hex].pack('H*') end |
#to_hex ⇒ Object
96 97 98 |
# File 'lib/bls/field.rb', line 96 def to_hex value.to_s(16).rjust(2 * BYTES_LEN, '0') end |