Skip to content

Commit

Permalink
Add Point#mul
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Jun 11, 2024
1 parent 9c100aa commit dd59f74
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/java/org/jruby/ext/openssl/PKeyEC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,32 @@ public IRubyObject inspect() {
return ObjectSupport.inspect(this, (List) Collections.singletonList(entry));
}

@JRubyMethod(name = "add")
public IRubyObject add(final ThreadContext context, final IRubyObject other) {
Ruby runtime = context.runtime;

org.bouncycastle.math.ec.ECPoint pointSelf, pointOther, pointResult;

Group groupV = this.group;
Point result;

ECCurve selfCurve = EC5Util.convertCurve(groupV.getCurve());
pointSelf = EC5Util.convertPoint(selfCurve, asECPoint());

Point otherPoint = (Point) other;
ECCurve otherCurve = EC5Util.convertCurve(otherPoint.group.getCurve());
pointOther = EC5Util.convertPoint(otherCurve, otherPoint.asECPoint());

pointResult = pointSelf.add(pointOther);
if (pointResult == null) {
newECError(runtime, "EC_POINT_add");
}

result = new Point(runtime, EC5Util.convertPoint(pointResult), group);

return result;
}

@JRubyMethod(name = "mul", required = 1, optional = 2)
public IRubyObject mul(final ThreadContext context, final IRubyObject[] args) {
Ruby runtime = context.runtime;
Expand Down

0 comments on commit dd59f74

Please sign in to comment.