@cheny56/node-client 1.0.12 → 1.0.14
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/package.json +1 -1
- package/src/transaction.js +43 -43
- package/src/utils/address.js +4 -4
- package/src/utils/rlp.js +4 -4
- package/src/wallet.js +7 -7
- package/src/zk-transaction.js +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheny56/node-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Client library for Quorum blockchain with Post-Quantum Cryptography (PQC) and Zero-Knowledge Proof (ZK) support",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
package/src/transaction.js
CHANGED
|
@@ -93,15 +93,15 @@ class PQCLegacyTransaction extends BaseTransaction {
|
|
|
93
93
|
getSigningHash() {
|
|
94
94
|
const nonceBytes = this.nonce === 0n || this.nonce === 0
|
|
95
95
|
? new Uint8Array(0)
|
|
96
|
-
: ethers.
|
|
96
|
+
: ethers.utils.arrayify(ethers.utils.hexlify(this.nonce));
|
|
97
97
|
const gasLimitBytes = this.gasLimit === 0n || this.gasLimit === 0
|
|
98
98
|
? new Uint8Array(0)
|
|
99
|
-
: ethers.
|
|
99
|
+
: ethers.utils.arrayify(ethers.utils.hexlify(this.gasLimit));
|
|
100
100
|
const chainIdBytes = this.chainId === 0n || this.chainId === 0
|
|
101
101
|
? new Uint8Array(0)
|
|
102
|
-
: ethers.
|
|
102
|
+
: ethers.utils.arrayify(ethers.utils.hexlify(this.chainId));
|
|
103
103
|
|
|
104
|
-
const encoded = ethers.
|
|
104
|
+
const encoded = ethers.utils.RLP.encode([
|
|
105
105
|
nonceBytes,
|
|
106
106
|
this.gasPrice === 0n ? new Uint8Array(0) : ethers.getBytes(ethers.toBeHex(this.gasPrice)),
|
|
107
107
|
gasLimitBytes,
|
|
@@ -112,7 +112,7 @@ class PQCLegacyTransaction extends BaseTransaction {
|
|
|
112
112
|
new Uint8Array(0),
|
|
113
113
|
new Uint8Array(0),
|
|
114
114
|
]);
|
|
115
|
-
return ethers.keccak256(encoded);
|
|
115
|
+
return ethers.utils.keccak256(encoded);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
@@ -124,7 +124,7 @@ class PQCLegacyTransaction extends BaseTransaction {
|
|
|
124
124
|
// Ensure wallet is initialized
|
|
125
125
|
await wallet._initPromise;
|
|
126
126
|
|
|
127
|
-
const hash = ethers.
|
|
127
|
+
const hash = ethers.utils.arrayify(this.getSigningHash());
|
|
128
128
|
this.pqcPubKey = wallet.publicKey;
|
|
129
129
|
// Use wallet's sign method which handles the async properly
|
|
130
130
|
this.pqcSig = await wallet.sign(hash);
|
|
@@ -136,7 +136,7 @@ class PQCLegacyTransaction extends BaseTransaction {
|
|
|
136
136
|
|
|
137
137
|
async verify() {
|
|
138
138
|
if (!this.pqcSig || !this.pqcPubKey) return false;
|
|
139
|
-
const hash = ethers.
|
|
139
|
+
const hash = ethers.utils.arrayify(this.getSigningHash());
|
|
140
140
|
// Use dilithium verify directly
|
|
141
141
|
if (dilithium.verify) {
|
|
142
142
|
return dilithium.verify(this.pqcPubKey, hash, this.pqcSig);
|
|
@@ -163,7 +163,7 @@ class PQCLegacyTransaction extends BaseTransaction {
|
|
|
163
163
|
const sHex = encodeSignature(this.s || '0x0');
|
|
164
164
|
const pqcTypeHex = encodeUint64(this.pqcType);
|
|
165
165
|
|
|
166
|
-
const encoded = ethers.
|
|
166
|
+
const encoded = ethers.utils.RLP.encode([
|
|
167
167
|
nonceHex,
|
|
168
168
|
gasPriceHex,
|
|
169
169
|
gasLimitHex,
|
|
@@ -177,11 +177,11 @@ class PQCLegacyTransaction extends BaseTransaction {
|
|
|
177
177
|
this.pqcPubKey,
|
|
178
178
|
this.pqcSig,
|
|
179
179
|
]);
|
|
180
|
-
return ethers.
|
|
180
|
+
return ethers.utils.arrayify(encoded);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
getHex() {
|
|
184
|
-
return ethers.hexlify(this.serialize());
|
|
184
|
+
return ethers.utils.hexlify(this.serialize());
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
@@ -205,15 +205,15 @@ class HybridLegacyTransaction extends BaseTransaction {
|
|
|
205
205
|
getSigningHash() {
|
|
206
206
|
const nonceBytes = this.nonce === 0n || this.nonce === 0
|
|
207
207
|
? new Uint8Array(0)
|
|
208
|
-
: ethers.
|
|
208
|
+
: ethers.utils.arrayify(ethers.utils.hexlify(this.nonce));
|
|
209
209
|
const gasLimitBytes = this.gasLimit === 0n || this.gasLimit === 0
|
|
210
210
|
? new Uint8Array(0)
|
|
211
|
-
: ethers.
|
|
211
|
+
: ethers.utils.arrayify(ethers.utils.hexlify(this.gasLimit));
|
|
212
212
|
const chainIdBytes = this.chainId === 0n || this.chainId === 0
|
|
213
213
|
? new Uint8Array(0)
|
|
214
|
-
: ethers.
|
|
214
|
+
: ethers.utils.arrayify(ethers.utils.hexlify(this.chainId));
|
|
215
215
|
|
|
216
|
-
const encoded = ethers.
|
|
216
|
+
const encoded = ethers.utils.RLP.encode([
|
|
217
217
|
nonceBytes,
|
|
218
218
|
this.gasPrice === 0n ? new Uint8Array(0) : ethers.getBytes(ethers.toBeHex(this.gasPrice)),
|
|
219
219
|
gasLimitBytes,
|
|
@@ -224,7 +224,7 @@ class HybridLegacyTransaction extends BaseTransaction {
|
|
|
224
224
|
new Uint8Array(0),
|
|
225
225
|
new Uint8Array(0),
|
|
226
226
|
]);
|
|
227
|
-
return ethers.keccak256(encoded);
|
|
227
|
+
return ethers.utils.keccak256(encoded);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
@@ -238,7 +238,7 @@ class HybridLegacyTransaction extends BaseTransaction {
|
|
|
238
238
|
await pqcWallet._initPromise;
|
|
239
239
|
|
|
240
240
|
const hash = this.getSigningHash();
|
|
241
|
-
const hashBytes = ethers.
|
|
241
|
+
const hashBytes = ethers.utils.arrayify(hash);
|
|
242
242
|
|
|
243
243
|
// ECDSA signature
|
|
244
244
|
const ecdsaSig = ecdsaWallet.wallet.signingKey.sign(hash);
|
|
@@ -256,7 +256,7 @@ class HybridLegacyTransaction extends BaseTransaction {
|
|
|
256
256
|
|
|
257
257
|
verify() {
|
|
258
258
|
if (!this.pqcSig || !this.pqcPubKey) return false;
|
|
259
|
-
const hash = ethers.
|
|
259
|
+
const hash = ethers.utils.arrayify(this.getSigningHash());
|
|
260
260
|
if (dilithium.verify) {
|
|
261
261
|
return dilithium.verify(this.pqcPubKey, hash, this.pqcSig);
|
|
262
262
|
} else if (dilithium.verifyWithContext) {
|
|
@@ -282,7 +282,7 @@ class HybridLegacyTransaction extends BaseTransaction {
|
|
|
282
282
|
const sHex = encodeSignature(this.s);
|
|
283
283
|
const pqcTypeHex = encodeUint64(this.pqcType);
|
|
284
284
|
|
|
285
|
-
const encoded = ethers.
|
|
285
|
+
const encoded = ethers.utils.RLP.encode([
|
|
286
286
|
nonceHex,
|
|
287
287
|
gasPriceHex,
|
|
288
288
|
gasLimitHex,
|
|
@@ -296,11 +296,11 @@ class HybridLegacyTransaction extends BaseTransaction {
|
|
|
296
296
|
this.pqcPubKey,
|
|
297
297
|
this.pqcSig,
|
|
298
298
|
]);
|
|
299
|
-
return ethers.
|
|
299
|
+
return ethers.utils.arrayify(encoded);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
getHex() {
|
|
303
|
-
return ethers.hexlify(this.serialize());
|
|
303
|
+
return ethers.utils.hexlify(this.serialize());
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
|
|
@@ -355,11 +355,11 @@ class PQCAccessListTransaction extends BaseTransaction {
|
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
getSigningHash() {
|
|
358
|
-
const chainIdHex = this.chainId === 0n || this.chainId === 0 ? '0x' : ethers.
|
|
359
|
-
const nonceHex = this.nonce === 0n || this.nonce === 0 ? '0x' : ethers.
|
|
360
|
-
const gasPriceHex = this.gasPrice === 0n || this.gasPrice === 0 ? '0x' : ethers.
|
|
361
|
-
const gasHex = this.gasLimit === 0n || this.gasLimit === 0 ? '0x' : ethers.
|
|
362
|
-
const valueHex = this.value === 0n || this.value === 0 ? '0x' : ethers.
|
|
358
|
+
const chainIdHex = this.chainId === 0n || this.chainId === 0 ? '0x' : ethers.utils.hexlify(this.chainId);
|
|
359
|
+
const nonceHex = this.nonce === 0n || this.nonce === 0 ? '0x' : ethers.utils.hexlify(this.nonce);
|
|
360
|
+
const gasPriceHex = this.gasPrice === 0n || this.gasPrice === 0 ? '0x' : ethers.utils.hexlify(this.gasPrice);
|
|
361
|
+
const gasHex = this.gasLimit === 0n || this.gasLimit === 0 ? '0x' : ethers.utils.hexlify(this.gasLimit);
|
|
362
|
+
const valueHex = this.value === 0n || this.value === 0 ? '0x' : ethers.utils.hexlify(this.value);
|
|
363
363
|
|
|
364
364
|
const rlpData = [
|
|
365
365
|
chainIdHex,
|
|
@@ -372,22 +372,22 @@ class PQCAccessListTransaction extends BaseTransaction {
|
|
|
372
372
|
this.accessList || [],
|
|
373
373
|
];
|
|
374
374
|
|
|
375
|
-
const encodedHex = ethers.
|
|
376
|
-
const encoded = ethers.
|
|
375
|
+
const encodedHex = ethers.utils.RLP.encode(rlpData);
|
|
376
|
+
const encoded = ethers.utils.arrayify(encodedHex);
|
|
377
377
|
|
|
378
378
|
const typeByte = TX_TYPE.ACCESS_LIST;
|
|
379
379
|
const prefixed = new Uint8Array(1 + encoded.length);
|
|
380
380
|
prefixed[0] = typeByte;
|
|
381
381
|
prefixed.set(encoded, 1);
|
|
382
382
|
|
|
383
|
-
return ethers.keccak256(ethers.hexlify(prefixed));
|
|
383
|
+
return ethers.utils.keccak256(ethers.utils.hexlify(prefixed));
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
async sign(wallet) {
|
|
387
387
|
// Ensure wallet is initialized
|
|
388
388
|
await wallet._initPromise;
|
|
389
389
|
|
|
390
|
-
const hash = ethers.
|
|
390
|
+
const hash = ethers.utils.arrayify(this.getSigningHash());
|
|
391
391
|
this.pqcPubKey = wallet.publicKey;
|
|
392
392
|
this.pqcSig = await wallet.sign(hash);
|
|
393
393
|
return this;
|
|
@@ -395,7 +395,7 @@ class PQCAccessListTransaction extends BaseTransaction {
|
|
|
395
395
|
|
|
396
396
|
async verify() {
|
|
397
397
|
if (!this.pqcSig || !this.pqcPubKey) return false;
|
|
398
|
-
const hash = ethers.
|
|
398
|
+
const hash = ethers.utils.arrayify(this.getSigningHash());
|
|
399
399
|
if (dilithium.verify) {
|
|
400
400
|
return dilithium.verify(this.pqcPubKey, hash, this.pqcSig);
|
|
401
401
|
} else if (dilithium.verifyWithContext) {
|
|
@@ -423,7 +423,7 @@ class PQCAccessListTransaction extends BaseTransaction {
|
|
|
423
423
|
const sHex = encodeSignature(this.s || '0x0');
|
|
424
424
|
const pqcTypeHex = encodeUint64(this.pqcType);
|
|
425
425
|
|
|
426
|
-
const encoded = ethers.
|
|
426
|
+
const encoded = ethers.utils.RLP.encode([
|
|
427
427
|
chainIdHex,
|
|
428
428
|
nonceHex,
|
|
429
429
|
gasPriceHex,
|
|
@@ -440,7 +440,7 @@ class PQCAccessListTransaction extends BaseTransaction {
|
|
|
440
440
|
this.pqcSig,
|
|
441
441
|
]);
|
|
442
442
|
|
|
443
|
-
const encodedBytes = ethers.
|
|
443
|
+
const encodedBytes = ethers.utils.arrayify(encoded);
|
|
444
444
|
const typeByte = new Uint8Array([TX_TYPE.ACCESS_LIST]);
|
|
445
445
|
const prefixed = new Uint8Array(typeByte.length + encodedBytes.length);
|
|
446
446
|
prefixed.set(typeByte, 0);
|
|
@@ -450,7 +450,7 @@ class PQCAccessListTransaction extends BaseTransaction {
|
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
getHex() {
|
|
453
|
-
return ethers.hexlify(this.serialize());
|
|
453
|
+
return ethers.utils.hexlify(this.serialize());
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
|
|
@@ -510,8 +510,8 @@ class PQCDynamicFeeTransaction extends BaseTransaction {
|
|
|
510
510
|
getSigningHash() {
|
|
511
511
|
const chainIdHex = this.chainId === 0n || this.chainId === 0 ? '0x' : ethers.toBeHex(this.chainId);
|
|
512
512
|
const nonceHex = this.nonce === 0n || this.nonce === 0 ? '0x' : ethers.toBeHex(this.nonce);
|
|
513
|
-
const gasTipCapHex = this.maxPriorityFeePerGas === 0n || this.maxPriorityFeePerGas === 0 ? '0x' : ethers.
|
|
514
|
-
const gasFeeCapHex = this.maxFeePerGas === 0n || this.maxFeePerGas === 0 ? '0x' : ethers.
|
|
513
|
+
const gasTipCapHex = this.maxPriorityFeePerGas === 0n || this.maxPriorityFeePerGas === 0 ? '0x' : ethers.utils.hexlify(this.maxPriorityFeePerGas);
|
|
514
|
+
const gasFeeCapHex = this.maxFeePerGas === 0n || this.maxFeePerGas === 0 ? '0x' : ethers.utils.hexlify(this.maxFeePerGas);
|
|
515
515
|
const gasHex = this.gasLimit === 0n || this.gasLimit === 0 ? '0x' : ethers.toBeHex(this.gasLimit);
|
|
516
516
|
const valueHex = this.value === 0n || this.value === 0 ? '0x' : ethers.toBeHex(this.value);
|
|
517
517
|
|
|
@@ -527,22 +527,22 @@ class PQCDynamicFeeTransaction extends BaseTransaction {
|
|
|
527
527
|
this.accessList || [],
|
|
528
528
|
];
|
|
529
529
|
|
|
530
|
-
const encodedHex = ethers.
|
|
531
|
-
const encoded = ethers.
|
|
530
|
+
const encodedHex = ethers.utils.RLP.encode(rlpData);
|
|
531
|
+
const encoded = ethers.utils.arrayify(encodedHex);
|
|
532
532
|
|
|
533
533
|
const typeByte = TX_TYPE.DYNAMIC_FEE;
|
|
534
534
|
const prefixed = new Uint8Array(1 + encoded.length);
|
|
535
535
|
prefixed[0] = typeByte;
|
|
536
536
|
prefixed.set(encoded, 1);
|
|
537
537
|
|
|
538
|
-
return ethers.keccak256(ethers.hexlify(prefixed));
|
|
538
|
+
return ethers.utils.keccak256(ethers.utils.hexlify(prefixed));
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
async sign(wallet) {
|
|
542
542
|
// Ensure wallet is initialized
|
|
543
543
|
await wallet._initPromise;
|
|
544
544
|
|
|
545
|
-
const hash = ethers.
|
|
545
|
+
const hash = ethers.utils.arrayify(this.getSigningHash());
|
|
546
546
|
this.pqcPubKey = wallet.publicKey;
|
|
547
547
|
this.pqcSig = await wallet.sign(hash);
|
|
548
548
|
return this;
|
|
@@ -550,7 +550,7 @@ class PQCDynamicFeeTransaction extends BaseTransaction {
|
|
|
550
550
|
|
|
551
551
|
async verify() {
|
|
552
552
|
if (!this.pqcSig || !this.pqcPubKey) return false;
|
|
553
|
-
const hash = ethers.
|
|
553
|
+
const hash = ethers.utils.arrayify(this.getSigningHash());
|
|
554
554
|
if (dilithium.verify) {
|
|
555
555
|
return dilithium.verify(this.pqcPubKey, hash, this.pqcSig);
|
|
556
556
|
} else if (dilithium.verifyWithContext) {
|
|
@@ -579,7 +579,7 @@ class PQCDynamicFeeTransaction extends BaseTransaction {
|
|
|
579
579
|
const sHex = encodeSignature(this.s || '0x0');
|
|
580
580
|
const pqcTypeHex = encodeUint64(this.pqcType);
|
|
581
581
|
|
|
582
|
-
const encoded = ethers.
|
|
582
|
+
const encoded = ethers.utils.RLP.encode([
|
|
583
583
|
chainIdHex,
|
|
584
584
|
nonceHex,
|
|
585
585
|
gasTipCapHex,
|
|
@@ -597,7 +597,7 @@ class PQCDynamicFeeTransaction extends BaseTransaction {
|
|
|
597
597
|
this.pqcSig,
|
|
598
598
|
]);
|
|
599
599
|
|
|
600
|
-
const encodedBytes = ethers.
|
|
600
|
+
const encodedBytes = ethers.utils.arrayify(encoded);
|
|
601
601
|
const typeByte = new Uint8Array([TX_TYPE.DYNAMIC_FEE]);
|
|
602
602
|
const prefixed = new Uint8Array(typeByte.length + encodedBytes.length);
|
|
603
603
|
prefixed.set(typeByte, 0);
|
|
@@ -607,7 +607,7 @@ class PQCDynamicFeeTransaction extends BaseTransaction {
|
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
getHex() {
|
|
610
|
-
return ethers.hexlify(this.serialize());
|
|
610
|
+
return ethers.utils.hexlify(this.serialize());
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
|
package/src/utils/address.js
CHANGED
|
@@ -11,8 +11,8 @@ const { ethers } = require('ethers');
|
|
|
11
11
|
* @returns {string} Ethereum address
|
|
12
12
|
*/
|
|
13
13
|
function derivePQCAddress(publicKey) {
|
|
14
|
-
const hash = ethers.keccak256(publicKey);
|
|
15
|
-
return ethers.getAddress('0x' + hash.slice(-40));
|
|
14
|
+
const hash = ethers.utils.keccak256(publicKey);
|
|
15
|
+
return ethers.utils.getAddress('0x' + hash.slice(-40));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -34,8 +34,8 @@ function deriveHybridAddress(ecdsaPublicKey, dilithiumPublicKey) {
|
|
|
34
34
|
concat.set(dilithiumPublicKey, ecdsaBytes.length);
|
|
35
35
|
|
|
36
36
|
// Hash and derive address
|
|
37
|
-
const hash = ethers.keccak256(concat);
|
|
38
|
-
return ethers.getAddress('0x' + hash.slice(-40));
|
|
37
|
+
const hash = ethers.utils.keccak256(concat);
|
|
38
|
+
return ethers.utils.getAddress('0x' + hash.slice(-40));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
package/src/utils/rlp.js
CHANGED
|
@@ -14,7 +14,7 @@ function encodeUint64(value) {
|
|
|
14
14
|
return '0x';
|
|
15
15
|
}
|
|
16
16
|
const bigValue = typeof value === 'bigint' ? value : BigInt(value);
|
|
17
|
-
return ethers.
|
|
17
|
+
return ethers.utils.hexlify(bigValue);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -26,7 +26,7 @@ function encodeBigInt(value) {
|
|
|
26
26
|
return '0x';
|
|
27
27
|
}
|
|
28
28
|
const bigValue = typeof value === 'bigint' ? value : BigInt(value);
|
|
29
|
-
return ethers.
|
|
29
|
+
return ethers.utils.hexlify(bigValue);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -39,7 +39,7 @@ function encodeSignature(value) {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const hex = value.startsWith('0x') ? value : '0x' + value;
|
|
42
|
-
let bytes = ethers.
|
|
42
|
+
let bytes = ethers.utils.arrayify(hex);
|
|
43
43
|
|
|
44
44
|
// Remove leading zeros for canonical form
|
|
45
45
|
let startIdx = 0;
|
|
@@ -52,7 +52,7 @@ function encodeSignature(value) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
bytes = bytes.slice(startIdx);
|
|
55
|
-
return ethers.hexlify(bytes);
|
|
55
|
+
return ethers.utils.hexlify(bytes);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
module.exports = {
|
package/src/wallet.js
CHANGED
|
@@ -132,8 +132,8 @@ class PQCWallet {
|
|
|
132
132
|
if (!secretKey || !publicKey) {
|
|
133
133
|
throw new Error('Both secretKey and publicKey are required');
|
|
134
134
|
}
|
|
135
|
-
const secret = secretKey instanceof Uint8Array ? secretKey : ethers.
|
|
136
|
-
const pub = publicKey instanceof Uint8Array ? publicKey : ethers.
|
|
135
|
+
const secret = secretKey instanceof Uint8Array ? secretKey : ethers.utils.arrayify(secretKey);
|
|
136
|
+
const pub = publicKey instanceof Uint8Array ? publicKey : ethers.utils.arrayify(publicKey);
|
|
137
137
|
return new PQCWallet(secret, pub);
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -185,7 +185,7 @@ class PQCWallet {
|
|
|
185
185
|
*/
|
|
186
186
|
async getPublicKeyHex() {
|
|
187
187
|
await this._initPromise;
|
|
188
|
-
return ethers.hexlify(this.publicKey);
|
|
188
|
+
return ethers.utils.hexlify(this.publicKey);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
@@ -194,7 +194,7 @@ class PQCWallet {
|
|
|
194
194
|
*/
|
|
195
195
|
async getSecretKeyHex() {
|
|
196
196
|
await this._initPromise;
|
|
197
|
-
return ethers.hexlify(this.secretKey);
|
|
197
|
+
return ethers.utils.hexlify(this.secretKey);
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
@@ -223,7 +223,7 @@ class HybridWallet {
|
|
|
223
223
|
await pqc._initPromise; // Wait for PQC keys to be generated
|
|
224
224
|
const wallet = new HybridWallet(ecdsa, pqc);
|
|
225
225
|
wallet.address = deriveHybridAddress(
|
|
226
|
-
ethers.
|
|
226
|
+
ethers.utils.arrayify(ecdsa.getPublicKey()),
|
|
227
227
|
pqc.publicKey
|
|
228
228
|
);
|
|
229
229
|
wallet._initialized = true;
|
|
@@ -243,7 +243,7 @@ class HybridWallet {
|
|
|
243
243
|
await this.pqcWallet._initPromise;
|
|
244
244
|
|
|
245
245
|
this.address = deriveHybridAddress(
|
|
246
|
-
ethers.
|
|
246
|
+
ethers.utils.arrayify(this.ecdsaWallet.getPublicKey()),
|
|
247
247
|
this.pqcWallet.publicKey
|
|
248
248
|
);
|
|
249
249
|
this._initialized = true;
|
|
@@ -262,7 +262,7 @@ class HybridWallet {
|
|
|
262
262
|
const pqcWallet = new PQCWallet(pqcSecretKey, pqcPublicKey);
|
|
263
263
|
const wallet = new HybridWallet(ecdsaWallet, pqcWallet);
|
|
264
264
|
wallet.address = deriveHybridAddress(
|
|
265
|
-
ethers.
|
|
265
|
+
ethers.utils.arrayify(ecdsaWallet.getPublicKey()),
|
|
266
266
|
pqcWallet.publicKey
|
|
267
267
|
);
|
|
268
268
|
wallet._initialized = true;
|
package/src/zk-transaction.js
CHANGED
|
@@ -51,27 +51,27 @@ class ZKTransaction {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
if (this.to) args.to = this.to;
|
|
54
|
-
if (this.value) args.value = ethers.
|
|
55
|
-
if (this.gasLimit) args.gas = ethers.
|
|
56
|
-
if (this.gasPrice) args.gasPrice = ethers.
|
|
54
|
+
if (this.value) args.value = ethers.utils.hexlify(this.value);
|
|
55
|
+
if (this.gasLimit) args.gas = ethers.utils.hexlify(this.gasLimit);
|
|
56
|
+
if (this.gasPrice) args.gasPrice = ethers.utils.hexlify(this.gasPrice);
|
|
57
57
|
if (this.data) args.data = this.data;
|
|
58
|
-
if (this.nonce) args.nonce = ethers.
|
|
59
|
-
if (this.chainId) args.chainId = ethers.
|
|
58
|
+
if (this.nonce) args.nonce = ethers.utils.hexlify(this.nonce);
|
|
59
|
+
if (this.chainId) args.chainId = ethers.utils.hexlify(this.chainId);
|
|
60
60
|
if (this.accessList && this.accessList.length > 0) args.accessList = this.accessList;
|
|
61
61
|
if (this.zkPublicInputs && this.zkPublicInputs.length > 0) {
|
|
62
62
|
args.zkPublicInputs = this.zkPublicInputs.map(pi =>
|
|
63
|
-
typeof pi === 'string' ? pi : ethers.hexlify(pi)
|
|
63
|
+
typeof pi === 'string' ? pi : ethers.utils.hexlify(pi)
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
if (this.zkVerificationKeyHash) {
|
|
67
67
|
args.zkVerificationKeyHash = typeof this.zkVerificationKeyHash === 'string'
|
|
68
68
|
? this.zkVerificationKeyHash
|
|
69
|
-
: ethers.hexlify(this.zkVerificationKeyHash);
|
|
69
|
+
: ethers.utils.hexlify(this.zkVerificationKeyHash);
|
|
70
70
|
}
|
|
71
71
|
if (this.encryptedPayload) {
|
|
72
72
|
args.encryptedPayload = typeof this.encryptedPayload === 'string'
|
|
73
73
|
? this.encryptedPayload
|
|
74
|
-
: ethers.hexlify(this.encryptedPayload);
|
|
74
|
+
: ethers.utils.hexlify(this.encryptedPayload);
|
|
75
75
|
}
|
|
76
76
|
if (this.recipients && this.recipients.length > 0) {
|
|
77
77
|
args.recipients = this.recipients;
|