【新月実装】需【Clojure・ClojureScript】

3b326be9 :Anonymous 2016-01-15 18:03
@markdown
署名の検証も試してみました。公開鍵とシグニチャから本文のmd5ダイジェスト
(44419214286006158861137771899985306382062246609227984941284330775348791043381N)が
再構築できたのでこれで問題ないはずです。

```
(let [record-body "body:test"
target (digest/md5 record-body)
md5-to-bigint (fn [s]
(apply +
(map
(fn [c n] (* (bigint (int c)) (clojure.math.numeric-tower/expt 256 n)))
s
(range (count s)))))
expt-mod (fn [b e n] (bigint (.modPow (biginteger b) (biginteger e) (biginteger n))))
public-key 1122806372610712283641764701710834148204234645585040684037170652091590554067499953763526724213941221496764286040865822589763248156452468642704658988427843N
secret-key 861280222834211635003719961005341323199464182108597666477205899292436716184420718855991902898025496028982723694319590089136399532658790932223389304471553N
test-signature 485929915806472765213575522933223159394941576528520956259553264248457078912341366480238285348741046848091733570511927351801272738791576365987870892767619N]
[(md5-to-bigint target)
(expt-mod test-signature 65537 public-key)])
```
Powered by shinGETsu.