228件ヒット
[1-100件を表示]
(0.076秒)
別のキーワード
クラス
- Integer (12)
-
OpenSSL
:: BN (216)
キーワード
- << (12)
- <=> (12)
- >> (12)
-
clear
_ bit! (12) - cmp (12)
- coerce (12)
-
mod
_ add (12) -
mod
_ exp (12) -
mod
_ inverse (12) -
mod
_ mul (12) -
mod
_ sub (12) -
num
_ bits (12) -
num
_ bytes (12) -
pretty
_ print (12) -
prime
_ fasttest? (12) - rshift! (12)
-
to
_ bn (12) -
to
_ s (12) - ucmp (12)
検索結果
先頭5件
-
OpenSSL
:: BN # prime _ fasttest?(checks=nil , vtrivdiv=true) -> bool (6209.0) -
自身が素数であるなら true を返します。
...自身が素数であるなら true を返します。
vtrivdiv が真である場合には、 Miller-Rabin 法での
判定の前に小さな素数で割ることで素数か否かを
調べます。自身が小さな素数である場合にはこの手順
により素数ではないと誤った......Miller-Rabin 法により確率的に判定します。
checksで指定した回数だけ繰り返します。
checksがnilである場合は OpenSSL が適切な
回数を判断します。
//emlist[][ruby]{
require 'openssl'
# 181 は 「小さな素数」である
OpenSSL::BN.new("181").prime_f......true) # => false
OpenSSL::BN.new("181").prime_fasttest?(nil, false) # => true
//}
@param checks Miller-Robin法の繰り返しの回数
@param vtrivdiv 真なら小さな素数で割ることでの素数判定を試みます
@raise OpenSSL::BNError 判定時にエラーが発生
@see OpenSSL::BN#pr... -
OpenSSL
:: BN # mod _ inverse(m) -> OpenSSL :: BN (6121.0) -
自身の mod m における逆元を返します。
...す。
(self * r) % m == 1 となる r を返します。
存在しない場合は例外 OpenSSL::BNError が発生します。
//emlist[][ruby]{
require 'openssl'
p 3.to_bn.mod_inverse(5) # => 2
p (3 * 2) % 5 # => 1
//}
@param m mod を取る数
@raise OpenSSL::BNError 計算時エ... -
OpenSSL
:: BN # clear _ bit!(n) -> self (6109.0) -
自身の n ビット目を0にします。
...自身の n ビット目を0にします。
//emlist[][ruby]{
require 'openssl'
a = OpenSSL::BN.new("129")
a.clear_bit!(0)
a # => 128
//}
@param n 0にするビットの位置
@raise OpenSSL::BNError 計算時エラー
@see OpenSSL::set_bit!... -
OpenSSL
:: BN # coerce(other) -> Array (6109.0) -
自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。
...自身と other が同じクラスになるよう、自身か other を変換し
[other, self] という配列にして返します。
基本的に other が整数のときに、自身を Integer のオブジェクトに
変換して [other, 変換後オブジェクト] にして返します。
そ......外 TypeError を発生させます。
//emlist[][ruby]{
require 'openssl'
p 1.to_bn.coerce(2) # => [2, 1]
//}
@param other 変換の基準となるオブジェクト
@raise TypeError 変換に失敗した場合に発生します
coerce メソッドの詳細な説明は、Numeric#coerce にあ......ります。
@see Numeric#coerce... -
OpenSSL
:: BN # pretty _ print(pp) (6109.0) -
Kernel.#pp でオブジェクトの内容を出力するときに、内部で呼ばれるメソッドです。
...Kernel.#pp でオブジェクトの内容を出力するときに、内部で呼ばれるメソッドです。
//emlist[][ruby]{
require 'pp'
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
@param pp PP クラスのインスタンスオブジェク......Kernel.#pp でオブジェクトの内容を出力するときに、内部で呼ばれるメソッドです。
//emlist[][ruby]{
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
@param pp PP クラスのインスタンスオブジェクト... -
OpenSSL
:: BN # rshift!(n) -> self (6109.0) -
自身を n ビット右シフトします。 [[m:OpenSSL::BN#>>]と異なり、破壊的メソッドです。
...[[m:OpenSSL::BN#>>]と異なり、破壊的メソッドです。
//emlist[][ruby]{
require 'openssl'
bn = 8.to_bn
bn.rshift!(1) # => #<OpenSSL::BN 4>
bn # => #<OpenSSL::BN 4>
//}
@param n シフトするビット数
@raise OpenSSL::BNError 計算時エラー
@see OpenSSL::BN#>>... -
Integer
# to _ bn -> OpenSSL :: BN (3015.0) -
Integer を同じ数を表す OpenSSL::BN のオブジェクトに 変換します。
...Integer を同じ数を表す OpenSSL::BN のオブジェクトに
変換します。
//emlist[][ruby]{
require 'pp'
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
なお、実装は、以下のようになっています。
//emlist[][ruby]{
clas......s Integer
def to_bn
OpenSSL::BN::new(self)
end
end
//}
@see OpenSSL::BN.new, OpenSSL::BN#to_i......Integer を同じ数を表す OpenSSL::BN のオブジェクトに
変換します。
//emlist[][ruby]{
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
なお、実装は、以下のようになっています。
//emlist[][ruby]{
class Integer
de......f to_bn
OpenSSL::BN::new(self)
end
end
//}
@see OpenSSL::BN.new, OpenSSL::BN#to_i... -
OpenSSL
:: BN # <<(other) -> OpenSSL :: BN (109.0) -
自身を other ビット左シフトした値を返します。
...自身を other ビット左シフトした値を返します。
//emlist[][ruby]{
bn = 1.to_bn
pp bn << 1 # => #<OpenSSL::BN 2>
pp bn # => #<OpenSSL::BN 1>
//}
@param other シフトするビット数
@raise OpenSSL::BNError 計算時エラー
@see OpenSSL::BN#lshift!... -
OpenSSL
:: BN # <=>(other) -> -1 | 0 | 1 (109.0) -
自身と other を比較し、自身が小さいときには -1、 等しいときには 0、大きいときには 1 を返します。
...身と other を比較し、自身が小さいときには -1、
等しいときには 0、大きいときには 1 を返します。
//emlist[][ruby]{
require 'openssl'
OpenSSL::BN.new(5) <=> 5 # => 0
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(9) # => -1
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(5)......# => 0
OpenSSL::BN.new(5) <=> OpenSSL::BN.new(-5) # => 1
//}
@param other 比較する整数
@raise TypeError 比較できないときに発生します。
@see OpenSSL::BN#ucmp...