1 1
(ns caesium.crypto.scalarmult
2
  "**DANGER** This namespace consists of low-level details that you
3
  should not use unless you know what you are doing. You probably
4
  want [[caesium.crypto.box]] instead.
5

6
  Scalar multiplication."
7
  (:refer-clojure :exclude [bytes])
8
  (:require [caesium.binding :as b]
9
            [caesium.byte-bufs :as bb]))
10

11 1
(b/defconsts [bytes scalarbytes primitive])
12

13 1
(defn scalarmult-to-buf!
14
  "Computes the scalar multiplication of a point into the given output
15
  buffer. If no point is specified, the standard base point of the
16
  curve is used."
17
  ([q n]
18 1
   (b/call! scalarmult-base q n))
19
  ([q n p]
20 1
   (b/call! scalarmult q n p)))
21

22 1
(defn scalarmult
23
  "Computes the scalar multiplication of a point. If no point is
24
  specified, the standard base point of the curve is used."
25
  ([n]
26 1
   (let [q (bb/alloc bytes)]
27 1
     (scalarmult-to-buf! q (bb/->indirect-byte-buf n))
28 1
     (bb/->bytes q)))
29
  ([n p]
30 1
   (let [q (bb/alloc bytes)]
31 1
     (scalarmult-to-buf!
32 1
      q (bb/->indirect-byte-buf n) (bb/->indirect-byte-buf p))
33 1
     (bb/->bytes q))))

Read our documentation on viewing source code .

Loading