Skip to content

Commit 90322a6

Browse files
author
Weiwu Zhang
committed
coming up with better README
1 parent 6a11ca4 commit 90322a6

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

xmldsig/js/README.md

+36-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
1-
Demonstrating verifying XML Digital Signature (xmldsig)
2-
====
1+
# Demonstrating verifying XML Digital Signature (xmldsig) #
32

43
xmldsig is used to sign every TokenScript file. This directory contains a
5-
demonstration of how to verify xmldsig with JavaScript code.
4+
demonstration on how to verify xmldsig with JavaScript code.
5+
6+
## Prepare ##
7+
8+
First, make sure your nodejs is above version 15.0.0 where [WebCrypto was introduced](https://www.nearform.com/blog/implementing-the-web-cryptography-api-for-node-js-core/)
9+
10+
Then, install the dependencies
11+
12+
````
13+
$ npm install
14+
````
15+
16+
Finally, apply an xmldom patch for [a known bug](https://github.com/xmldom/xmldom/issues/203). Note that this patch is destructive, the resulting xmldom won't work properly on html files (which we don't use in our case). Such a patch will not be needed (hence will be deleted from this repo) when xmldom release the next version after 0.5.0.
17+
18+
````
19+
$ patch -p0 < xmldom.patch
20+
````
21+
22+
## Test ##
23+
24+
Let's say you have a bunch of signed TokenScripts residing in `../../../TokenScript-Repo/aw.app/2020/06/` (which you can get by checking out [TokenScript-Repo](https://github.com/AlphaWallet/TokenScript-Repo)). Run the files through the `xmldsigverifier.js` script:
25+
26+
````
27+
$ node xmldsigverifier.js ../../../TokenScript-Repo/aw.app/2020/06/*
28+
[ OK ] ../../../TokenScript-Repo/aw.app/2020/06/aDAI.tsml
29+
[ OK ] ../../../TokenScript-Repo/aw.app/2020/06/cBAT.tsml
30+
31+
[ OK ] ../../../TokenScript-Repo/aw.app/2020/06/WETH.tsml
32+
````
33+
34+
## Work in progress ##
35+
36+
- Because this signature verifier doesn't check the certificates, the result is not an indication whether or not the TokenScript is signed with the correct key. More work needs to be done to use it in production environment.
37+
38+
- A version that can run in the web browser is needed.

0 commit comments

Comments
 (0)