Skip to content

Commit ac03c25

Browse files
committed
Merge branch 'master' of github.com:DavidEGrayson/ruby_ecdsa
2 parents 9338c34 + 8e203f6 commit ac03c25

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/ecdsa/point.rb

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ def add_to_point(other)
8383
raise "Failed to add #{inspect} to #{other.inspect}: No addition rules matched."
8484
end
8585

86+
# (see #add_to_point)
87+
alias_method :+, :add_to_point
88+
8689
# Returns the additive inverse of the point.
8790
#
8891
# @return (Point)
@@ -123,6 +126,9 @@ def multiply_by_scalar(i)
123126
result
124127
end
125128

129+
# (see #multiply_by_scalar)
130+
alias_method :*, :multiply_by_scalar
131+
126132
# Compares this point to another.
127133
#
128134
# @return (true or false) true if the points are equal

spec/point_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
it 'complains if the argument is negative' do
2222
expect { group.generator.multiply_by_scalar(-3) }.to raise_error ArgumentError, 'Scalar is negative.'
2323
end
24+
25+
it 'is aliased to :*' do
26+
expect(group.generator.method(:*)).to eq group.generator.method(:multiply_by_scalar)
27+
end
2428
end
2529

2630
describe '#coords' do
@@ -63,6 +67,10 @@
6367
expect(group.generator.add_to_point(group.generator)).to eq group.generator.double
6468
end
6569
end
70+
71+
it 'is aliased to :+' do
72+
expect(group.generator.method(:+)).to eq group.generator.method(:add_to_point)
73+
end
6674
end
6775

6876
describe '#negate' do

0 commit comments

Comments
 (0)