Skip to content

Commit dd59f74

Browse files
committed
Add Point#mul
1 parent 9c100aa commit dd59f74

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/main/java/org/jruby/ext/openssl/PKeyEC.java

+26
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,32 @@ public IRubyObject inspect() {
10731073
return ObjectSupport.inspect(this, (List) Collections.singletonList(entry));
10741074
}
10751075

1076+
@JRubyMethod(name = "add")
1077+
public IRubyObject add(final ThreadContext context, final IRubyObject other) {
1078+
Ruby runtime = context.runtime;
1079+
1080+
org.bouncycastle.math.ec.ECPoint pointSelf, pointOther, pointResult;
1081+
1082+
Group groupV = this.group;
1083+
Point result;
1084+
1085+
ECCurve selfCurve = EC5Util.convertCurve(groupV.getCurve());
1086+
pointSelf = EC5Util.convertPoint(selfCurve, asECPoint());
1087+
1088+
Point otherPoint = (Point) other;
1089+
ECCurve otherCurve = EC5Util.convertCurve(otherPoint.group.getCurve());
1090+
pointOther = EC5Util.convertPoint(otherCurve, otherPoint.asECPoint());
1091+
1092+
pointResult = pointSelf.add(pointOther);
1093+
if (pointResult == null) {
1094+
newECError(runtime, "EC_POINT_add");
1095+
}
1096+
1097+
result = new Point(runtime, EC5Util.convertPoint(pointResult), group);
1098+
1099+
return result;
1100+
}
1101+
10761102
@JRubyMethod(name = "mul", required = 1, optional = 2)
10771103
public IRubyObject mul(final ThreadContext context, final IRubyObject[] args) {
10781104
Ruby runtime = context.runtime;

0 commit comments

Comments
 (0)