@aztec/stdlib 3.0.0-nightly.20251016 → 3.0.0-nightly.20251022
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/block/attestation_info.d.ts +30 -0
- package/dest/block/attestation_info.d.ts.map +1 -0
- package/dest/block/attestation_info.js +39 -0
- package/dest/block/index.d.ts +1 -0
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -0
- package/dest/block/published_l2_block.d.ts +0 -2
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +0 -6
- package/dest/interfaces/aztec-node-admin.d.ts +3 -0
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +5 -0
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/p2p.d.ts +2 -0
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +2 -1
- package/dest/note/notes_filter.d.ts +0 -5
- package/dest/note/notes_filter.d.ts.map +1 -1
- package/dest/note/notes_filter.js +0 -3
- package/dest/p2p/block_attestation.d.ts +44 -3
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +36 -12
- package/dest/p2p/block_proposal.d.ts +2 -1
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +3 -2
- package/dest/tests/mocks.d.ts +3 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +31 -9
- package/dest/tx/tx.d.ts +6 -0
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +8 -0
- package/dest/zkpassport/index.d.ts +15 -9
- package/dest/zkpassport/index.d.ts.map +1 -1
- package/dest/zkpassport/index.js +17 -11
- package/package.json +9 -9
- package/src/block/attestation_info.ts +62 -0
- package/src/block/index.ts +1 -0
- package/src/block/published_l2_block.ts +0 -11
- package/src/interfaces/configs.ts +3 -0
- package/src/interfaces/p2p.ts +4 -0
- package/src/note/notes_filter.ts +0 -7
- package/src/p2p/block_attestation.ts +49 -10
- package/src/p2p/block_proposal.ts +4 -3
- package/src/tests/mocks.ts +51 -12
- package/src/tx/tx.ts +10 -0
- package/src/zkpassport/index.ts +40 -28
package/dest/tx/tx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../../src/tx/tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAyD,MAAM,6BAA6B,CAAC;AAClH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,oCAAoC,EAAE,MAAM,wDAAwD,CAAC;AAC9G,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,MAAM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E,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,GAAG,EAAE;IAUjF,oGAAoG;IACvF,aAAa;CAW3B;AAED;;GAEG;AACH,qBAAa,OAAQ,SAAQ,KAAK,CAAC,EAAE,CAAC;IACpC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO;IAWlD,QAAQ,IAAI,MAAM;CAG1B"}
|
package/dest/tx/tx.js
CHANGED
|
@@ -114,6 +114,14 @@ import { TxHash } from './tx_hash.js';
|
|
|
114
114
|
return new Tx(fields.txHash, fields.data, fields.clientIvcProof, fields.contractClassLogFields, fields.publicFunctionCalldata);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
+
* Validates that the tx hash matches the computed hash from the tx data.
|
|
118
|
+
* This should be called when deserializing a tx from an untrusted source.
|
|
119
|
+
* @returns true if the hash is valid, false otherwise
|
|
120
|
+
*/ async validateTxHash() {
|
|
121
|
+
const expectedHash = await Tx.computeTxHash(this);
|
|
122
|
+
return this.txHash.equals(expectedHash);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
117
125
|
* Gets public logs emitted by this tx.
|
|
118
126
|
* @param logsSource - An instance of `L2LogsSource` which can be used to obtain the logs.
|
|
119
127
|
* @returns The requested logs.
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
export type ViemZkPassportProofParams = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
proofVerificationData: {
|
|
5
|
+
vkeyHash: `0x${string}`;
|
|
6
|
+
proof: `0x${string}`;
|
|
7
|
+
publicInputs: `0x${string}`[];
|
|
8
|
+
};
|
|
9
|
+
commitments: {
|
|
10
|
+
committedInputs: `0x${string}`;
|
|
11
|
+
committedInputCounts: bigint[];
|
|
12
|
+
};
|
|
13
|
+
serviceConfig: {
|
|
14
|
+
validityPeriodInSeconds: bigint;
|
|
15
|
+
domain: string;
|
|
16
|
+
scope: string;
|
|
17
|
+
devMode: boolean;
|
|
18
|
+
};
|
|
13
19
|
};
|
|
14
20
|
export declare class ZkPassportProofParams {
|
|
15
21
|
devMode: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zkpassport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zkpassport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAI9C,MAAM,MAAM,yBAAyB,GAAG;IACtC,qBAAqB,EAAE;QACrB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;QACxB,KAAK,EAAE,KAAK,MAAM,EAAE,CAAC;QACrB,YAAY,EAAE,KAAK,MAAM,EAAE,EAAE,CAAC;KAC/B,CAAC;IACF,WAAW,EAAE;QACX,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;QAC/B,oBAAoB,EAAE,MAAM,EAAE,CAAC;KAChC,CAAC;IACF,aAAa,EAAE;QACb,uBAAuB,EAAE,MAAM,CAAC;QAChC,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH,CAAC;AAIF,qBAAa,qBAAqB;IAEvB,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,MAAM;IACb,YAAY,EAAE,EAAE,EAAE;IAClB,eAAe,EAAE,MAAM;IACvB,oBAAoB,EAAE,MAAM,EAAE;IAC9B,uBAAuB,EAAE,MAAM;IAC/B,MAAM,EAAE,MAAM;IACd,KAAK,EAAE,MAAM;gBARb,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,EAAE,EAAE,EAClB,eAAe,EAAE,MAAM,EACvB,oBAAoB,EAAE,MAAM,EAAE,EAC9B,uBAAuB,EAAE,MAAM,EAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM;IAGtB,QAAQ;IAkBR,MAAM,CAAC,MAAM;IAqBb,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM;IAehC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,yBAAyB;IAcjD,MAAM,IAAI,yBAAyB;CAmBpC"}
|
package/dest/zkpassport/index.js
CHANGED
|
@@ -56,26 +56,32 @@ export class ZkPassportProofParams {
|
|
|
56
56
|
const publicInputs = Array.from({
|
|
57
57
|
length: Number(publicInputsCount)
|
|
58
58
|
}, ()=>Fr.random());
|
|
59
|
-
return new ZkPassportProofParams(false, Buffer32.random(), randomBytes(1024), publicInputs, committedInputs, committedInputCounts, BigInt(
|
|
59
|
+
return new ZkPassportProofParams(false, Buffer32.random(), randomBytes(1024), publicInputs, committedInputs, committedInputCounts, BigInt(7 * 24 * 60 * 60), 'sequencer.alpha-testnet.aztec.network', 'personhood');
|
|
60
60
|
}
|
|
61
61
|
static fromBuffer(buffer) {
|
|
62
62
|
const reader = BufferReader.asReader(buffer);
|
|
63
63
|
return new ZkPassportProofParams(reader.readBoolean(), reader.readObject(Buffer32), reader.readBuffer(), reader.readVector(Fr), reader.readBuffer(), reader.readUint256Vector(), reader.readUInt256(), reader.readString(), reader.readString());
|
|
64
64
|
}
|
|
65
65
|
static fromViem(params) {
|
|
66
|
-
return new ZkPassportProofParams(params.devMode, Buffer32.fromString(params.vkeyHash), Buffer.from(withoutHexPrefix(params.proof), 'hex'), params.publicInputs.map((input)=>Fr.fromString(input)), Buffer.from(withoutHexPrefix(params.committedInputs), 'hex'), params.committedInputCounts, params.validityPeriodInSeconds, params.domain, params.scope);
|
|
66
|
+
return new ZkPassportProofParams(params.serviceConfig.devMode, Buffer32.fromString(params.proofVerificationData.vkeyHash), Buffer.from(withoutHexPrefix(params.proofVerificationData.proof), 'hex'), params.proofVerificationData.publicInputs.map((input)=>Fr.fromString(input)), Buffer.from(withoutHexPrefix(params.commitments.committedInputs), 'hex'), params.commitments.committedInputCounts, params.serviceConfig.validityPeriodInSeconds, params.serviceConfig.domain, params.serviceConfig.scope);
|
|
67
67
|
}
|
|
68
68
|
toViem() {
|
|
69
69
|
return {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
serviceConfig: {
|
|
71
|
+
devMode: this.devMode,
|
|
72
|
+
validityPeriodInSeconds: this.validityPeriodInSeconds,
|
|
73
|
+
domain: this.domain,
|
|
74
|
+
scope: this.scope
|
|
75
|
+
},
|
|
76
|
+
proofVerificationData: {
|
|
77
|
+
vkeyHash: this.vkeyHash.toString(),
|
|
78
|
+
proof: `0x${this.proof.toString('hex')}`,
|
|
79
|
+
publicInputs: this.publicInputs.map((input)=>input.toString())
|
|
80
|
+
},
|
|
81
|
+
commitments: {
|
|
82
|
+
committedInputs: `0x${this.committedInputs.toString('hex')}`,
|
|
83
|
+
committedInputCounts: this.committedInputCounts
|
|
84
|
+
}
|
|
79
85
|
};
|
|
80
86
|
}
|
|
81
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251022",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -70,13 +70,13 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
73
|
-
"@aztec/bb.js": "3.0.0-nightly.
|
|
74
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
75
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
76
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
77
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
78
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
79
|
-
"@aztec/noir-noirc_abi": "3.0.0-nightly.
|
|
73
|
+
"@aztec/bb.js": "3.0.0-nightly.20251022",
|
|
74
|
+
"@aztec/blob-lib": "3.0.0-nightly.20251022",
|
|
75
|
+
"@aztec/constants": "3.0.0-nightly.20251022",
|
|
76
|
+
"@aztec/ethereum": "3.0.0-nightly.20251022",
|
|
77
|
+
"@aztec/foundation": "3.0.0-nightly.20251022",
|
|
78
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251022",
|
|
79
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20251022",
|
|
80
80
|
"@google-cloud/storage": "^7.15.0",
|
|
81
81
|
"axios": "^1.12.0",
|
|
82
82
|
"json-stringify-deterministic": "1.0.12",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"msgpackr": "^1.11.2",
|
|
88
88
|
"pako": "^2.1.0",
|
|
89
89
|
"tslib": "^2.4.0",
|
|
90
|
-
"viem": "2.
|
|
90
|
+
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0",
|
|
91
91
|
"zod": "^3.23.8"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { recoverAddress } from '@aztec/foundation/crypto';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
|
|
4
|
+
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
5
|
+
import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '../p2p/signature_utils.js';
|
|
6
|
+
import type { L2Block } from './l2_block.js';
|
|
7
|
+
import type { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Status indicating how the attestation address was determined
|
|
11
|
+
*/
|
|
12
|
+
export type AttestationStatus = 'recovered-from-signature' | 'provided-as-address' | 'invalid-signature' | 'empty';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Information about an attestation extracted from a published block
|
|
16
|
+
*/
|
|
17
|
+
export type AttestationInfo =
|
|
18
|
+
| {
|
|
19
|
+
/** The validator's address, undefined if signature recovery failed or empty */
|
|
20
|
+
address?: undefined;
|
|
21
|
+
/** How the attestation address was determined */
|
|
22
|
+
status: Extract<AttestationStatus, 'invalid-signature' | 'empty'>;
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
/** The validator's address */
|
|
26
|
+
address: EthAddress;
|
|
27
|
+
/** How the attestation address was determined */
|
|
28
|
+
status: Extract<AttestationStatus, 'provided-as-address' | 'recovered-from-signature'>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Extracts attestation information from a published L2 block.
|
|
33
|
+
* Returns info for each attestation, preserving array indices.
|
|
34
|
+
*/
|
|
35
|
+
export function getAttestationInfoFromPublishedL2Block(block: {
|
|
36
|
+
attestations: CommitteeAttestation[];
|
|
37
|
+
block: L2Block;
|
|
38
|
+
}): AttestationInfo[] {
|
|
39
|
+
const payload = ConsensusPayload.fromBlock(block.block);
|
|
40
|
+
const hashedPayload = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
41
|
+
|
|
42
|
+
return block.attestations.map(attestation => {
|
|
43
|
+
// If signature is empty, check if we have an address directly
|
|
44
|
+
if (attestation.signature.isEmpty()) {
|
|
45
|
+
if (attestation.address.isZero()) {
|
|
46
|
+
// No signature and no address - empty
|
|
47
|
+
return { status: 'empty' as const };
|
|
48
|
+
}
|
|
49
|
+
// Address provided without signature
|
|
50
|
+
return { address: attestation.address, status: 'provided-as-address' as const };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Try to recover address from signature
|
|
54
|
+
try {
|
|
55
|
+
const recoveredAddress = recoverAddress(hashedPayload, attestation.signature);
|
|
56
|
+
return { address: recoveredAddress, status: 'recovered-from-signature' as const };
|
|
57
|
+
} catch {
|
|
58
|
+
// Signature present but recovery failed
|
|
59
|
+
return { status: 'invalid-signature' as const };
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
package/src/block/index.ts
CHANGED
|
@@ -7,8 +7,6 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
7
7
|
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
|
|
10
|
-
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
11
|
-
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
12
10
|
import { L2Block } from './l2_block.js';
|
|
13
11
|
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
14
12
|
|
|
@@ -82,12 +80,3 @@ export class PublishedL2Block {
|
|
|
82
80
|
);
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
|
-
|
|
86
|
-
export function getAttestationsFromPublishedL2Block(
|
|
87
|
-
block: Pick<PublishedL2Block, 'attestations' | 'block'>,
|
|
88
|
-
): BlockAttestation[] {
|
|
89
|
-
const payload = ConsensusPayload.fromBlock(block.block);
|
|
90
|
-
return block.attestations
|
|
91
|
-
.filter(attestation => !attestation.signature.isEmpty())
|
|
92
|
-
.map(attestation => new BlockAttestation(block.block.number, payload, attestation.signature));
|
|
93
|
-
}
|
|
@@ -54,6 +54,8 @@ export interface SequencerConfig {
|
|
|
54
54
|
skipInvalidateBlockAsProposer?: boolean;
|
|
55
55
|
/** Broadcast invalid block proposals with corrupted state (for testing only) */
|
|
56
56
|
broadcastInvalidBlockProposal?: boolean;
|
|
57
|
+
/** Inject a fake attestation (for testing only) */
|
|
58
|
+
injectFakeAttestation?: boolean;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
export const SequencerConfigSchema = z.object({
|
|
@@ -78,4 +80,5 @@ export const SequencerConfigSchema = z.object({
|
|
|
78
80
|
secondsBeforeInvalidatingBlockAsCommitteeMember: z.number(),
|
|
79
81
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.number(),
|
|
80
82
|
broadcastInvalidBlockProposal: z.boolean().optional(),
|
|
83
|
+
injectFakeAttestation: z.boolean().optional(),
|
|
81
84
|
}) satisfies ZodFor<SequencerConfig>;
|
package/src/interfaces/p2p.ts
CHANGED
|
@@ -57,6 +57,9 @@ export interface P2PApiWithAttestations extends P2PApiWithoutAttestations {
|
|
|
57
57
|
* @returns BlockAttestations
|
|
58
58
|
*/
|
|
59
59
|
getAttestationsForSlot(slot: bigint, proposalId?: string): Promise<BlockAttestation[]>;
|
|
60
|
+
|
|
61
|
+
/** Deletes a given attestation manually from the p2p client attestation pool. */
|
|
62
|
+
deleteAttestation(attestation: BlockAttestation): Promise<void>;
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
export interface P2PClient extends P2PApiWithAttestations {
|
|
@@ -85,4 +88,5 @@ export const P2PApiSchema: ApiSchemaFor<P2PApi> = {
|
|
|
85
88
|
getPendingTxCount: z.function().returns(schemas.Integer),
|
|
86
89
|
getEncodedEnr: z.function().returns(z.string().optional()),
|
|
87
90
|
getPeers: z.function().args(optional(z.boolean())).returns(z.array(PeerInfoSchema)),
|
|
91
|
+
deleteAttestation: z.function().args(BlockAttestation.schema).returns(z.void()),
|
|
88
92
|
};
|
package/src/note/notes_filter.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { z } from 'zod';
|
|
|
4
4
|
|
|
5
5
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
6
6
|
import { type ZodFor, schemas } from '../schemas/index.js';
|
|
7
|
-
import { TxHash } from '../tx/tx_hash.js';
|
|
8
7
|
import { NoteStatus } from './note_status.js';
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -17,12 +16,8 @@ export type NotesFilter = {
|
|
|
17
16
|
* @remarks Providing a contract address is required as we need that information to trigger private state sync.
|
|
18
17
|
*/
|
|
19
18
|
contractAddress: AztecAddress;
|
|
20
|
-
/** Hash of a transaction from which to fetch the notes. */
|
|
21
|
-
txHash?: TxHash;
|
|
22
19
|
/** The specific storage location of the note on the contract. */
|
|
23
20
|
storageSlot?: Fr;
|
|
24
|
-
/** The recipient of the note (whose public key was used to encrypt the note). */
|
|
25
|
-
recipient?: AztecAddress;
|
|
26
21
|
/** The status of the note. Defaults to 'ACTIVE'. */
|
|
27
22
|
status?: NoteStatus;
|
|
28
23
|
/** The siloed nullifier for the note. */
|
|
@@ -33,9 +28,7 @@ export type NotesFilter = {
|
|
|
33
28
|
|
|
34
29
|
export const NotesFilterSchema: ZodFor<NotesFilter> = z.object({
|
|
35
30
|
contractAddress: schemas.AztecAddress,
|
|
36
|
-
txHash: TxHash.schema.optional(),
|
|
37
31
|
storageSlot: schemas.Fr.optional(),
|
|
38
|
-
recipient: schemas.AztecAddress.optional(),
|
|
39
32
|
status: z.nativeEnum(NoteStatus).optional(),
|
|
40
33
|
siloedNullifier: schemas.Fr.optional(),
|
|
41
34
|
scopes: z.array(schemas.AztecAddress).optional(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { keccak256,
|
|
2
|
+
import { keccak256, tryRecoverAddress } from '@aztec/foundation/crypto';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -30,6 +30,7 @@ export class BlockAttestation extends Gossipable {
|
|
|
30
30
|
static override p2pTopic = TopicType.block_attestation;
|
|
31
31
|
|
|
32
32
|
private sender: EthAddress | undefined;
|
|
33
|
+
private proposer: EthAddress | undefined;
|
|
33
34
|
|
|
34
35
|
constructor(
|
|
35
36
|
/** The block number of the attestation. */
|
|
@@ -40,6 +41,9 @@ export class BlockAttestation extends Gossipable {
|
|
|
40
41
|
|
|
41
42
|
/** The signature of the block attester */
|
|
42
43
|
public readonly signature: Signature,
|
|
44
|
+
|
|
45
|
+
/** The signature from the block proposer */
|
|
46
|
+
public readonly proposerSignature: Signature,
|
|
43
47
|
) {
|
|
44
48
|
super();
|
|
45
49
|
}
|
|
@@ -50,8 +54,9 @@ export class BlockAttestation extends Gossipable {
|
|
|
50
54
|
blockNumber: schemas.UInt32,
|
|
51
55
|
payload: ConsensusPayload.schema,
|
|
52
56
|
signature: Signature.schema,
|
|
57
|
+
proposerSignature: Signature.schema,
|
|
53
58
|
})
|
|
54
|
-
.transform(obj => new BlockAttestation(obj.blockNumber, obj.payload, obj.signature));
|
|
59
|
+
.transform(obj => new BlockAttestation(obj.blockNumber, obj.payload, obj.signature, obj.proposerSignature));
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
override generateP2PMessageIdentifier(): Promise<Buffer32> {
|
|
@@ -68,41 +73,75 @@ export class BlockAttestation extends Gossipable {
|
|
|
68
73
|
|
|
69
74
|
/**
|
|
70
75
|
* Lazily evaluate and cache the signer of the attestation
|
|
71
|
-
* @returns The signer of the attestation
|
|
76
|
+
* @returns The signer of the attestation, or undefined if signature recovery fails
|
|
72
77
|
*/
|
|
73
|
-
getSender(): EthAddress {
|
|
78
|
+
getSender(): EthAddress | undefined {
|
|
74
79
|
if (!this.sender) {
|
|
75
80
|
// Recover the sender from the attestation
|
|
76
81
|
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockAttestation);
|
|
77
82
|
// Cache the sender for later use
|
|
78
|
-
this.sender =
|
|
83
|
+
this.sender = tryRecoverAddress(hashed, this.signature);
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
return this.sender;
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Lazily evaluate and cache the proposer of the block
|
|
91
|
+
* @returns The proposer of the block
|
|
92
|
+
*/
|
|
93
|
+
getProposer(): EthAddress {
|
|
94
|
+
if (!this.proposer) {
|
|
95
|
+
// Recover the proposer from the proposal signature
|
|
96
|
+
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
|
|
97
|
+
// Cache the proposer for later use
|
|
98
|
+
this.proposer = tryRecoverAddress(hashed, this.proposerSignature)!;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this.proposer;
|
|
102
|
+
}
|
|
103
|
+
|
|
84
104
|
getPayload(): Buffer {
|
|
85
105
|
return this.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation);
|
|
86
106
|
}
|
|
87
107
|
|
|
88
108
|
toBuffer(): Buffer {
|
|
89
|
-
return serializeToBuffer([this.blockNumber, this.payload, this.signature]);
|
|
109
|
+
return serializeToBuffer([this.blockNumber, this.payload, this.signature, this.proposerSignature]);
|
|
90
110
|
}
|
|
91
111
|
|
|
92
112
|
static fromBuffer(buf: Buffer | BufferReader): BlockAttestation {
|
|
93
113
|
const reader = BufferReader.asReader(buf);
|
|
94
|
-
return new BlockAttestation(
|
|
114
|
+
return new BlockAttestation(
|
|
115
|
+
reader.readNumber(),
|
|
116
|
+
reader.readObject(ConsensusPayload),
|
|
117
|
+
reader.readObject(Signature),
|
|
118
|
+
reader.readObject(Signature),
|
|
119
|
+
);
|
|
95
120
|
}
|
|
96
121
|
|
|
97
122
|
static empty(): BlockAttestation {
|
|
98
|
-
return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty());
|
|
123
|
+
return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty(), Signature.empty());
|
|
99
124
|
}
|
|
100
125
|
|
|
101
126
|
static random(): BlockAttestation {
|
|
102
|
-
return new BlockAttestation(
|
|
127
|
+
return new BlockAttestation(
|
|
128
|
+
Math.floor(Math.random() * 1000) + 1,
|
|
129
|
+
ConsensusPayload.random(),
|
|
130
|
+
Signature.random(),
|
|
131
|
+
Signature.random(),
|
|
132
|
+
);
|
|
103
133
|
}
|
|
104
134
|
|
|
105
135
|
getSize(): number {
|
|
106
|
-
return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize();
|
|
136
|
+
return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize() + this.proposerSignature.getSize();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
toInspect() {
|
|
140
|
+
return {
|
|
141
|
+
blockNumber: this.blockNumber,
|
|
142
|
+
payload: this.payload.toInspect(),
|
|
143
|
+
signature: this.signature.toString(),
|
|
144
|
+
proposerSignature: this.proposerSignature.toString(),
|
|
145
|
+
};
|
|
107
146
|
}
|
|
108
147
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { keccak256,
|
|
2
|
+
import { keccak256, tryRecoverAddress } from '@aztec/foundation/crypto';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -100,12 +100,13 @@ export class BlockProposal extends Gossipable {
|
|
|
100
100
|
|
|
101
101
|
/**Get Sender
|
|
102
102
|
* Lazily evaluate the sender of the proposal; result is cached
|
|
103
|
+
* @returns The sender address, or undefined if signature recovery fails
|
|
103
104
|
*/
|
|
104
|
-
getSender() {
|
|
105
|
+
getSender(): EthAddress | undefined {
|
|
105
106
|
if (!this.sender) {
|
|
106
107
|
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
|
|
107
108
|
// Cache the sender for later use
|
|
108
|
-
this.sender =
|
|
109
|
+
this.sender = tryRecoverAddress(hashed, this.signature);
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
return this.sender;
|
package/src/tests/mocks.ts
CHANGED
|
@@ -246,6 +246,8 @@ export const randomDeployedContract = async () => {
|
|
|
246
246
|
|
|
247
247
|
export interface MakeConsensusPayloadOptions {
|
|
248
248
|
signer?: Secp256k1Signer;
|
|
249
|
+
attesterSigner?: Secp256k1Signer;
|
|
250
|
+
proposerSigner?: Secp256k1Signer;
|
|
249
251
|
header?: L2BlockHeader;
|
|
250
252
|
archive?: Fr;
|
|
251
253
|
stateReference?: StateReference;
|
|
@@ -294,21 +296,58 @@ export const makeBlockProposal = (options?: MakeConsensusPayloadOptions): BlockP
|
|
|
294
296
|
|
|
295
297
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028)
|
|
296
298
|
export const makeBlockAttestation = (options?: MakeConsensusPayloadOptions): BlockAttestation => {
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
const header = options?.header ?? makeL2BlockHeader(1);
|
|
300
|
+
const {
|
|
301
|
+
signer,
|
|
302
|
+
attesterSigner = signer ?? Secp256k1Signer.random(),
|
|
303
|
+
proposerSigner = signer ?? Secp256k1Signer.random(),
|
|
304
|
+
archive = Fr.random(),
|
|
305
|
+
stateReference = header.state,
|
|
306
|
+
} = options ?? {};
|
|
307
|
+
|
|
308
|
+
const payload = ConsensusPayload.fromFields({
|
|
309
|
+
header: header.toCheckpointHeader(),
|
|
310
|
+
archive,
|
|
311
|
+
stateReference,
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Sign as attester
|
|
315
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
316
|
+
const attestationSignature = attesterSigner.sign(attestationHash);
|
|
317
|
+
|
|
318
|
+
// Sign as proposer
|
|
319
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
320
|
+
const proposerSignature = proposerSigner.sign(proposalHash);
|
|
321
|
+
|
|
322
|
+
return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
302
323
|
};
|
|
303
324
|
|
|
304
|
-
export const makeBlockAttestationFromBlock = (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
325
|
+
export const makeBlockAttestationFromBlock = (
|
|
326
|
+
block: L2Block,
|
|
327
|
+
attesterSigner?: Secp256k1Signer,
|
|
328
|
+
proposerSigner?: Secp256k1Signer,
|
|
329
|
+
): BlockAttestation => {
|
|
330
|
+
const header = block.header;
|
|
331
|
+
const archive = block.archive.root;
|
|
332
|
+
const stateReference = block.header.state;
|
|
333
|
+
|
|
334
|
+
const payload = ConsensusPayload.fromFields({
|
|
335
|
+
header: header.toCheckpointHeader(),
|
|
336
|
+
archive,
|
|
337
|
+
stateReference,
|
|
311
338
|
});
|
|
339
|
+
|
|
340
|
+
// Sign as attester
|
|
341
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
342
|
+
const attestationSigner = attesterSigner ?? Secp256k1Signer.random();
|
|
343
|
+
const attestationSignature = attestationSigner.sign(attestationHash);
|
|
344
|
+
|
|
345
|
+
// Sign as proposer
|
|
346
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
347
|
+
const proposalSignerToUse = proposerSigner ?? Secp256k1Signer.random();
|
|
348
|
+
const proposerSignature = proposalSignerToUse.sign(proposalHash);
|
|
349
|
+
|
|
350
|
+
return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
312
351
|
};
|
|
313
352
|
|
|
314
353
|
export async function randomPublishedL2Block(
|
package/src/tx/tx.ts
CHANGED
|
@@ -161,6 +161,16 @@ export class Tx extends Gossipable {
|
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Validates that the tx hash matches the computed hash from the tx data.
|
|
166
|
+
* This should be called when deserializing a tx from an untrusted source.
|
|
167
|
+
* @returns true if the hash is valid, false otherwise
|
|
168
|
+
*/
|
|
169
|
+
async validateTxHash(): Promise<boolean> {
|
|
170
|
+
const expectedHash = await Tx.computeTxHash(this);
|
|
171
|
+
return this.txHash.equals(expectedHash);
|
|
172
|
+
}
|
|
173
|
+
|
|
164
174
|
/**
|
|
165
175
|
* Gets public logs emitted by this tx.
|
|
166
176
|
* @param logsSource - An instance of `L2LogsSource` which can be used to obtain the logs.
|
package/src/zkpassport/index.ts
CHANGED
|
@@ -5,15 +5,21 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
|
5
5
|
import { withoutHexPrefix } from '@aztec/foundation/string';
|
|
6
6
|
|
|
7
7
|
export type ViemZkPassportProofParams = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
proofVerificationData: {
|
|
9
|
+
vkeyHash: `0x${string}`;
|
|
10
|
+
proof: `0x${string}`;
|
|
11
|
+
publicInputs: `0x${string}`[];
|
|
12
|
+
};
|
|
13
|
+
commitments: {
|
|
14
|
+
committedInputs: `0x${string}`;
|
|
15
|
+
committedInputCounts: bigint[];
|
|
16
|
+
};
|
|
17
|
+
serviceConfig: {
|
|
18
|
+
validityPeriodInSeconds: bigint;
|
|
19
|
+
domain: string;
|
|
20
|
+
scope: string;
|
|
21
|
+
devMode: boolean;
|
|
22
|
+
};
|
|
17
23
|
};
|
|
18
24
|
|
|
19
25
|
// NOTE: Must match the ZkPassportProofParams struct in the zkpassport verifier contract
|
|
@@ -64,7 +70,7 @@ export class ZkPassportProofParams {
|
|
|
64
70
|
publicInputs,
|
|
65
71
|
committedInputs,
|
|
66
72
|
committedInputCounts,
|
|
67
|
-
BigInt(
|
|
73
|
+
BigInt(7 * 24 * 60 * 60), // 7 days
|
|
68
74
|
'sequencer.alpha-testnet.aztec.network',
|
|
69
75
|
'personhood',
|
|
70
76
|
);
|
|
@@ -87,29 +93,35 @@ export class ZkPassportProofParams {
|
|
|
87
93
|
|
|
88
94
|
static fromViem(params: ViemZkPassportProofParams) {
|
|
89
95
|
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.validityPeriodInSeconds,
|
|
97
|
-
params.domain,
|
|
98
|
-
params.scope,
|
|
96
|
+
params.serviceConfig.devMode,
|
|
97
|
+
Buffer32.fromString(params.proofVerificationData.vkeyHash),
|
|
98
|
+
Buffer.from(withoutHexPrefix(params.proofVerificationData.proof), 'hex'),
|
|
99
|
+
params.proofVerificationData.publicInputs.map(input => Fr.fromString(input)),
|
|
100
|
+
Buffer.from(withoutHexPrefix(params.commitments.committedInputs), 'hex'),
|
|
101
|
+
params.commitments.committedInputCounts,
|
|
102
|
+
params.serviceConfig.validityPeriodInSeconds,
|
|
103
|
+
params.serviceConfig.domain,
|
|
104
|
+
params.serviceConfig.scope,
|
|
99
105
|
);
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
toViem(): ViemZkPassportProofParams {
|
|
103
109
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
serviceConfig: {
|
|
111
|
+
devMode: this.devMode,
|
|
112
|
+
validityPeriodInSeconds: this.validityPeriodInSeconds,
|
|
113
|
+
domain: this.domain,
|
|
114
|
+
scope: this.scope,
|
|
115
|
+
},
|
|
116
|
+
proofVerificationData: {
|
|
117
|
+
vkeyHash: this.vkeyHash.toString(),
|
|
118
|
+
proof: `0x${this.proof.toString('hex')}`,
|
|
119
|
+
publicInputs: this.publicInputs.map(input => input.toString()),
|
|
120
|
+
},
|
|
121
|
+
commitments: {
|
|
122
|
+
committedInputs: `0x${this.committedInputs.toString('hex')}`,
|
|
123
|
+
committedInputCounts: this.committedInputCounts,
|
|
124
|
+
},
|
|
113
125
|
};
|
|
114
126
|
}
|
|
115
127
|
}
|