@agirails/sdk 2.0.0-beta
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 +183 -0
- package/dist/ACTPClient.d.ts +52 -0
- package/dist/ACTPClient.d.ts.map +1 -0
- package/dist/ACTPClient.js +120 -0
- package/dist/ACTPClient.js.map +1 -0
- package/dist/abi/ACTPKernel.json +1340 -0
- package/dist/abi/ERC20.json +38 -0
- package/dist/abi/EscrowVault.json +64 -0
- package/dist/builders/DeliveryProofBuilder.d.ts +37 -0
- package/dist/builders/DeliveryProofBuilder.d.ts.map +1 -0
- package/dist/builders/DeliveryProofBuilder.js +165 -0
- package/dist/builders/DeliveryProofBuilder.js.map +1 -0
- package/dist/builders/QuoteBuilder.d.ts +68 -0
- package/dist/builders/QuoteBuilder.d.ts.map +1 -0
- package/dist/builders/QuoteBuilder.js +255 -0
- package/dist/builders/QuoteBuilder.js.map +1 -0
- package/dist/builders/index.d.ts +3 -0
- package/dist/builders/index.d.ts.map +1 -0
- package/dist/builders/index.js +10 -0
- package/dist/builders/index.js.map +1 -0
- package/dist/config/networks.d.ts +27 -0
- package/dist/config/networks.d.ts.map +1 -0
- package/dist/config/networks.js +103 -0
- package/dist/config/networks.js.map +1 -0
- package/dist/errors/index.d.ts +38 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +87 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol/ACTPKernel.d.ts +30 -0
- package/dist/protocol/ACTPKernel.d.ts.map +1 -0
- package/dist/protocol/ACTPKernel.js +261 -0
- package/dist/protocol/ACTPKernel.js.map +1 -0
- package/dist/protocol/EASHelper.d.ts +23 -0
- package/dist/protocol/EASHelper.d.ts.map +1 -0
- package/dist/protocol/EASHelper.js +106 -0
- package/dist/protocol/EASHelper.js.map +1 -0
- package/dist/protocol/EscrowVault.d.ts +24 -0
- package/dist/protocol/EscrowVault.d.ts.map +1 -0
- package/dist/protocol/EscrowVault.js +114 -0
- package/dist/protocol/EscrowVault.js.map +1 -0
- package/dist/protocol/EventMonitor.d.ts +18 -0
- package/dist/protocol/EventMonitor.d.ts.map +1 -0
- package/dist/protocol/EventMonitor.js +92 -0
- package/dist/protocol/EventMonitor.js.map +1 -0
- package/dist/protocol/MessageSigner.d.ts +23 -0
- package/dist/protocol/MessageSigner.d.ts.map +1 -0
- package/dist/protocol/MessageSigner.js +178 -0
- package/dist/protocol/MessageSigner.js.map +1 -0
- package/dist/protocol/ProofGenerator.d.ts +22 -0
- package/dist/protocol/ProofGenerator.d.ts.map +1 -0
- package/dist/protocol/ProofGenerator.js +64 -0
- package/dist/protocol/ProofGenerator.js.map +1 -0
- package/dist/protocol/QuoteBuilder.d.ts +2 -0
- package/dist/protocol/QuoteBuilder.d.ts.map +1 -0
- package/dist/protocol/QuoteBuilder.js +7 -0
- package/dist/protocol/QuoteBuilder.js.map +1 -0
- package/dist/types/eip712.d.ts +106 -0
- package/dist/types/eip712.d.ts.map +1 -0
- package/dist/types/eip712.js +84 -0
- package/dist/types/eip712.js.map +1 -0
- package/dist/types/escrow.d.ts +18 -0
- package/dist/types/escrow.d.ts.map +1 -0
- package/dist/types/escrow.js +3 -0
- package/dist/types/escrow.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +22 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/message.d.ts +109 -0
- package/dist/types/message.d.ts.map +1 -0
- package/dist/types/message.js +3 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/state.d.ts +19 -0
- package/dist/types/state.d.ts.map +1 -0
- package/dist/types/state.js +49 -0
- package/dist/types/state.js.map +1 -0
- package/dist/types/transaction.d.ts +36 -0
- package/dist/types/transaction.d.ts.map +1 -0
- package/dist/types/transaction.js +3 -0
- package/dist/types/transaction.js.map +1 -0
- package/dist/utils/IPFSClient.d.ts +37 -0
- package/dist/utils/IPFSClient.d.ts.map +1 -0
- package/dist/utils/IPFSClient.js +128 -0
- package/dist/utils/IPFSClient.js.map +1 -0
- package/dist/utils/NonceManager.d.ts +34 -0
- package/dist/utils/NonceManager.d.ts.map +1 -0
- package/dist/utils/NonceManager.js +114 -0
- package/dist/utils/NonceManager.js.map +1 -0
- package/dist/utils/ReceivedNonceTracker.d.ts +35 -0
- package/dist/utils/ReceivedNonceTracker.d.ts.map +1 -0
- package/dist/utils/ReceivedNonceTracker.js +196 -0
- package/dist/utils/ReceivedNonceTracker.js.map +1 -0
- package/dist/utils/canonicalJson.d.ts +4 -0
- package/dist/utils/canonicalJson.d.ts.map +1 -0
- package/dist/utils/canonicalJson.js +21 -0
- package/dist/utils/canonicalJson.js.map +1 -0
- package/dist/utils/computeTypeHash.d.ts +3 -0
- package/dist/utils/computeTypeHash.d.ts.map +1 -0
- package/dist/utils/computeTypeHash.js +30 -0
- package/dist/utils/computeTypeHash.js.map +1 -0
- package/dist/utils/validation.d.ts +6 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +46 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +73 -0
- package/src/ACTPClient.ts +276 -0
- package/src/__tests__/ProofGenerator.test.ts +124 -0
- package/src/__tests__/QuoteBuilder.test.ts +516 -0
- package/src/__tests__/StateMachine.test.ts +82 -0
- package/src/__tests__/builders/DeliveryProofBuilder.test.ts +581 -0
- package/src/__tests__/integration/ACTPClient.test.ts +263 -0
- package/src/__tests__/integration.test.ts +289 -0
- package/src/__tests__/protocol/EASHelper.test.ts +472 -0
- package/src/__tests__/protocol/EventMonitor.test.ts +382 -0
- package/src/__tests__/security/ACTPKernel.security.test.ts +1167 -0
- package/src/__tests__/security/EscrowVault.security.test.ts +570 -0
- package/src/__tests__/security/MessageSigner.security.test.ts +286 -0
- package/src/__tests__/security/NonceReplay.security.test.ts +501 -0
- package/src/__tests__/security/validation.security.test.ts +376 -0
- package/src/__tests__/utils/IPFSClient.test.ts +262 -0
- package/src/__tests__/utils/NonceManager.test.ts +205 -0
- package/src/__tests__/utils/canonicalJson.test.ts +153 -0
- package/src/abi/ACTPKernel.json +1340 -0
- package/src/abi/ERC20.json +40 -0
- package/src/abi/EscrowVault.json +66 -0
- package/src/builders/DeliveryProofBuilder.ts +326 -0
- package/src/builders/QuoteBuilder.ts +483 -0
- package/src/builders/index.ts +17 -0
- package/src/config/networks.ts +165 -0
- package/src/errors/index.ts +130 -0
- package/src/index.ts +108 -0
- package/src/protocol/ACTPKernel.ts +625 -0
- package/src/protocol/EASHelper.ts +197 -0
- package/src/protocol/EscrowVault.ts +237 -0
- package/src/protocol/EventMonitor.ts +161 -0
- package/src/protocol/MessageSigner.ts +336 -0
- package/src/protocol/ProofGenerator.ts +119 -0
- package/src/protocol/QuoteBuilder.ts +15 -0
- package/src/types/eip712.ts +175 -0
- package/src/types/escrow.ts +26 -0
- package/src/types/index.ts +10 -0
- package/src/types/message.ts +145 -0
- package/src/types/state.ts +77 -0
- package/src/types/transaction.ts +54 -0
- package/src/utils/IPFSClient.ts +248 -0
- package/src/utils/NonceManager.ts +293 -0
- package/src/utils/ReceivedNonceTracker.ts +397 -0
- package/src/utils/canonicalJson.ts +38 -0
- package/src/utils/computeTypeHash.ts +50 -0
- package/src/utils/validation.ts +82 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MessageSigner Security Test Suite
|
|
3
|
+
*
|
|
4
|
+
* CRITICAL: EIP-712 signature security is essential for message integrity
|
|
5
|
+
* Coverage Target: 100% (security-critical code)
|
|
6
|
+
*
|
|
7
|
+
* Security Test Categories:
|
|
8
|
+
* 1. Domain Initialization Security (2 tests)
|
|
9
|
+
* 2. Signature Tampering Detection (3 tests)
|
|
10
|
+
* 3. Message Integrity Protection (3 tests)
|
|
11
|
+
* 4. DID/Address Validation (2 tests)
|
|
12
|
+
*
|
|
13
|
+
* Attack Vectors Tested:
|
|
14
|
+
* - Signature forgery
|
|
15
|
+
* - Message payload tampering
|
|
16
|
+
* - Cross-contract signature replay
|
|
17
|
+
* - DID injection attacks
|
|
18
|
+
*
|
|
19
|
+
* References:
|
|
20
|
+
* - MessageSigner.ts implementation
|
|
21
|
+
* - EIP-712 specification
|
|
22
|
+
* - V4 vulnerability (nonce replay)
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { Wallet } from 'ethers';
|
|
26
|
+
import { MessageSigner } from '../../protocol/MessageSigner';
|
|
27
|
+
import { ACTPMessage } from '../../types';
|
|
28
|
+
|
|
29
|
+
// Test signers
|
|
30
|
+
const testPrivateKey1 = '0x' + '1'.repeat(64);
|
|
31
|
+
const testPrivateKey2 = '0x' + '2'.repeat(64);
|
|
32
|
+
const signer1 = new Wallet(testPrivateKey1);
|
|
33
|
+
const signer2 = new Wallet(testPrivateKey2);
|
|
34
|
+
|
|
35
|
+
const TEST_KERNEL_ADDRESS = '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
|
|
36
|
+
|
|
37
|
+
describe('MessageSigner - Domain Initialization Security', () => {
|
|
38
|
+
it('should prevent signing without domain initialization', async () => {
|
|
39
|
+
const messageSigner = new MessageSigner(signer1);
|
|
40
|
+
|
|
41
|
+
const message: ACTPMessage = {
|
|
42
|
+
type: 'test.message',
|
|
43
|
+
version: '1.0.0',
|
|
44
|
+
from: `did:ethr:${signer1.address}`,
|
|
45
|
+
to: `did:ethr:${signer2.address}`,
|
|
46
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
47
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
48
|
+
data: { test: 'value' }
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Should throw when domain not initialized
|
|
52
|
+
await expect(messageSigner.signMessage(message)).rejects.toThrow('Domain not initialized');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should initialize domain with correct chainId', async () => {
|
|
56
|
+
const messageSigner = new MessageSigner(signer1);
|
|
57
|
+
|
|
58
|
+
// Initialize with explicit chainId
|
|
59
|
+
await messageSigner.initDomain(TEST_KERNEL_ADDRESS, 84532);
|
|
60
|
+
|
|
61
|
+
// Should not throw after initialization
|
|
62
|
+
const message: ACTPMessage = {
|
|
63
|
+
type: 'test.message',
|
|
64
|
+
version: '1.0.0',
|
|
65
|
+
from: `did:ethr:${signer1.address}`,
|
|
66
|
+
to: `did:ethr:${signer2.address}`,
|
|
67
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
68
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
69
|
+
data: { test: 'value' }
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const signature = await messageSigner.signMessage(message);
|
|
73
|
+
expect(signature).toMatch(/^0x[a-fA-F0-9]{130}$/);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('MessageSigner - Signature Tampering Detection', () => {
|
|
78
|
+
let messageSigner: MessageSigner;
|
|
79
|
+
|
|
80
|
+
beforeAll(async () => {
|
|
81
|
+
messageSigner = new MessageSigner(signer1);
|
|
82
|
+
await messageSigner.initDomain(TEST_KERNEL_ADDRESS, 84532);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should detect tampered message payload', async () => {
|
|
86
|
+
const originalMessage: ACTPMessage = {
|
|
87
|
+
type: 'test.message',
|
|
88
|
+
version: '1.0.0',
|
|
89
|
+
from: `did:ethr:${signer1.address}`,
|
|
90
|
+
to: `did:ethr:${signer2.address}`,
|
|
91
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
92
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
93
|
+
data: { amount: '100', action: 'transfer' }
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const signature = await messageSigner.signMessage(originalMessage);
|
|
97
|
+
|
|
98
|
+
// Tamper with the message payload
|
|
99
|
+
const tamperedMessage: ACTPMessage = {
|
|
100
|
+
...originalMessage,
|
|
101
|
+
data: { amount: '1000000', action: 'transfer' } // Changed amount
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Verification should fail with tampered message
|
|
105
|
+
const isValid = await messageSigner.verifySignature(tamperedMessage, signature);
|
|
106
|
+
expect(isValid).toBe(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should detect invalid signature format', async () => {
|
|
110
|
+
const message: ACTPMessage = {
|
|
111
|
+
type: 'test.message',
|
|
112
|
+
version: '1.0.0',
|
|
113
|
+
from: `did:ethr:${signer1.address}`,
|
|
114
|
+
to: `did:ethr:${signer2.address}`,
|
|
115
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
116
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
117
|
+
data: { test: 'value' }
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Invalid signature (wrong length, wrong format)
|
|
121
|
+
const invalidSignature = '0x' + '9'.repeat(130);
|
|
122
|
+
|
|
123
|
+
// Invalid signature format will throw cryptographic error
|
|
124
|
+
await expect(messageSigner.verifySignature(message, invalidSignature))
|
|
125
|
+
.rejects.toThrow();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should throw SignatureVerificationError on invalid signature', async () => {
|
|
129
|
+
const message: ACTPMessage = {
|
|
130
|
+
type: 'test.message',
|
|
131
|
+
version: '1.0.0',
|
|
132
|
+
from: `did:ethr:${signer1.address}`,
|
|
133
|
+
to: `did:ethr:${signer2.address}`,
|
|
134
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
135
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
136
|
+
data: { test: 'value' }
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const invalidSignature = '0x' + '0'.repeat(130);
|
|
140
|
+
|
|
141
|
+
// Should throw error (either cryptographic error or SignatureVerificationError)
|
|
142
|
+
await expect(messageSigner.verifySignatureOrThrow(message, invalidSignature))
|
|
143
|
+
.rejects.toThrow();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('MessageSigner - Message Integrity Protection', () => {
|
|
148
|
+
let messageSigner: MessageSigner;
|
|
149
|
+
|
|
150
|
+
beforeAll(async () => {
|
|
151
|
+
messageSigner = new MessageSigner(signer1);
|
|
152
|
+
await messageSigner.initDomain(TEST_KERNEL_ADDRESS, 84532);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should verify valid signature', async () => {
|
|
156
|
+
const message: ACTPMessage = {
|
|
157
|
+
type: 'test.message',
|
|
158
|
+
version: '1.0.0',
|
|
159
|
+
from: `did:ethr:${signer1.address}`,
|
|
160
|
+
to: `did:ethr:${signer2.address}`,
|
|
161
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
162
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
163
|
+
data: { test: 'value' }
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const signature = await messageSigner.signMessage(message);
|
|
167
|
+
const isValid = await messageSigner.verifySignature(message, signature);
|
|
168
|
+
|
|
169
|
+
expect(isValid).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('should detect signature from wrong signer', async () => {
|
|
173
|
+
const message: ACTPMessage = {
|
|
174
|
+
type: 'test.message',
|
|
175
|
+
version: '1.0.0',
|
|
176
|
+
from: `did:ethr:${signer1.address}`, // Claims to be from signer1
|
|
177
|
+
to: `did:ethr:${signer2.address}`,
|
|
178
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
179
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
180
|
+
data: { test: 'value' }
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// But sign with signer2
|
|
184
|
+
const maliciousSigner = new MessageSigner(signer2);
|
|
185
|
+
await maliciousSigner.initDomain(TEST_KERNEL_ADDRESS, 84532);
|
|
186
|
+
const maliciousSignature = await maliciousSigner.signMessage(message);
|
|
187
|
+
|
|
188
|
+
// Verification should fail (signature doesn't match claimed 'from' address)
|
|
189
|
+
const isValid = await messageSigner.verifySignature(message, maliciousSignature);
|
|
190
|
+
expect(isValid).toBe(false);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('should use canonical JSON encoding for payload', async () => {
|
|
194
|
+
// Test that different JSON key ordering produces same signature
|
|
195
|
+
const message1: ACTPMessage = {
|
|
196
|
+
type: 'test.message',
|
|
197
|
+
version: '1.0.0',
|
|
198
|
+
from: `did:ethr:${signer1.address}`,
|
|
199
|
+
to: `did:ethr:${signer2.address}`,
|
|
200
|
+
timestamp: 1234567890,
|
|
201
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
202
|
+
data: { b: 'value2', a: 'value1' } // Keys in different order
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const message2: ACTPMessage = {
|
|
206
|
+
type: 'test.message',
|
|
207
|
+
version: '1.0.0',
|
|
208
|
+
from: `did:ethr:${signer1.address}`,
|
|
209
|
+
to: `did:ethr:${signer2.address}`,
|
|
210
|
+
timestamp: 1234567890,
|
|
211
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
212
|
+
data: { a: 'value1', b: 'value2' } // Same data, keys sorted
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const signature1 = await messageSigner.signMessage(message1);
|
|
216
|
+
const signature2 = await messageSigner.signMessage(message2);
|
|
217
|
+
|
|
218
|
+
// Signatures should be identical due to canonical JSON encoding
|
|
219
|
+
expect(signature1).toBe(signature2);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('MessageSigner - DID/Address Validation', () => {
|
|
224
|
+
it('should convert valid Ethereum address to DID', () => {
|
|
225
|
+
const messageSigner = new MessageSigner(signer1);
|
|
226
|
+
const address = '0x742d35cc6634c0532925a3b844bc9e7595f0beb0';
|
|
227
|
+
|
|
228
|
+
const did = messageSigner.addressToDID(address);
|
|
229
|
+
|
|
230
|
+
expect(did).toBe(`did:ethr:${address}`);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('should reject invalid Ethereum address in addressToDID', () => {
|
|
234
|
+
const messageSigner = new MessageSigner(signer1);
|
|
235
|
+
const invalidAddress = 'not-an-address';
|
|
236
|
+
|
|
237
|
+
expect(() => messageSigner.addressToDID(invalidAddress)).toThrow('Invalid Ethereum address');
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('should handle standard DID format', async () => {
|
|
241
|
+
const messageSigner = new MessageSigner(signer1);
|
|
242
|
+
await messageSigner.initDomain(TEST_KERNEL_ADDRESS, 84532);
|
|
243
|
+
|
|
244
|
+
const message: ACTPMessage = {
|
|
245
|
+
type: 'test.message',
|
|
246
|
+
version: '1.0.0',
|
|
247
|
+
from: `did:ethr:${signer1.address}`,
|
|
248
|
+
to: `did:ethr:${signer2.address}`,
|
|
249
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
250
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
251
|
+
data: { test: 'value' }
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const signature = await messageSigner.signMessage(message);
|
|
255
|
+
const isValid = await messageSigner.verifySignature(message, signature);
|
|
256
|
+
|
|
257
|
+
expect(isValid).toBe(true);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('should verify cross-contract signature isolation', async () => {
|
|
261
|
+
// Sign message with domain 1 (kernel address 1)
|
|
262
|
+
const messageSigner1 = new MessageSigner(signer1);
|
|
263
|
+
await messageSigner1.initDomain('0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 84532);
|
|
264
|
+
|
|
265
|
+
const message: ACTPMessage = {
|
|
266
|
+
type: 'test.message',
|
|
267
|
+
version: '1.0.0',
|
|
268
|
+
from: `did:ethr:${signer1.address}`,
|
|
269
|
+
to: `did:ethr:${signer2.address}`,
|
|
270
|
+
timestamp: Math.floor(Date.now() / 1000),
|
|
271
|
+
nonce: '0x' + '0'.repeat(63) + '1', // bytes32
|
|
272
|
+
data: { test: 'value' }
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const signature = await messageSigner1.signMessage(message);
|
|
276
|
+
|
|
277
|
+
// Try to verify with domain 2 (different kernel address)
|
|
278
|
+
const messageSigner2 = new MessageSigner(signer1);
|
|
279
|
+
await messageSigner2.initDomain('0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', 84532);
|
|
280
|
+
|
|
281
|
+
const isValid = await messageSigner2.verifySignature(message, signature);
|
|
282
|
+
|
|
283
|
+
// Should fail due to domain mismatch (prevents cross-contract replay)
|
|
284
|
+
expect(isValid).toBe(false);
|
|
285
|
+
});
|
|
286
|
+
});
|