Sha256: 85fd771db816304d362bb72c38c57ba65b82cf92b076181b84153139cb9bd438
Contents?: true
Size: 630 Bytes
Versions: 1
Compression:
Stored size: 630 Bytes
Contents
require 'forwardable' require 'openssl' module Sperm::Groups # Provides isomorphism from (Z/(p-1)Z, +) to (Z/pZ \ {0}, *). # class Isomorphism extend Forwardable attr_reader :add_group, :mul_group def_delegator :add_group, :order def initialize(add_group, mul_group) fail ArgumentError, 'unequal orders' unless add_group.order == mul_group.order @add_group = add_group @mul_group = mul_group end def map(number) fail ArgumentError, 'not an element' unless add_group.include?(number) mul_group.generator.to_bn.mod_exp(number, mul_group.modulo).to_i end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sperm-0.1.1 | lib/sperm/groups/isomorphism.rb |