-
Notifications
You must be signed in to change notification settings - Fork 2
/
crypto_js.cljs
84 lines (70 loc) · 2.8 KB
/
crypto_js.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(ns fluree.crypto-js
(:require [fluree.crypto :as fc]
[fluree.crypto.jws :as jws]))
(defn ^:export sha2-256
[& args] ; TS types don't work well with multi-arity fns
(apply fc/sha2-256 args))
(defn ^:export sha2-256-normalize
[& args] ; TS types don't work well with multi-arity fns
(apply fc/sha2-256-normalize args))
(defn ^:export sha2-512
[& args] ; TS types don't work well with multi-arity fns
(apply fc/sha2-512 args))
(defn ^:export sha2-512-normalize
[& args] ; TS types don't work well with multi-arity fns
(apply fc/sha2-512-normalize args))
(defn ^:export sha3-256
[& args] ; TS types don't work well with multi-arity fns
(apply fc/sha3-256 args))
(defn ^:export sha3-256-normalize
[& args] ; TS types don't work well with multi-arity fns
(apply fc/sha3-256-normalize args))
(defn ^:export sha3-512
[& args] ; TS types don't work well with multi-arity fns
(apply fc/sha3-512 args))
(defn ^:export sha3-512-normalize
[& args] ; TS types don't work well with multi-arity fns
(apply fc/sha3-512-normalize args))
(defn ^:export ripemd-160
[& args] ; TS types don't work well with multi-arity fns
(apply fc/ripemd-160 args))
(defn ^:export aes-encrypt
[& args]
(apply fc/aes-encrypt args))
(defn ^:export aes-decrypt
[& args] ; TS types don't work well with multi-arity fns
(apply fc/aes-decrypt args))
(defn ^:export generate-key-pair
[& args] ; multi-arity fns don't play well with TS types
(clj->js (apply fc/generate-key-pair args)))
(defn ^:export verify-jws
[jws]
(-> jws fc/verify-jws clj->js))
(def ^:export exports
#js {:normalizeString fc/normalize-string
:stringToByteArray fc/string->byte-array
:byteArrayToString fc/byte-array->string
:sha2_256 sha2-256
:sha2_256_normalize sha2-256-normalize
:sha2_512 sha2-512
:sha2_512_normalize sha2-512-normalize
:sha3_256 sha3-256
:sha3_256_normalize sha3-256-normalize
:sha3_512 sha3-512
:sha3_512_normalize sha3-512-normalize
:ripemd_160 ripemd-160
:aesEncrypt aes-encrypt
:aesDecrypt aes-decrypt
:generateKeyPair generate-key-pair
:pubKeyFromPrivate fc/pub-key-from-private
:accountIdFromPublic fc/account-id-from-public
:accountIdFromPrivate fc/account-id-from-private
:signMessage fc/sign-message
:verifySignature fc/verify-signature
:pubKeyFromMessage fc/pub-key-from-message
:accountIdFromMessage fc/account-id-from-message
:scryptEncrypt fc/scrypt-encrypt
:scryptCheck fc/scrypt-check
:randomBytes fc/random-bytes
:createJWS fc/create-jws
:verifyJWS verify-jws})