@bsv/sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -3
- package/package.json +9 -5
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
- package/.github/ISSUE_TEMPLATE/discussion.md +0 -24
- package/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +0 -23
- package/CHANGELOG.md +0 -72
- package/CONTRIBUTING.md +0 -85
- package/ROADMAP.md +0 -3
- package/docs/getting-started/COMMONJS.md +0 -94
- package/docs/getting-started/REACT-TS.md +0 -131
- package/docs/getting-started/TS-NODE.md +0 -106
- package/docs/getting-started/VUE.md +0 -103
- package/jest.config.js +0 -6
- package/mod.ts +0 -8
- package/src/compat/BSM.ts +0 -51
- package/src/compat/ECIES.ts +0 -557
- package/src/compat/HD.ts +0 -348
- package/src/compat/Mnemonic.ts +0 -295
- package/src/compat/__tests/BSM.test.ts +0 -38
- package/src/compat/__tests/ECIES.test.ts +0 -90
- package/src/compat/__tests/HD.test.ts +0 -405
- package/src/compat/__tests/Mnemonic.test.ts +0 -177
- package/src/compat/__tests/Mnemonic.vectors.ts +0 -172
- package/src/compat/bip-39-wordlist-en.ts +0 -2053
- package/src/compat/index.ts +0 -4
- package/src/messages/EncryptedMessage.ts +0 -70
- package/src/messages/SignedMessage.ts +0 -87
- package/src/messages/__tests/EncryptedMessage.test.ts +0 -36
- package/src/messages/__tests/SignedMessage.test.ts +0 -53
- package/src/messages/index.ts +0 -2
- package/src/primitives/AESGCM.ts +0 -479
- package/src/primitives/BasePoint.ts +0 -21
- package/src/primitives/BigNumber.ts +0 -4619
- package/src/primitives/Curve.ts +0 -1163
- package/src/primitives/DRBG.ts +0 -102
- package/src/primitives/ECDSA.ts +0 -164
- package/src/primitives/Hash.ts +0 -1420
- package/src/primitives/JacobianPoint.ts +0 -410
- package/src/primitives/K256.ts +0 -116
- package/src/primitives/Mersenne.ts +0 -123
- package/src/primitives/MontgomoryMethod.ts +0 -160
- package/src/primitives/Point.ts +0 -852
- package/src/primitives/PrivateKey.ts +0 -195
- package/src/primitives/PublicKey.ts +0 -154
- package/src/primitives/Random.ts +0 -55
- package/src/primitives/ReductionContext.ts +0 -528
- package/src/primitives/Signature.ts +0 -235
- package/src/primitives/SymmetricKey.ts +0 -75
- package/src/primitives/TransactionSignature.ts +0 -189
- package/src/primitives/__tests/AESGCM.test.ts +0 -338
- package/src/primitives/__tests/BRC42.private.vectors.ts +0 -33
- package/src/primitives/__tests/BRC42.public.vectors.ts +0 -33
- package/src/primitives/__tests/BigNumber.arithmatic.test.ts +0 -572
- package/src/primitives/__tests/BigNumber.binary.test.ts +0 -203
- package/src/primitives/__tests/BigNumber.constructor.test.ts +0 -176
- package/src/primitives/__tests/BigNumber.dhGroup.test.ts +0 -18
- package/src/primitives/__tests/BigNumber.fixtures.ts +0 -264
- package/src/primitives/__tests/BigNumber.serializers.test.ts +0 -157
- package/src/primitives/__tests/BigNumber.utils.test.ts +0 -347
- package/src/primitives/__tests/Curve.unit.test.ts +0 -192
- package/src/primitives/__tests/DRBG.test.ts +0 -18
- package/src/primitives/__tests/DRBG.vectors.ts +0 -167
- package/src/primitives/__tests/ECDH.test.ts +0 -31
- package/src/primitives/__tests/ECDSA.test.ts +0 -58
- package/src/primitives/__tests/HMAC.test.ts +0 -59
- package/src/primitives/__tests/Hash.test.ts +0 -121
- package/src/primitives/__tests/PBKDF2.vectors.ts +0 -119
- package/src/primitives/__tests/PrivateKey.test.ts +0 -17
- package/src/primitives/__tests/PublicKey.test.ts +0 -66
- package/src/primitives/__tests/Random.test.ts +0 -14
- package/src/primitives/__tests/Reader.test.ts +0 -296
- package/src/primitives/__tests/ReductionContext.test.ts +0 -279
- package/src/primitives/__tests/SymmetricKey.test.ts +0 -58
- package/src/primitives/__tests/SymmetricKey.vectors.ts +0 -40
- package/src/primitives/__tests/Writer.test.ts +0 -198
- package/src/primitives/__tests/sighash.vectors.ts +0 -3503
- package/src/primitives/__tests/utils.test.ts +0 -108
- package/src/primitives/index.ts +0 -8
- package/src/primitives/utils.ts +0 -665
- package/src/script/LockingScript.ts +0 -30
- package/src/script/OP.ts +0 -219
- package/src/script/Script.ts +0 -426
- package/src/script/ScriptChunk.ts +0 -7
- package/src/script/ScriptTemplate.ts +0 -36
- package/src/script/Spend.ts +0 -1379
- package/src/script/UnlockingScript.ts +0 -30
- package/src/script/__tests/Script.test.ts +0 -369
- package/src/script/__tests/Spend.test.ts +0 -248
- package/src/script/__tests/script.invalid.vectors.ts +0 -925
- package/src/script/__tests/script.valid.vectors.ts +0 -1120
- package/src/script/__tests/scriptFromVector.ts +0 -42
- package/src/script/__tests/spend.valid.vectors.ts +0 -2288
- package/src/script/index.ts +0 -7
- package/src/script/templates/P2PKH.ts +0 -109
- package/src/script/templates/RPuzzle.ts +0 -140
- package/src/script/templates/index.ts +0 -2
- package/src/transaction/Broadcaster.ts +0 -42
- package/src/transaction/ChainTracker.ts +0 -22
- package/src/transaction/FeeModel.ts +0 -13
- package/src/transaction/MerklePath.ts +0 -259
- package/src/transaction/Transaction.ts +0 -602
- package/src/transaction/TransactionInput.ts +0 -63
- package/src/transaction/TransactionOutput.ts +0 -37
- package/src/transaction/__tests/MerklePath.test.ts +0 -181
- package/src/transaction/__tests/Transaction.test.ts +0 -413
- package/src/transaction/__tests/bigtx.vectors.ts +0 -4
- package/src/transaction/__tests/bump.invalid.vectors.ts +0 -8
- package/src/transaction/__tests/bump.valid.vectors.ts +0 -4
- package/src/transaction/__tests/tx.invalid.vectors.ts +0 -281
- package/src/transaction/__tests/tx.valid.vectors.ts +0 -364
- package/src/transaction/broadcasters/ARC.ts +0 -106
- package/src/transaction/broadcasters/__tests/ARC.test.ts +0 -115
- package/src/transaction/broadcasters/index.ts +0 -1
- package/src/transaction/fee-models/SatoshisPerKilobyte.ts +0 -71
- package/src/transaction/fee-models/index.ts +0 -1
- package/src/transaction/index.ts +0 -6
- package/ts2md.json +0 -5
- package/tsconfig.base.json +0 -26
- package/tsconfig.cjs.json +0 -11
- package/tsconfig.eslint.json +0 -12
- package/tsconfig.esm.json +0 -9
- package/tsconfig.json +0 -17
- package/tsconfig.types.json +0 -11
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
/* eslint-env jest */
|
|
2
|
-
import { AES, AESGCM, ghash, rightShift, multiply, incrementLeastSignificantThirtyTwoBits, checkBit, getBytes, exclusiveOR } from '../../../dist/cjs/src/primitives/AESGCM'
|
|
3
|
-
import { toArray } from '../../../dist/cjs/src/primitives/utils'
|
|
4
|
-
|
|
5
|
-
describe('AES', () => {
|
|
6
|
-
it('should encrypt: AES-128', () => {
|
|
7
|
-
expect(toArray('69c4e0d86a7b0430d8cdb78070b4c55a', 'hex'))
|
|
8
|
-
.toEqual(AES(
|
|
9
|
-
toArray('00112233445566778899aabbccddeeff', 'hex'),
|
|
10
|
-
toArray('000102030405060708090a0b0c0d0e0f', 'hex')
|
|
11
|
-
))
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('should encrypt: AES-192', () => {
|
|
15
|
-
expect(toArray('dda97ca4864cdfe06eaf70a0ec0d7191', 'hex')).toEqual(
|
|
16
|
-
AES(toArray('00112233445566778899aabbccddeeff', 'hex'),
|
|
17
|
-
toArray('000102030405060708090a0b0c0d0e0f1011121314151617', 'hex')))
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('should encrypt: AES-256', () => {
|
|
21
|
-
expect(toArray('8ea2b7ca516745bfeafc49904b496089', 'hex')).toEqual(
|
|
22
|
-
AES(toArray('00112233445566778899aabbccddeeff', 'hex'),
|
|
23
|
-
toArray('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f', 'hex')))
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('should encrypt', () => {
|
|
27
|
-
expect(toArray('66e94bd4ef8a2c3b884cfa59ca342b2e', 'hex')).toEqual(
|
|
28
|
-
AES(toArray('00000000000000000000000000000000', 'hex'), toArray('00000000000000000000000000000000', 'hex')))
|
|
29
|
-
expect(toArray('c6a13b37878f5b826f4f8162a1c8d879', 'hex')).toEqual(
|
|
30
|
-
AES(toArray('00000000000000000000000000000000', 'hex'), toArray('000102030405060708090a0b0c0d0e0f', 'hex')))
|
|
31
|
-
expect(toArray('73a23d80121de2d5a850253fcf43120e', 'hex')).toEqual(
|
|
32
|
-
AES(toArray('00000000000000000000000000000000', 'hex'), toArray('ad7a2bd03eac835a6f620fdcb506b345', 'hex')))
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
describe('ghash', () => {
|
|
37
|
-
it('should ghash', () => {
|
|
38
|
-
expect(toArray('f38cbb1ad69223dcc3457ae5b6b0f885', 'hex')).toEqual(
|
|
39
|
-
ghash(toArray('000000000000000000000000000000000388dace60b6a392f328c2b971b2fe780000000000000000000000' +
|
|
40
|
-
'0000000080', 'hex'), toArray('66e94bd4ef8a2c3b884cfa59ca342b2e', 'hex')))
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
describe('AESGCM', () => {
|
|
45
|
-
it('should encrypt: Test Case 1', () => {
|
|
46
|
-
const output = AESGCM([], [], toArray('000000000000000000000000', 'hex'),
|
|
47
|
-
toArray('00000000000000000000000000000000', 'hex'))
|
|
48
|
-
|
|
49
|
-
expect([]).toEqual(output.result)
|
|
50
|
-
expect(toArray('58e2fccefa7e3061367f1d57a4e7455a', 'hex')).toEqual(output.authenticationTag)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('should encrypt: Test Case 2', () => {
|
|
54
|
-
const output = AESGCM(toArray('00000000000000000000000000000000', 'hex'), [],
|
|
55
|
-
toArray('000000000000000000000000', 'hex'), toArray('00000000000000000000000000000000', 'hex'))
|
|
56
|
-
|
|
57
|
-
expect(toArray('0388dace60b6a392f328c2b971b2fe78', 'hex')).toEqual(output.result)
|
|
58
|
-
expect(toArray('ab6e47d42cec13bdf53a67b21257bddf', 'hex')).toEqual(output.authenticationTag)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it('should encrypt: Test Case 3', () => {
|
|
62
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
63
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', 'hex'), [], toArray('cafebabefacedbaddecaf888', 'hex'),
|
|
64
|
-
toArray('feffe9928665731c6d6a8f9467308308', 'hex'))
|
|
65
|
-
|
|
66
|
-
expect(toArray('42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8' +
|
|
67
|
-
'f6a5aac84aa051ba30b396a0aac973d58e091473f5985', 'hex')).toEqual(output.result)
|
|
68
|
-
expect(toArray('4d5c2af327cd64a62cf35abd2ba6fab4', 'hex')).toEqual(output.authenticationTag)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('should encrypt: Test Case 4', () => {
|
|
72
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
73
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'), toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
74
|
-
toArray('cafebabefacedbaddecaf888', 'hex'), toArray('feffe9928665731c6d6a8f9467308308', 'hex'))
|
|
75
|
-
expect(toArray('42831ec2217774244b7221b784d0d49ce3aa212f2c02a4e035c17e2329aca12e21d514b25466931c7d8' +
|
|
76
|
-
'f6a5aac84aa051ba30b396a0aac973d58e091', 'hex')).toEqual(output.result)
|
|
77
|
-
expect(toArray('5bc94fbc3221a5db94fae95ae7121a47', 'hex')).toEqual(output.authenticationTag)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it('should encrypt: Test Case 5', () => {
|
|
81
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
82
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'), toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
83
|
-
toArray('cafebabefacedbad', 'hex'), toArray('feffe9928665731c6d6a8f9467308308', 'hex'))
|
|
84
|
-
|
|
85
|
-
expect(toArray('61353b4c2806934a777ff51fa22a4755699b2a714fcdc6f83766e5f97b6c742373806900e49f24b22b0' +
|
|
86
|
-
'97544d4896b424989b5e1ebac0f07c23f4598', 'hex')).toEqual(output.result)
|
|
87
|
-
expect(toArray('3612d2e79e3b0785561be14aaca2fccb', 'hex')).toEqual(output.authenticationTag)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
it('should encrypt: Test Case 6', () => {
|
|
91
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
92
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'), toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
93
|
-
toArray('9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416' +
|
|
94
|
-
'aedbf5a0de6a57a637b39b', 'hex'), toArray('feffe9928665731c6d6a8f9467308308', 'hex'))
|
|
95
|
-
|
|
96
|
-
expect(toArray('8ce24998625615b603a033aca13fb894be9112a5c3a211a8ba262a3cca7e2ca701e4a9a4fba43c90ccd' +
|
|
97
|
-
'cb281d48c7c6fd62875d2aca417034c34aee5', 'hex')).toEqual(output.result)
|
|
98
|
-
expect(toArray('619cc5aefffe0bfa462af43c1699d050', 'hex')).toEqual(output.authenticationTag)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
it('should encrypt: Test Case 7', () => {
|
|
102
|
-
const output = AESGCM([], [], toArray('000000000000000000000000', 'hex'),
|
|
103
|
-
toArray('000000000000000000000000000000000000000000000000', 'hex'))
|
|
104
|
-
|
|
105
|
-
expect([]).toEqual(output.result)
|
|
106
|
-
expect(toArray('cd33b28ac773f74ba00ed1f312572435', 'hex')).toEqual(output.authenticationTag)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
it('should encrypt: Test Case 8', () => {
|
|
110
|
-
const output = AESGCM(toArray('00000000000000000000000000000000', 'hex'), [],
|
|
111
|
-
toArray('000000000000000000000000', 'hex'), toArray('000000000000000000000000000000000000000000000000', 'hex'))
|
|
112
|
-
|
|
113
|
-
expect(toArray('98e7247c07f0fe411c267e4384b0f600', 'hex')).toEqual(output.result)
|
|
114
|
-
expect(toArray('2ff58d80033927ab8ef4d4587514f0fb', 'hex')).toEqual(output.authenticationTag)
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
it('should encrypt: Test Case 9', () => {
|
|
118
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
119
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', 'hex'), [], toArray('cafebabefacedbaddecaf888', 'hex'),
|
|
120
|
-
toArray('feffe9928665731c6d6a8f9467308308feffe9928665731c', 'hex'))
|
|
121
|
-
|
|
122
|
-
expect(toArray('3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac6' +
|
|
123
|
-
'19d18c84a3f4718e2448b2fe324d9ccda2710acade256', 'hex')).toEqual(output.result)
|
|
124
|
-
expect(toArray('9924a7c8587336bfb118024db8674a14', 'hex')).toEqual(output.authenticationTag)
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
it('should encrypt: Test Case 10', () => {
|
|
128
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
129
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'), toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
130
|
-
toArray('cafebabefacedbaddecaf888', 'hex'), toArray('feffe9928665731c6d6a8f9467308308feffe9928665731c', 'hex'))
|
|
131
|
-
|
|
132
|
-
expect(toArray('3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac6' +
|
|
133
|
-
'19d18c84a3f4718e2448b2fe324d9ccda2710', 'hex')).toEqual(output.result)
|
|
134
|
-
expect(toArray('2519498e80f1478f37ba55bd6d27618c', 'hex')).toEqual(output.authenticationTag)
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it('should encrypt: Test Case 11', () => {
|
|
138
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
139
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'), toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
140
|
-
toArray('cafebabefacedbad', 'hex'), toArray('feffe9928665731c6d6a8f9467308308feffe9928665731c', 'hex'))
|
|
141
|
-
|
|
142
|
-
expect(toArray('0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057fddc29df9a471f75c66' +
|
|
143
|
-
'541d4d4dad1c9e93a19a58e8b473fa0f062f7', 'hex')).toEqual(output.result)
|
|
144
|
-
expect(toArray('65dcc57fcf623a24094fcca40d3533f8', 'hex')).toEqual(output.authenticationTag)
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
it('should encrypt: Test Case 12', () => {
|
|
148
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
149
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'), toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
150
|
-
toArray('9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b5254' +
|
|
151
|
-
'16aedbf5a0de6a57a637b39b', 'hex'), toArray('feffe9928665731c6d6a8f9467308308feffe9928665731c', 'hex'))
|
|
152
|
-
|
|
153
|
-
expect(toArray('d27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e4581e79012af34ddd9e2f' +
|
|
154
|
-
'037589b292db3e67c036745fa22e7e9b7373b', 'hex')).toEqual(output.result)
|
|
155
|
-
expect(toArray('dcf566ff291c25bbb8568fc3d376a6d9', 'hex')).toEqual(output.authenticationTag)
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
it('should encrypt: Test Case 13', () => {
|
|
159
|
-
const output = AESGCM([], [], toArray('000000000000000000000000', 'hex'),
|
|
160
|
-
toArray('0000000000000000000000000000000000000000000000000000000000000000', 'hex'))
|
|
161
|
-
|
|
162
|
-
expect([]).toEqual(output.result)
|
|
163
|
-
expect(toArray('530f8afbc74536b9a963b4f1c4cb738b', 'hex')).toEqual(output.authenticationTag)
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
it('should encrypt: Test Case 14', () => {
|
|
167
|
-
const output = AESGCM(toArray('00000000000000000000000000000000', 'hex'), [],
|
|
168
|
-
toArray('000000000000000000000000', 'hex'),
|
|
169
|
-
toArray('0000000000000000000000000000000000000000000000000000000000000000', 'hex'))
|
|
170
|
-
|
|
171
|
-
expect(toArray('cea7403d4d606b6e074ec5d3baf39d18', 'hex')).toEqual(output.result)
|
|
172
|
-
expect(toArray('d0d1c8a799996bf0265b98b5d48ab919', 'hex')).toEqual(output.authenticationTag)
|
|
173
|
-
})
|
|
174
|
-
|
|
175
|
-
it('should encrypt: Test Case 15', () => {
|
|
176
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
177
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255', 'hex'), [],
|
|
178
|
-
toArray('cafebabefacedbaddecaf888', 'hex'),
|
|
179
|
-
toArray('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', 'hex'))
|
|
180
|
-
|
|
181
|
-
expect(toArray('522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b' +
|
|
182
|
-
'08b1056828838c5f61e6393ba7a0abcc9f662898015ad', 'hex')).toEqual(output.result)
|
|
183
|
-
expect(toArray('b094dac5d93471bdec1a502270e3cc6c', 'hex')).toEqual(output.authenticationTag)
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
it('should encrypt: Test Case 16', () => {
|
|
187
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
188
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'), toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
189
|
-
toArray('cafebabefacedbaddecaf888', 'hex'),
|
|
190
|
-
toArray('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', 'hex'))
|
|
191
|
-
|
|
192
|
-
expect(toArray('522dc1f099567d07f47f37a32a84427d643a8cdcbfe5c0c97598a2bd2555d1aa8cb08e48590dbb3da7b' +
|
|
193
|
-
'08b1056828838c5f61e6393ba7a0abcc9f662', 'hex')).toEqual(output.result)
|
|
194
|
-
expect(toArray('76fc6ece0f4e1768cddf8853bb2d551b', 'hex')).toEqual(output.authenticationTag)
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
it('should encrypt: Test Case 17', () => {
|
|
198
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
199
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'),
|
|
200
|
-
toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
201
|
-
toArray('cafebabefacedbad', 'hex'),
|
|
202
|
-
toArray('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', 'hex'))
|
|
203
|
-
|
|
204
|
-
expect(toArray('c3762df1ca787d32ae47c13bf19844cbaf1ae14d0b976afac52ff7d79bba9de0feb582d33934a4f0954' +
|
|
205
|
-
'cc2363bc73f7862ac430e64abe499f47c9b1f', 'hex')).toEqual(output.result)
|
|
206
|
-
expect(toArray('3a337dbf46a792c45e454913fe2ea8f2', 'hex')).toEqual(output.authenticationTag)
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
it('should encrypt: Test Case 18', () => {
|
|
210
|
-
const output = AESGCM(toArray('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956' +
|
|
211
|
-
'809532fcf0e2449a6b525b16aedf5aa0de657ba637b39', 'hex'),
|
|
212
|
-
toArray('feedfacedeadbeeffeedfacedeadbeefabaddad2', 'hex'),
|
|
213
|
-
toArray('9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416' +
|
|
214
|
-
'aedbf5a0de6a57a637b39b', 'hex'),
|
|
215
|
-
toArray('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308', 'hex'))
|
|
216
|
-
|
|
217
|
-
expect(toArray('5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da' +
|
|
218
|
-
'3ebf1c5d82cdea2418997200ef82e44ae7e3f', 'hex')).toEqual(output.result)
|
|
219
|
-
expect(toArray('a44a8266ee1c8eb0c8b5d4cf5ae9f19a', 'hex')).toEqual(output.authenticationTag)
|
|
220
|
-
})
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
describe('exclusiveOR', () => {
|
|
224
|
-
it('should exclusiveOR', () => {
|
|
225
|
-
expect([0xFF, 0xF7, 0x7F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]).toEqual(
|
|
226
|
-
exclusiveOR([0xF0, 0xF8, 0x7F, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
227
|
-
0x00], [0x0F, 0x0F, 0x00, 0xF0]))
|
|
228
|
-
|
|
229
|
-
expect([0xFF, 0xF7, 0x7F, 0x0F]).toEqual(
|
|
230
|
-
exclusiveOR([0xF0, 0xF8, 0x7F, 0xFF], [0x0F, 0x0F, 0x00, 0xF0]))
|
|
231
|
-
})
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
describe('rightShift', () => {
|
|
235
|
-
it('should rightShift', () => {
|
|
236
|
-
expect(toArray('3dadaa32b9ba2b32b1ba37b92ea9a3ae', 'hex')).toEqual(
|
|
237
|
-
rightShift(toArray('7b5b54657374566563746f725d53475d', 'hex')))
|
|
238
|
-
})
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
describe('multiply', () => {
|
|
242
|
-
it('should multiply', () => {
|
|
243
|
-
expect(toArray('da53eb0ad2c55bb64fc4802cc3feda60', 'hex')).toEqual(
|
|
244
|
-
multiply(toArray('952b2a56a5604ac0b32b6656a05b40b6', 'hex'),
|
|
245
|
-
toArray('dfa6bf4ded81db03ffcaff95f830f061', 'hex')))
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
it('should commutatively multiply', () => {
|
|
249
|
-
expect(multiply(toArray('48692853686179295b477565726f6e5d', 'hex'),
|
|
250
|
-
toArray('7b5b54657374566563746f725d53475d', 'hex'))).toEqual(
|
|
251
|
-
multiply(toArray('7b5b54657374566563746f725d53475d', 'hex'),
|
|
252
|
-
toArray('48692853686179295b477565726f6e5d', 'hex')))
|
|
253
|
-
})
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
describe('incrementLeastSignificantThirtyTwoBits', () => {
|
|
257
|
-
it('should incrementLeastSignificantThirtyTwoBits', () => {
|
|
258
|
-
expect(toArray('00000000000000000000000000000001', 'hex')).toEqual(
|
|
259
|
-
incrementLeastSignificantThirtyTwoBits(toArray('00000000000000000000000000000000', 'hex')))
|
|
260
|
-
expect(toArray('00000000000000000000000000000100', 'hex')).toEqual(
|
|
261
|
-
incrementLeastSignificantThirtyTwoBits(toArray('000000000000000000000000000000ff', 'hex')))
|
|
262
|
-
expect(toArray('00000000000000000000000001000000', 'hex')).toEqual(
|
|
263
|
-
incrementLeastSignificantThirtyTwoBits(toArray('00000000000000000000000000ffffff', 'hex')))
|
|
264
|
-
expect(toArray('00000000000000000000000000000000', 'hex')).toEqual(
|
|
265
|
-
incrementLeastSignificantThirtyTwoBits(toArray('000000000000000000000000ffffffff', 'hex')))
|
|
266
|
-
})
|
|
267
|
-
})
|
|
268
|
-
|
|
269
|
-
describe('checkBit', () => {
|
|
270
|
-
it('should checkBit', () => {
|
|
271
|
-
let i
|
|
272
|
-
let j
|
|
273
|
-
let k = 0
|
|
274
|
-
let block = toArray('7b5b54657374566563746f725d53475d', 'hex')
|
|
275
|
-
const expected = [0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0,
|
|
276
|
-
1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0,
|
|
277
|
-
1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0,
|
|
278
|
-
1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1]
|
|
279
|
-
const expectedLSB = expected.slice().reverse()
|
|
280
|
-
|
|
281
|
-
for (i = 0; i < 16; i++) {
|
|
282
|
-
for (j = 7; j !== -1; j--) {
|
|
283
|
-
expect(expected[k++]).toEqual(checkBit(block, i, j))
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
for (i = 0; i < 128; i++) {
|
|
288
|
-
expect(expectedLSB[i]).toEqual(checkBit(block, 15, 0))
|
|
289
|
-
block = rightShift(block)
|
|
290
|
-
}
|
|
291
|
-
})
|
|
292
|
-
it('should get bit', () => {
|
|
293
|
-
expect(0).toEqual(checkBit([0], 0, 7))
|
|
294
|
-
expect(0).toEqual(checkBit([0], 0, 6))
|
|
295
|
-
expect(0).toEqual(checkBit([0], 0, 5))
|
|
296
|
-
expect(0).toEqual(checkBit([0], 0, 4))
|
|
297
|
-
expect(0).toEqual(checkBit([0], 0, 3))
|
|
298
|
-
expect(0).toEqual(checkBit([0], 0, 2))
|
|
299
|
-
expect(0).toEqual(checkBit([0], 0, 1))
|
|
300
|
-
expect(0).toEqual(checkBit([0], 0, 0))
|
|
301
|
-
|
|
302
|
-
expect(0).toEqual(checkBit([85], 0, 7))
|
|
303
|
-
expect(1).toEqual(checkBit([85], 0, 6))
|
|
304
|
-
expect(0).toEqual(checkBit([85], 0, 5))
|
|
305
|
-
expect(1).toEqual(checkBit([85], 0, 4))
|
|
306
|
-
expect(0).toEqual(checkBit([85], 0, 3))
|
|
307
|
-
expect(1).toEqual(checkBit([85], 0, 2))
|
|
308
|
-
expect(0).toEqual(checkBit([85], 0, 1))
|
|
309
|
-
expect(1).toEqual(checkBit([85], 0, 0))
|
|
310
|
-
|
|
311
|
-
expect(1).toEqual(checkBit([170], 0, 7))
|
|
312
|
-
expect(0).toEqual(checkBit([170], 0, 6))
|
|
313
|
-
expect(1).toEqual(checkBit([170], 0, 5))
|
|
314
|
-
expect(0).toEqual(checkBit([170], 0, 4))
|
|
315
|
-
expect(1).toEqual(checkBit([170], 0, 3))
|
|
316
|
-
expect(0).toEqual(checkBit([170], 0, 2))
|
|
317
|
-
expect(1).toEqual(checkBit([170], 0, 1))
|
|
318
|
-
expect(0).toEqual(checkBit([170], 0, 0))
|
|
319
|
-
|
|
320
|
-
expect(1).toEqual(checkBit([255], 0, 7))
|
|
321
|
-
expect(1).toEqual(checkBit([255], 0, 6))
|
|
322
|
-
expect(1).toEqual(checkBit([255], 0, 5))
|
|
323
|
-
expect(1).toEqual(checkBit([255], 0, 4))
|
|
324
|
-
expect(1).toEqual(checkBit([255], 0, 3))
|
|
325
|
-
expect(1).toEqual(checkBit([255], 0, 2))
|
|
326
|
-
expect(1).toEqual(checkBit([255], 0, 1))
|
|
327
|
-
expect(1).toEqual(checkBit([255], 0, 0))
|
|
328
|
-
})
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
describe('getBytes', () => {
|
|
332
|
-
it('should getBytes', () => {
|
|
333
|
-
expect([0x00, 0x00, 0x00, 0x00]).toEqual(getBytes(0x00))
|
|
334
|
-
expect([0x00, 0x00, 0x02, 0x01]).toEqual(getBytes(0x0201))
|
|
335
|
-
expect([0x04, 0x03, 0x02, 0x01]).toEqual(getBytes(0x04030201))
|
|
336
|
-
expect([0x04, 0x03, 0x02, 0x01]).toEqual(getBytes(0x0504030201))
|
|
337
|
-
})
|
|
338
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Source: https://github.com/p2ppsr/sendover/blob/master/test/getPaymentPrivateKey.vectors.js
|
|
2
|
-
export default [
|
|
3
|
-
{
|
|
4
|
-
senderPublicKey: '033f9160df035156f1c48e75eae99914fa1a1546bec19781e8eddb900200bff9d1',
|
|
5
|
-
recipientPrivateKey: '6a1751169c111b4667a6539ee1be6b7cd9f6e9c8fe011a5f2fe31e03a15e0ede',
|
|
6
|
-
invoiceNumber: 'f3WCaUmnN9U=',
|
|
7
|
-
privateKey: '761656715bbfa172f8f9f58f5af95d9d0dfd69014cfdcacc9a245a10ff8893ef'
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
senderPublicKey: '027775fa43959548497eb510541ac34b01d5ee9ea768de74244a4a25f7b60fae8d',
|
|
11
|
-
recipientPrivateKey: 'cab2500e206f31bc18a8af9d6f44f0b9a208c32d5cca2b22acfe9d1a213b2f36',
|
|
12
|
-
invoiceNumber: '2Ska++APzEc=',
|
|
13
|
-
privateKey: '09f2b48bd75f4da6429ac70b5dce863d5ed2b350b6f2119af5626914bdb7c276'
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
senderPublicKey: '0338d2e0d12ba645578b0955026ee7554889ae4c530bd7a3b6f688233d763e169f',
|
|
17
|
-
recipientPrivateKey: '7a66d0896f2c4c2c9ac55670c71a9bc1bdbdfb4e8786ee5137cea1d0a05b6f20',
|
|
18
|
-
invoiceNumber: 'cN/yQ7+k7pg=',
|
|
19
|
-
privateKey: '7114cd9afd1eade02f76703cc976c241246a2f26f5c4b7a3a0150ecc745da9f0'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
senderPublicKey: '02830212a32a47e68b98d477000bde08cb916f4d44ef49d47ccd4918d9aaabe9c8',
|
|
23
|
-
recipientPrivateKey: '6e8c3da5f2fb0306a88d6bcd427cbfba0b9c7f4c930c43122a973d620ffa3036',
|
|
24
|
-
invoiceNumber: 'm2/QAsmwaA4=',
|
|
25
|
-
privateKey: 'f1d6fb05da1225feeddd1cf4100128afe09c3c1aadbffbd5c8bd10d329ef8f40'
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
senderPublicKey: '03f20a7e71c4b276753969e8b7e8b67e2dbafc3958d66ecba98dedc60a6615336d',
|
|
29
|
-
recipientPrivateKey: 'e9d174eff5708a0a41b32624f9b9cc97ef08f8931ed188ee58d5390cad2bf68e',
|
|
30
|
-
invoiceNumber: 'jgpUIjWFlVQ=',
|
|
31
|
-
privateKey: 'c5677c533f17c30f79a40744b18085632b262c0c13d87f3848c385f1389f79a6'
|
|
32
|
-
}
|
|
33
|
-
]
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Source: https://github.com/p2ppsr/sendover/blob/master/test/getPaymentpublicKey.vectors.js
|
|
2
|
-
export default [
|
|
3
|
-
{
|
|
4
|
-
senderPrivateKey: '583755110a8c059de5cd81b8a04e1be884c46083ade3f779c1e022f6f89da94c',
|
|
5
|
-
recipientPublicKey: '02c0c1e1a1f7d247827d1bcf399f0ef2deef7695c322fd91a01a91378f101b6ffc',
|
|
6
|
-
invoiceNumber: 'IBioA4D/OaE=',
|
|
7
|
-
publicKey: '03c1bf5baadee39721ae8c9882b3cf324f0bf3b9eb3fc1b8af8089ca7a7c2e669f'
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
senderPrivateKey: '2c378b43d887d72200639890c11d79e8f22728d032a5733ba3d7be623d1bb118',
|
|
11
|
-
recipientPublicKey: '039a9da906ecb8ced5c87971e9c2e7c921e66ad450fd4fc0a7d569fdb5bede8e0f',
|
|
12
|
-
invoiceNumber: 'PWYuo9PDKvI=',
|
|
13
|
-
publicKey: '0398cdf4b56a3b2e106224ff3be5253afd5b72de735d647831be51c713c9077848'
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
senderPrivateKey: 'd5a5f70b373ce164998dff7ecd93260d7e80356d3d10abf928fb267f0a6c7be6',
|
|
17
|
-
recipientPublicKey: '02745623f4e5de046b6ab59ce837efa1a959a8f28286ce9154a4781ec033b85029',
|
|
18
|
-
invoiceNumber: 'X9pnS+bByrM=',
|
|
19
|
-
publicKey: '0273eec9380c1a11c5a905e86c2d036e70cbefd8991d9a0cfca671f5e0bbea4a3c'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
senderPrivateKey: '46cd68165fd5d12d2d6519b02feb3f4d9c083109de1bfaa2b5c4836ba717523c',
|
|
23
|
-
recipientPublicKey: '031e18bb0bbd3162b886007c55214c3c952bb2ae6c33dd06f57d891a60976003b1',
|
|
24
|
-
invoiceNumber: '+ktmYRHv3uQ=',
|
|
25
|
-
publicKey: '034c5c6bf2e52e8de8b2eb75883090ed7d1db234270907f1b0d1c2de1ddee5005d'
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
senderPrivateKey: '7c98b8abd7967485cfb7437f9c56dd1e48ceb21a4085b8cdeb2a647f62012db4',
|
|
29
|
-
recipientPublicKey: '03c8885f1e1ab4facd0f3272bb7a48b003d2e608e1619fb38b8be69336ab828f37',
|
|
30
|
-
invoiceNumber: 'PPfDTTcl1ao=',
|
|
31
|
-
publicKey: '03304b41cfa726096ffd9d8907fe0835f888869eda9653bca34eb7bcab870d3779'
|
|
32
|
-
}
|
|
33
|
-
]
|