Skip to content

Performance improvement in xmr_utils namespace #36

@kno3comma14

Description

@kno3comma14

If the team still using the function ->public-key from the namespace bips.xmr-utils then I purpose to change the following code:

(defn exp-mod
  "Calculates the result of a modular exponentiation of a given base `b`, exponent `e`, and modulus `m`."
  [b e m]
  (if (= e 0)
    (biginteger 1)
    (let [t (atom (.mod  (.pow (exp-mod (biginteger b) (.divide (biginteger e) (biginteger 2)) m) 2) m))]
      (when (not= (.and (biginteger e) (biginteger 1)) 0)
        (reset! t (.mod (.multiply @t (biginteger b)) m)))
      @t)))

with

(defn exp-mod
  [b e m]
  (.modPow b e m))

The internal implementation from BigInteger reduces the time by 3 seconds approximately. You can check the change here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions