@aztec/stdlib 1.0.0-nightly.20250605 → 1.0.0-nightly.20250607
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/dest/avm/avm.d.ts +304 -406
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm_accumulated_data.d.ts +0 -8
- package/dest/avm/avm_accumulated_data.d.ts.map +1 -1
- package/dest/avm/avm_circuit_public_inputs.d.ts +60 -90
- package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
- package/dest/avm/avm_proving_request.d.ts +184 -251
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/avm/message_pack.d.ts.map +1 -1
- package/dest/avm/message_pack.js +2 -1
- package/dest/block/l2_block_code_to_purge.js +1 -1
- package/dest/block/l2_block_source.d.ts +2 -0
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/config/node-rpc-config.d.ts +2 -0
- package/dest/config/node-rpc-config.d.ts.map +1 -1
- package/dest/config/node-rpc-config.js +5 -0
- package/dest/fees/transaction_fee.js +3 -3
- package/dest/gas/gas.js +1 -1
- package/dest/gas/gas_fees.d.ts +15 -14
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +17 -18
- package/dest/gas/gas_settings.d.ts +24 -24
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +1 -1
- package/dest/hash/hash.d.ts +2 -3
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +3 -4
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +1 -0
- package/dest/interfaces/proving-job.d.ts +184 -251
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/server_circuit_prover.d.ts +4 -0
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/service.d.ts +1 -2
- package/dest/interfaces/service.d.ts.map +1 -1
- package/dest/interfaces/service.js +0 -7
- package/dest/kernel/private_accumulated_data.d.ts +3 -3
- package/dest/kernel/private_accumulated_data.d.ts.map +1 -1
- package/dest/kernel/private_accumulated_data.js +3 -3
- package/dest/kernel/private_circuit_public_inputs.d.ts +4 -4
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +4 -4
- package/dest/kernel/private_to_avm_accumulated_data.d.ts +0 -8
- package/dest/kernel/private_to_avm_accumulated_data.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_message.d.ts +108 -16
- package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_message.js +76 -37
- package/dest/note/extended_note.d.ts +8 -8
- package/dest/note/extended_note.d.ts.map +1 -1
- package/dest/note/extended_note.js +9 -9
- package/dest/tests/factories.d.ts +1 -2
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +11 -8
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +2 -2
- package/dest/tx/global_variables.d.ts +12 -12
- package/dest/tx/global_variables.js +2 -2
- package/dest/tx/proposed_block_header.d.ts +2 -2
- package/dest/tx/proposed_block_header.js +1 -1
- package/dest/tx/tx_context.d.ts +32 -32
- package/dest/types/shared.d.ts +4 -0
- package/dest/types/shared.d.ts.map +1 -1
- package/dest/zkpassport/index.d.ts +31 -0
- package/dest/zkpassport/index.d.ts.map +1 -0
- package/dest/zkpassport/index.js +81 -0
- package/package.json +9 -8
- package/src/avm/message_pack.ts +1 -0
- package/src/block/l2_block_code_to_purge.ts +1 -1
- package/src/block/l2_block_source.ts +3 -0
- package/src/config/node-rpc-config.ts +7 -0
- package/src/fees/transaction_fee.ts +5 -5
- package/src/gas/gas.ts +1 -1
- package/src/gas/gas_fees.ts +27 -23
- package/src/gas/gas_settings.ts +1 -5
- package/src/hash/hash.ts +3 -4
- package/src/interfaces/archiver.ts +1 -0
- package/src/interfaces/server_circuit_prover.ts +5 -0
- package/src/interfaces/service.ts +1 -11
- package/src/kernel/private_accumulated_data.ts +4 -4
- package/src/kernel/private_circuit_public_inputs.ts +5 -5
- package/src/messaging/l2_to_l1_message.ts +88 -39
- package/src/note/extended_note.ts +8 -8
- package/src/tests/factories.ts +13 -9
- package/src/tests/mocks.ts +2 -2
- package/src/tx/global_variables.ts +2 -2
- package/src/tx/proposed_block_header.ts +1 -1
- package/src/types/shared.ts +5 -0
- package/src/zkpassport/index.ts +115 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { L2_TO_L1_MESSAGE_LENGTH, SCOPED_L2_TO_L1_MESSAGE_LENGTH } from '@aztec/constants';
|
|
2
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
3
|
import { schemas } from '@aztec/foundation/schemas';
|
|
5
4
|
import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
|
|
6
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
7
5
|
|
|
8
6
|
import { z } from 'zod';
|
|
9
7
|
|
|
@@ -13,7 +11,6 @@ export class L2ToL1Message {
|
|
|
13
11
|
constructor(
|
|
14
12
|
public recipient: EthAddress,
|
|
15
13
|
public content: Fr,
|
|
16
|
-
public counter: number,
|
|
17
14
|
) {}
|
|
18
15
|
|
|
19
16
|
static get schema() {
|
|
@@ -21,9 +18,8 @@ export class L2ToL1Message {
|
|
|
21
18
|
.object({
|
|
22
19
|
recipient: schemas.EthAddress,
|
|
23
20
|
content: schemas.Fr,
|
|
24
|
-
counter: z.number().int().nonnegative(),
|
|
25
21
|
})
|
|
26
|
-
.transform(({ recipient, content
|
|
22
|
+
.transform(({ recipient, content }) => new L2ToL1Message(recipient, content));
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
/**
|
|
@@ -31,7 +27,7 @@ export class L2ToL1Message {
|
|
|
31
27
|
* @returns An instance of L2ToL1Message with empty fields.
|
|
32
28
|
*/
|
|
33
29
|
static empty(): L2ToL1Message {
|
|
34
|
-
return new L2ToL1Message(EthAddress.ZERO, Fr.zero()
|
|
30
|
+
return new L2ToL1Message(EthAddress.ZERO, Fr.zero());
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
/**
|
|
@@ -40,9 +36,7 @@ export class L2ToL1Message {
|
|
|
40
36
|
* @returns True if both recipient and content are equal.
|
|
41
37
|
*/
|
|
42
38
|
equals(other: L2ToL1Message): boolean {
|
|
43
|
-
return (
|
|
44
|
-
this.recipient.equals(other.recipient) && this.content.equals(other.content) && this.counter === other.counter
|
|
45
|
-
);
|
|
39
|
+
return this.recipient.equals(other.recipient) && this.content.equals(other.content);
|
|
46
40
|
}
|
|
47
41
|
|
|
48
42
|
/**
|
|
@@ -50,7 +44,7 @@ export class L2ToL1Message {
|
|
|
50
44
|
* @returns The buffer.
|
|
51
45
|
*/
|
|
52
46
|
toBuffer(): Buffer {
|
|
53
|
-
return serializeToBuffer(this.recipient, this.content
|
|
47
|
+
return serializeToBuffer(this.recipient, this.content);
|
|
54
48
|
}
|
|
55
49
|
|
|
56
50
|
/**
|
|
@@ -58,13 +52,7 @@ export class L2ToL1Message {
|
|
|
58
52
|
* @returns An array of fields representing the serialized message.
|
|
59
53
|
*/
|
|
60
54
|
toFields(): Fr[] {
|
|
61
|
-
|
|
62
|
-
if (fields.length !== L2_TO_L1_MESSAGE_LENGTH) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Invalid number of fields for L2ToL1Message. Expected ${L2_TO_L1_MESSAGE_LENGTH}, got ${fields.length}`,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
return fields;
|
|
55
|
+
return [this.recipient.toField(), this.content];
|
|
68
56
|
}
|
|
69
57
|
|
|
70
58
|
/**
|
|
@@ -74,7 +62,7 @@ export class L2ToL1Message {
|
|
|
74
62
|
*/
|
|
75
63
|
static fromFields(fields: Fr[] | FieldReader): L2ToL1Message {
|
|
76
64
|
const reader = FieldReader.asReader(fields);
|
|
77
|
-
return new L2ToL1Message(reader.readObject(EthAddress), reader.readField()
|
|
65
|
+
return new L2ToL1Message(reader.readObject(EthAddress), reader.readField());
|
|
78
66
|
}
|
|
79
67
|
|
|
80
68
|
/**
|
|
@@ -84,7 +72,7 @@ export class L2ToL1Message {
|
|
|
84
72
|
*/
|
|
85
73
|
static fromBuffer(buffer: Buffer | BufferReader): L2ToL1Message {
|
|
86
74
|
const reader = BufferReader.asReader(buffer);
|
|
87
|
-
return new L2ToL1Message(reader.readObject(EthAddress), reader.readObject(Fr)
|
|
75
|
+
return new L2ToL1Message(reader.readObject(EthAddress), reader.readObject(Fr));
|
|
88
76
|
}
|
|
89
77
|
|
|
90
78
|
/**
|
|
@@ -92,14 +80,56 @@ export class L2ToL1Message {
|
|
|
92
80
|
* @returns True if both recipient and content are zero.
|
|
93
81
|
*/
|
|
94
82
|
isEmpty(): boolean {
|
|
95
|
-
return this.recipient.isZero() && this.content.isZero()
|
|
83
|
+
return this.recipient.isZero() && this.content.isZero();
|
|
96
84
|
}
|
|
97
85
|
|
|
98
|
-
scope(contractAddress: AztecAddress) {
|
|
86
|
+
scope(contractAddress: AztecAddress): ScopedL2ToL1Message {
|
|
99
87
|
return new ScopedL2ToL1Message(this, contractAddress);
|
|
100
88
|
}
|
|
101
89
|
}
|
|
102
90
|
|
|
91
|
+
export class CountedL2ToL1Message {
|
|
92
|
+
constructor(
|
|
93
|
+
public message: L2ToL1Message,
|
|
94
|
+
public counter: number,
|
|
95
|
+
) {}
|
|
96
|
+
|
|
97
|
+
static get schema() {
|
|
98
|
+
return z
|
|
99
|
+
.object({
|
|
100
|
+
message: L2ToL1Message.schema,
|
|
101
|
+
counter: z.number().int().nonnegative(),
|
|
102
|
+
})
|
|
103
|
+
.transform(({ message, counter }) => new CountedL2ToL1Message(message, counter));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static empty() {
|
|
107
|
+
return new CountedL2ToL1Message(L2ToL1Message.empty(), 0);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
isEmpty(): boolean {
|
|
111
|
+
return this.message.isEmpty() && !this.counter;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
115
|
+
const reader = BufferReader.asReader(buffer);
|
|
116
|
+
return new CountedL2ToL1Message(reader.readObject(L2ToL1Message), reader.readNumber());
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
toBuffer(): Buffer {
|
|
120
|
+
return serializeToBuffer(this.message, this.counter);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static fromFields(fields: Fr[] | FieldReader) {
|
|
124
|
+
const reader = FieldReader.asReader(fields);
|
|
125
|
+
return new CountedL2ToL1Message(reader.readObject(L2ToL1Message), reader.readU32());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
toFields(): Fr[] {
|
|
129
|
+
return serializeToFields(this.message, this.counter);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
103
133
|
export class ScopedL2ToL1Message {
|
|
104
134
|
constructor(
|
|
105
135
|
public message: L2ToL1Message,
|
|
@@ -115,20 +145,12 @@ export class ScopedL2ToL1Message {
|
|
|
115
145
|
.transform(({ message, contractAddress }) => new ScopedL2ToL1Message(message, contractAddress));
|
|
116
146
|
}
|
|
117
147
|
|
|
118
|
-
static getFields(fields: FieldsOf<ScopedL2ToL1Message>) {
|
|
119
|
-
return [fields.message, fields.contractAddress] as const;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
148
|
static empty() {
|
|
123
149
|
return new ScopedL2ToL1Message(L2ToL1Message.empty(), AztecAddress.ZERO);
|
|
124
150
|
}
|
|
125
151
|
|
|
126
|
-
|
|
127
|
-
return this.message.
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
toBuffer(): Buffer {
|
|
131
|
-
return serializeToBuffer(this.message, this.contractAddress);
|
|
152
|
+
isEmpty(): boolean {
|
|
153
|
+
return this.message.isEmpty() && this.contractAddress.isZero();
|
|
132
154
|
}
|
|
133
155
|
|
|
134
156
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
@@ -136,22 +158,49 @@ export class ScopedL2ToL1Message {
|
|
|
136
158
|
return new ScopedL2ToL1Message(reader.readObject(L2ToL1Message), reader.readObject(AztecAddress));
|
|
137
159
|
}
|
|
138
160
|
|
|
161
|
+
toBuffer(): Buffer {
|
|
162
|
+
return serializeToBuffer(this.message, this.contractAddress);
|
|
163
|
+
}
|
|
164
|
+
|
|
139
165
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
140
166
|
const reader = FieldReader.asReader(fields);
|
|
141
167
|
return new ScopedL2ToL1Message(reader.readObject(L2ToL1Message), reader.readObject(AztecAddress));
|
|
142
168
|
}
|
|
143
169
|
|
|
144
170
|
toFields(): Fr[] {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
171
|
+
return serializeToFields(this.message, this.contractAddress);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export class ScopedCountedL2ToL1Message {
|
|
176
|
+
constructor(
|
|
177
|
+
public inner: CountedL2ToL1Message,
|
|
178
|
+
public contractAddress: AztecAddress,
|
|
179
|
+
) {}
|
|
180
|
+
|
|
181
|
+
static get schema() {
|
|
182
|
+
return z
|
|
183
|
+
.object({
|
|
184
|
+
inner: CountedL2ToL1Message.schema,
|
|
185
|
+
contractAddress: AztecAddress.schema,
|
|
186
|
+
})
|
|
187
|
+
.transform(({ inner, contractAddress }) => new ScopedCountedL2ToL1Message(inner, contractAddress));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static empty() {
|
|
191
|
+
return new ScopedCountedL2ToL1Message(CountedL2ToL1Message.empty(), AztecAddress.ZERO);
|
|
152
192
|
}
|
|
153
193
|
|
|
154
194
|
isEmpty(): boolean {
|
|
155
|
-
return this.
|
|
195
|
+
return this.inner.isEmpty() && this.contractAddress.isZero();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
199
|
+
const reader = BufferReader.asReader(buffer);
|
|
200
|
+
return new ScopedCountedL2ToL1Message(reader.readObject(CountedL2ToL1Message), reader.readObject(AztecAddress));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
toBuffer(): Buffer {
|
|
204
|
+
return serializeToBuffer(this.inner, this.contractAddress);
|
|
156
205
|
}
|
|
157
206
|
}
|
|
@@ -87,8 +87,8 @@ export class UniqueNote extends ExtendedNote {
|
|
|
87
87
|
storageSlot: Fr,
|
|
88
88
|
/** The hash of the tx the note was created in. */
|
|
89
89
|
txHash: TxHash,
|
|
90
|
-
/** The nonce
|
|
91
|
-
public
|
|
90
|
+
/** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
|
|
91
|
+
public noteNonce: Fr,
|
|
92
92
|
) {
|
|
93
93
|
super(note, recipient, contractAddress, storageSlot, txHash);
|
|
94
94
|
}
|
|
@@ -101,10 +101,10 @@ export class UniqueNote extends ExtendedNote {
|
|
|
101
101
|
contractAddress: schemas.AztecAddress,
|
|
102
102
|
storageSlot: schemas.Fr,
|
|
103
103
|
txHash: TxHash.schema,
|
|
104
|
-
|
|
104
|
+
noteNonce: schemas.Fr,
|
|
105
105
|
})
|
|
106
|
-
.transform(({ note, recipient, contractAddress, storageSlot, txHash,
|
|
107
|
-
return new UniqueNote(note, recipient, contractAddress, storageSlot, txHash,
|
|
106
|
+
.transform(({ note, recipient, contractAddress, storageSlot, txHash, noteNonce }) => {
|
|
107
|
+
return new UniqueNote(note, recipient, contractAddress, storageSlot, txHash, noteNonce);
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -115,7 +115,7 @@ export class UniqueNote extends ExtendedNote {
|
|
|
115
115
|
this.contractAddress,
|
|
116
116
|
this.storageSlot,
|
|
117
117
|
this.txHash,
|
|
118
|
-
this.
|
|
118
|
+
this.noteNonce,
|
|
119
119
|
]);
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -138,9 +138,9 @@ export class UniqueNote extends ExtendedNote {
|
|
|
138
138
|
const contractAddress = reader.readObject(AztecAddress);
|
|
139
139
|
const storageSlot = reader.readObject(Fr);
|
|
140
140
|
const txHash = reader.readObject(TxHash);
|
|
141
|
-
const
|
|
141
|
+
const noteNonce = reader.readObject(Fr);
|
|
142
142
|
|
|
143
|
-
return new this(note, recipient, contractAddress, storageSlot, txHash,
|
|
143
|
+
return new this(note, recipient, contractAddress, storageSlot, txHash, noteNonce);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
static override fromString(str: string) {
|
package/src/tests/factories.ts
CHANGED
|
@@ -126,7 +126,7 @@ import { PublicKeys, computeAddress } from '../keys/index.js';
|
|
|
126
126
|
import { ContractClassLogFields } from '../logs/index.js';
|
|
127
127
|
import { PrivateLog } from '../logs/private_log.js';
|
|
128
128
|
import { PublicLog } from '../logs/public_log.js';
|
|
129
|
-
import { L2ToL1Message, ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
|
|
129
|
+
import { CountedL2ToL1Message, L2ToL1Message, ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
|
|
130
130
|
import { BaseParityInputs } from '../parity/base_parity_inputs.js';
|
|
131
131
|
import { ParityPublicInputs } from '../parity/parity_public_inputs.js';
|
|
132
132
|
import { RootParityInput } from '../parity/root_parity_input.js';
|
|
@@ -593,7 +593,7 @@ export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicIn
|
|
|
593
593
|
privateCallRequests: makeTuple(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, makePrivateCallRequest, seed + 0x600),
|
|
594
594
|
publicCallRequests: makeTuple(MAX_ENQUEUED_CALLS_PER_CALL, makeCountedPublicCallRequest, seed + 0x700),
|
|
595
595
|
publicTeardownCallRequest: makePublicCallRequest(seed + 0x800),
|
|
596
|
-
l2ToL1Msgs: makeTuple(MAX_L2_TO_L1_MSGS_PER_CALL,
|
|
596
|
+
l2ToL1Msgs: makeTuple(MAX_L2_TO_L1_MSGS_PER_CALL, makeCountedL2ToL1Message, seed + 0x800),
|
|
597
597
|
privateLogs: makeTuple(MAX_PRIVATE_LOGS_PER_CALL, makePrivateLogData, seed + 0x875),
|
|
598
598
|
contractClassLogsHashes: makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, makeCountedLogHash, seed + 0xa00),
|
|
599
599
|
startSideEffectCounter: fr(seed + 0x849),
|
|
@@ -613,13 +613,13 @@ export function makeGlobalVariables(seed = 1, overrides: Partial<FieldsOf<Global
|
|
|
613
613
|
timestamp: new Fr(seed + 4),
|
|
614
614
|
coinbase: EthAddress.fromField(new Fr(seed + 5)),
|
|
615
615
|
feeRecipient: AztecAddress.fromField(new Fr(seed + 6)),
|
|
616
|
-
gasFees: new GasFees(
|
|
616
|
+
gasFees: new GasFees(seed + 7, seed + 8),
|
|
617
617
|
...compact(overrides),
|
|
618
618
|
});
|
|
619
619
|
}
|
|
620
620
|
|
|
621
621
|
export function makeGasFees(seed = 1) {
|
|
622
|
-
return new GasFees(
|
|
622
|
+
return new GasFees(seed, seed + 1);
|
|
623
623
|
}
|
|
624
624
|
|
|
625
625
|
export function makeFeeRecipient(seed = 1) {
|
|
@@ -644,10 +644,6 @@ export function makeConstantRollupData(
|
|
|
644
644
|
});
|
|
645
645
|
}
|
|
646
646
|
|
|
647
|
-
export function makeScopedL2ToL1Message(seed = 1): ScopedL2ToL1Message {
|
|
648
|
-
return new ScopedL2ToL1Message(makeL2ToL1Message(seed), makeAztecAddress(seed + 3));
|
|
649
|
-
}
|
|
650
|
-
|
|
651
647
|
/**
|
|
652
648
|
* Makes arbitrary append only tree snapshot.
|
|
653
649
|
* @param seed - The seed to use for generating the append only tree snapshot.
|
|
@@ -969,7 +965,15 @@ export function makeL2ToL1Message(seed = 0): L2ToL1Message {
|
|
|
969
965
|
const recipient = EthAddress.fromField(new Fr(seed));
|
|
970
966
|
const content = new Fr(seed + 1);
|
|
971
967
|
|
|
972
|
-
return new L2ToL1Message(recipient, content
|
|
968
|
+
return new L2ToL1Message(recipient, content);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
function makeCountedL2ToL1Message(seed = 0) {
|
|
972
|
+
return new CountedL2ToL1Message(makeL2ToL1Message(seed), seed + 2);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
function makeScopedL2ToL1Message(seed = 1) {
|
|
976
|
+
return new ScopedL2ToL1Message(makeL2ToL1Message(seed), makeAztecAddress(seed + 3));
|
|
973
977
|
}
|
|
974
978
|
|
|
975
979
|
/**
|
package/src/tests/mocks.ts
CHANGED
|
@@ -67,7 +67,7 @@ export const randomUniqueNote = async ({
|
|
|
67
67
|
contractAddress = undefined,
|
|
68
68
|
txHash = randomTxHash(),
|
|
69
69
|
storageSlot = Fr.random(),
|
|
70
|
-
|
|
70
|
+
noteNonce = Fr.random(),
|
|
71
71
|
}: Partial<UniqueNote> = {}) => {
|
|
72
72
|
return new UniqueNote(
|
|
73
73
|
note,
|
|
@@ -75,7 +75,7 @@ export const randomUniqueNote = async ({
|
|
|
75
75
|
contractAddress ?? (await AztecAddress.random()),
|
|
76
76
|
storageSlot,
|
|
77
77
|
txHash,
|
|
78
|
-
|
|
78
|
+
noteNonce,
|
|
79
79
|
);
|
|
80
80
|
};
|
|
81
81
|
|
|
@@ -169,8 +169,8 @@ export class GlobalVariables {
|
|
|
169
169
|
timestamp: this.timestamp.toNumber(),
|
|
170
170
|
coinbase: this.coinbase.toString(),
|
|
171
171
|
feeRecipient: this.feeRecipient.toString(),
|
|
172
|
-
feePerDaGas: this.gasFees.feePerDaGas
|
|
173
|
-
feePerL2Gas: this.gasFees.feePerL2Gas
|
|
172
|
+
feePerDaGas: Number(this.gasFees.feePerDaGas),
|
|
173
|
+
feePerL2Gas: Number(this.gasFees.feePerL2Gas),
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -154,7 +154,7 @@ export class ProposedBlockHeader {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
[inspect.custom]() {
|
|
157
|
-
const gasfees = `da:${this.gasFees.feePerDaGas
|
|
157
|
+
const gasfees = `da:${this.gasFees.feePerDaGas}, l2:${this.gasFees.feePerL2Gas}`;
|
|
158
158
|
return `Header {
|
|
159
159
|
lastArchiveRoot: ${this.lastArchiveRoot.toString()},
|
|
160
160
|
contentCommitment: ${inspect(this.contentCommitment)},
|
package/src/types/shared.ts
CHANGED
|
@@ -30,6 +30,11 @@ export type UInt32 = number;
|
|
|
30
30
|
*/
|
|
31
31
|
export type UInt64 = bigint;
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* A type alias for a 128-bit unsigned integer.
|
|
35
|
+
*/
|
|
36
|
+
export type UInt128 = bigint;
|
|
37
|
+
|
|
33
38
|
/**
|
|
34
39
|
* CircuitType replaces ComposerType for now. When using Plonk, CircuitType is equivalent to the information of the proving system that will be used
|
|
35
40
|
* to construct a proof. In the future Aztec zk stack, more information must be specified (e.g., the curve over which circuits are constructed;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
|
+
import { withoutHexPrefix } from '@aztec/foundation/string';
|
|
6
|
+
|
|
7
|
+
export type ViemZkPassportProofParams = {
|
|
8
|
+
vkeyHash: `0x${string}`;
|
|
9
|
+
proof: `0x${string}`;
|
|
10
|
+
publicInputs: `0x${string}`[];
|
|
11
|
+
committedInputs: `0x${string}`;
|
|
12
|
+
committedInputCounts: bigint[];
|
|
13
|
+
validityPeriodInDays: bigint;
|
|
14
|
+
scope: string;
|
|
15
|
+
subscope: string;
|
|
16
|
+
devMode: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// NOTE: Must match the ZkPassportProofParams struct in the zkpassport verifier contract
|
|
20
|
+
// find here: ROOT/l1-contracts/lib/circuits/src/solidity/src/ZKPassportVerifier.sol
|
|
21
|
+
export class ZkPassportProofParams {
|
|
22
|
+
constructor(
|
|
23
|
+
public devMode: boolean,
|
|
24
|
+
public vkeyHash: Buffer32,
|
|
25
|
+
public proof: Buffer,
|
|
26
|
+
public publicInputs: Fr[],
|
|
27
|
+
public committedInputs: Buffer,
|
|
28
|
+
public committedInputCounts: bigint[],
|
|
29
|
+
public validityPeriodInDays: bigint,
|
|
30
|
+
public scope: string,
|
|
31
|
+
public subscope: string,
|
|
32
|
+
) {}
|
|
33
|
+
|
|
34
|
+
toBuffer() {
|
|
35
|
+
return serializeToBuffer([
|
|
36
|
+
this.devMode,
|
|
37
|
+
this.vkeyHash,
|
|
38
|
+
this.proof.length,
|
|
39
|
+
this.proof,
|
|
40
|
+
this.publicInputs.length,
|
|
41
|
+
this.publicInputs,
|
|
42
|
+
this.committedInputs.length,
|
|
43
|
+
this.committedInputs,
|
|
44
|
+
this.committedInputCounts.length,
|
|
45
|
+
this.committedInputCounts,
|
|
46
|
+
this.validityPeriodInDays,
|
|
47
|
+
this.scope,
|
|
48
|
+
this.subscope,
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static random() {
|
|
53
|
+
const committedInputCounts = [BigInt(1), BigInt(2), BigInt(3), BigInt(4)];
|
|
54
|
+
const numberOfCommittedInputs = committedInputCounts.reduce((acc, count) => acc + count, BigInt(0));
|
|
55
|
+
const committedInputs = randomBytes(Number(numberOfCommittedInputs) * 32);
|
|
56
|
+
|
|
57
|
+
const publicInputsCount = numberOfCommittedInputs + 16n;
|
|
58
|
+
const publicInputs = Array.from({ length: Number(publicInputsCount) }, () => Fr.random());
|
|
59
|
+
|
|
60
|
+
return new ZkPassportProofParams(
|
|
61
|
+
false,
|
|
62
|
+
Buffer32.random(),
|
|
63
|
+
randomBytes(1024),
|
|
64
|
+
publicInputs,
|
|
65
|
+
committedInputs,
|
|
66
|
+
committedInputCounts,
|
|
67
|
+
BigInt(100),
|
|
68
|
+
'sequencer.alpha-testnet.aztec.network',
|
|
69
|
+
'personhood',
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static fromBuffer(buffer: Buffer) {
|
|
74
|
+
const reader = BufferReader.asReader(buffer);
|
|
75
|
+
return new ZkPassportProofParams(
|
|
76
|
+
reader.readBoolean(),
|
|
77
|
+
reader.readObject(Buffer32),
|
|
78
|
+
reader.readBuffer(),
|
|
79
|
+
reader.readVector(Fr),
|
|
80
|
+
reader.readBuffer(),
|
|
81
|
+
reader.readUint256Vector(),
|
|
82
|
+
reader.readUInt256(),
|
|
83
|
+
reader.readString(),
|
|
84
|
+
reader.readString(),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static fromViem(params: ViemZkPassportProofParams) {
|
|
89
|
+
return new ZkPassportProofParams(
|
|
90
|
+
params.devMode,
|
|
91
|
+
Buffer32.fromString(params.vkeyHash),
|
|
92
|
+
Buffer.from(withoutHexPrefix(params.proof), 'hex'),
|
|
93
|
+
params.publicInputs.map(input => Fr.fromString(input)),
|
|
94
|
+
Buffer.from(withoutHexPrefix(params.committedInputs), 'hex'),
|
|
95
|
+
params.committedInputCounts,
|
|
96
|
+
params.validityPeriodInDays,
|
|
97
|
+
params.scope,
|
|
98
|
+
params.subscope,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
toViem(): ViemZkPassportProofParams {
|
|
103
|
+
return {
|
|
104
|
+
devMode: this.devMode,
|
|
105
|
+
vkeyHash: this.vkeyHash.toString(),
|
|
106
|
+
proof: `0x${this.proof.toString('hex')}`,
|
|
107
|
+
publicInputs: this.publicInputs.map(input => input.toString()),
|
|
108
|
+
committedInputs: `0x${this.committedInputs.toString('hex')}`,
|
|
109
|
+
committedInputCounts: this.committedInputCounts,
|
|
110
|
+
validityPeriodInDays: this.validityPeriodInDays,
|
|
111
|
+
scope: this.scope,
|
|
112
|
+
subscope: this.subscope,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|