|
1 |
| -var assert = require("assert"); |
| 1 | +const assert = require("assert"); |
| 2 | +const BigInt = require("big-integer"); |
2 | 3 |
|
3 |
| -var Ecdsa = require("../ellipticcurve/ecdsa"); |
4 |
| -var PrivateKey = require("../ellipticcurve/privateKey").PrivateKey; |
5 |
| -var PublicKey = require("../ellipticcurve/publicKey").PublicKey; |
6 |
| -var Signature = require("../ellipticcurve/signature").Signature; |
7 |
| -var File = require("../ellipticcurve/utils/file"); |
| 4 | +const Ecdsa = require("../ellipticcurve/ecdsa"); |
| 5 | +const PrivateKey = require("../ellipticcurve/privateKey").PrivateKey; |
| 6 | +const PublicKey = require("../ellipticcurve/publicKey").PublicKey; |
| 7 | +const Signature = require("../ellipticcurve/signature").Signature; |
| 8 | +const File = require("../ellipticcurve/utils/file"); |
8 | 9 |
|
9 | 10 |
|
10 | 11 | describe("ECDSA test", function() {
|
@@ -152,4 +153,18 @@ describe("Signature test", function() {
|
152 | 153 | assert.equal(String(signature1.s), String(signature2.s));
|
153 | 154 | });
|
154 | 155 | });
|
| 156 | + describe("#testExternalRandNum()", function () { |
| 157 | + it("should confirm authenticity and same signature", function () { |
| 158 | + let privateKey = new PrivateKey(); |
| 159 | + let publicKey = privateKey.publicKey(); |
| 160 | + let message = "This is a message"; |
| 161 | + let signature_1 = Ecdsa.sign(message, privateKey, null, BigInt(123)); |
| 162 | + let signature_2 = Ecdsa.sign(message, privateKey, null, BigInt(123)); |
| 163 | + |
| 164 | + assert.equal(Ecdsa.verify(message, signature_1, publicKey), true); |
| 165 | + assert.equal(Ecdsa.verify(message, signature_2, publicKey), true); |
| 166 | + assert.equal(signature_1.r.value, signature_2.r.value); |
| 167 | + assert.equal(signature_1.s.value, signature_2.s.value); |
| 168 | + }); |
| 169 | + }); |
155 | 170 | });
|
0 commit comments