@aztec/stdlib 2.0.3-rc.19 → 2.0.3-rc.20

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.
@@ -0,0 +1,48 @@
1
+ import type { ViemCommitteeAttestations } from '@aztec/ethereum';
2
+ import { z } from 'zod';
3
+ import type { Signable, SignatureDomainSeparator } from '../../p2p/signature_utils.js';
4
+ import { CommitteeAttestation } from './committee_attestation.js';
5
+ export declare class CommitteeAttestationsAndSigners implements Signable {
6
+ attestations: CommitteeAttestation[];
7
+ constructor(attestations: CommitteeAttestation[]);
8
+ static get schema(): z.ZodEffects<z.ZodObject<{
9
+ attestations: z.ZodArray<z.ZodEffects<z.ZodObject<{
10
+ address: z.ZodType<import("./committee_attestation.js").EthAddress, any, string>;
11
+ signature: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>, import("./committee_attestation.js").Signature, string>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ address: import("./committee_attestation.js").EthAddress;
14
+ signature: import("./committee_attestation.js").Signature;
15
+ }, {
16
+ address: string;
17
+ signature: string;
18
+ }>, CommitteeAttestation, {
19
+ address: string;
20
+ signature: string;
21
+ }>, "many">;
22
+ }, "strip", z.ZodTypeAny, {
23
+ attestations: CommitteeAttestation[];
24
+ }, {
25
+ attestations: {
26
+ address: string;
27
+ signature: string;
28
+ }[];
29
+ }>, CommitteeAttestationsAndSigners, {
30
+ attestations: {
31
+ address: string;
32
+ signature: string;
33
+ }[];
34
+ }>;
35
+ getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer;
36
+ static empty(): CommitteeAttestationsAndSigners;
37
+ toString(): string;
38
+ getSigners(): import("./committee_attestation.js").EthAddress[];
39
+ getSignedAttestations(): CommitteeAttestation[];
40
+ /**
41
+ * Packs an array of committee attestations into the format expected by the Solidity contract
42
+ *
43
+ * @param attestations - Array of committee attestations with addresses and signatures
44
+ * @returns Packed attestations with bitmap and tightly packed signature/address data
45
+ */
46
+ getPackedAttestations(): ViemCommitteeAttestations;
47
+ }
48
+ //# sourceMappingURL=attestations_and_signers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attestations_and_signers.d.ts","sourceRoot":"","sources":["../../../src/block/proposal/attestations_and_signers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAIjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,qBAAa,+BAAgC,YAAW,QAAQ;IAC3C,YAAY,EAAE,oBAAoB,EAAE;gBAApC,YAAY,EAAE,oBAAoB,EAAE;IAEvD,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;OAMhB;IAED,gBAAgB,CAAC,eAAe,EAAE,wBAAwB,GAAG,MAAM;IAanE,MAAM,CAAC,KAAK,IAAI,+BAA+B;IAI/C,QAAQ;IAIR,UAAU;IAIV,qBAAqB;IAIrB;;;;;OAKG;IACH,qBAAqB,IAAI,yBAAyB;CAiEnD"}
@@ -0,0 +1,99 @@
1
+ import { hexToBuffer } from '@aztec/foundation/string';
2
+ import { encodeAbiParameters, parseAbiParameters } from 'viem';
3
+ import { z } from 'zod';
4
+ import { CommitteeAttestation } from './committee_attestation.js';
5
+ export class CommitteeAttestationsAndSigners {
6
+ attestations;
7
+ constructor(attestations){
8
+ this.attestations = attestations;
9
+ }
10
+ static get schema() {
11
+ return z.object({
12
+ attestations: CommitteeAttestation.schema.array()
13
+ }).transform((obj)=>new CommitteeAttestationsAndSigners(obj.attestations));
14
+ }
15
+ getPayloadToSign(domainSeparator) {
16
+ const abi = parseAbiParameters('uint8,(bytes,bytes),address[]');
17
+ const packed = this.getPackedAttestations();
18
+ const encodedData = encodeAbiParameters(abi, [
19
+ domainSeparator,
20
+ [
21
+ packed.signatureIndices,
22
+ packed.signaturesOrAddresses
23
+ ],
24
+ this.getSigners().map((s)=>s.toString())
25
+ ]);
26
+ return hexToBuffer(encodedData);
27
+ }
28
+ static empty() {
29
+ return new CommitteeAttestationsAndSigners([]);
30
+ }
31
+ toString() {
32
+ return `CommitteeAttestationsAndSigners(${this.attestations.map((a)=>a.toString()).join(',')})`;
33
+ }
34
+ getSigners() {
35
+ return this.attestations.filter((a)=>!a.signature.isEmpty()).map((a)=>a.address);
36
+ }
37
+ getSignedAttestations() {
38
+ return this.attestations.filter((a)=>!a.signature.isEmpty());
39
+ }
40
+ /**
41
+ * Packs an array of committee attestations into the format expected by the Solidity contract
42
+ *
43
+ * @param attestations - Array of committee attestations with addresses and signatures
44
+ * @returns Packed attestations with bitmap and tightly packed signature/address data
45
+ */ getPackedAttestations() {
46
+ const length = this.attestations.length;
47
+ const attestations = this.attestations.map((a)=>a.toViem());
48
+ // Calculate bitmap size (1 bit per attestation, rounded up to nearest byte)
49
+ const bitmapSize = Math.ceil(length / 8);
50
+ const signatureIndices = new Uint8Array(bitmapSize);
51
+ // Calculate total data size needed
52
+ let totalDataSize = 0;
53
+ for(let i = 0; i < length; i++){
54
+ const signature = attestations[i].signature;
55
+ // Check if signature is empty (v = 0)
56
+ const isEmpty = signature.v === 0;
57
+ if (!isEmpty) {
58
+ totalDataSize += 65; // v (1) + r (32) + s (32)
59
+ } else {
60
+ totalDataSize += 20; // address only
61
+ }
62
+ }
63
+ const signaturesOrAddresses = new Uint8Array(totalDataSize);
64
+ let dataIndex = 0;
65
+ // Pack the data
66
+ for(let i = 0; i < length; i++){
67
+ const attestation = attestations[i];
68
+ const signature = attestation.signature;
69
+ // Check if signature is empty
70
+ const isEmpty = signature.v === 0;
71
+ if (!isEmpty) {
72
+ // Set bit in bitmap (bit 7-0 in each byte, left to right)
73
+ const byteIndex = Math.floor(i / 8);
74
+ const bitIndex = 7 - i % 8;
75
+ signatureIndices[byteIndex] |= 1 << bitIndex;
76
+ // Pack signature: v + r + s
77
+ signaturesOrAddresses[dataIndex] = signature.v;
78
+ dataIndex++;
79
+ // Pack r (32 bytes)
80
+ const rBytes = Buffer.from(signature.r.slice(2), 'hex');
81
+ signaturesOrAddresses.set(rBytes, dataIndex);
82
+ dataIndex += 32;
83
+ // Pack s (32 bytes)
84
+ const sBytes = Buffer.from(signature.s.slice(2), 'hex');
85
+ signaturesOrAddresses.set(sBytes, dataIndex);
86
+ dataIndex += 32;
87
+ } else {
88
+ // Pack address only (20 bytes)
89
+ const addrBytes = Buffer.from(attestation.addr.slice(2), 'hex');
90
+ signaturesOrAddresses.set(addrBytes, dataIndex);
91
+ dataIndex += 20;
92
+ }
93
+ }
94
+ return {
95
+ signatureIndices: `0x${Buffer.from(signatureIndices).toString('hex')}`,
96
+ signaturesOrAddresses: `0x${Buffer.from(signaturesOrAddresses).toString('hex')}`
97
+ };
98
+ }
99
+ }
@@ -31,6 +31,7 @@ export declare class CommitteeAttestation {
31
31
  static fromPacked(packed: ViemCommitteeAttestations, committeeSize: number): CommitteeAttestation[];
32
32
  toBuffer(): Buffer;
33
33
  equals(other: CommitteeAttestation): boolean;
34
+ toString(): string;
34
35
  toViem(): ViemCommitteeAttestation;
35
36
  }
36
37
  //# sourceMappingURL=committee_attestation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"committee_attestation.d.ts","sourceRoot":"","sources":["../../../src/block/proposal/committee_attestation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAA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U,EAAE,SAAS,EAAE,CAAC;AAEjC,qBAAa,oBAAoB;aAEb,OAAO,EAAE,UAAU;aACnB,SAAS,EAAE,SAAS;gBADpB,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,SAAS;IAGtC,MAAM,KAAK,MAAM;;;;;;;;;;;;OAOhB;IAGD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,oBAAoB;IAK7D,MAAM,CAAC,uBAAuB,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,oBAAoB;IAI/F,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,oBAAoB;IAIhE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,GAAG,oBAAoB;IAIrE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,oBAAoB;IAOtE,MAAM,CAAC,MAAM,IAAI,oBAAoB;IAKrC,MAAM,CAAC,KAAK,IAAI,oBAAoB;IAIpC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,GAAG,oBAAoB,EAAE;IA+CnG,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAI5C,QAAQ,IAAI,MAAM;IAIlB,MAAM,IAAI,wBAAwB;CAMnC"}
@@ -92,6 +92,9 @@ export class CommitteeAttestation {
92
92
  equals(other) {
93
93
  return this.address.equals(other.address) && this.signature.equals(other.signature);
94
94
  }
95
+ toString() {
96
+ return `CommitteeAttestation(${this.address.toString()}, ${this.signature.toString()})`;
97
+ }
95
98
  toViem() {
96
99
  return {
97
100
  addr: this.address.toString(),
@@ -1,2 +1,3 @@
1
1
  export * from './committee_attestation.js';
2
+ export * from './attestations_and_signers.js';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/block/proposal/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/block/proposal/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from './committee_attestation.js';
2
+ export * from './attestations_and_signers.js';
@@ -1,11 +1,13 @@
1
1
  import type { SecretValue } from '@aztec/foundation/config';
2
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
+ import type { Signature } from '@aztec/foundation/eth-signature';
3
4
  import { Fr } from '@aztec/foundation/fields';
4
5
  import type { SequencerConfig, SlasherConfig } from '@aztec/stdlib/interfaces/server';
5
6
  import type { BlockAttestation, BlockProposal, BlockProposalOptions } from '@aztec/stdlib/p2p';
6
7
  import type { ProposedBlockHeader, StateReference, Tx } from '@aztec/stdlib/tx';
7
8
  import type { PeerId } from '@libp2p/interface';
8
9
  import { z } from 'zod';
10
+ import type { CommitteeAttestationsAndSigners } from '../block/index.js';
9
11
  /**
10
12
  * Validator client configuration
11
13
  */
@@ -60,5 +62,6 @@ export interface Validator {
60
62
  attestToProposal(proposal: BlockProposal, sender: PeerId): Promise<BlockAttestation[] | undefined>;
61
63
  broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
62
64
  collectAttestations(proposal: BlockProposal, required: number, deadline: Date): Promise<BlockAttestation[]>;
65
+ signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress): Promise<Signature>;
63
66
  }
64
67
  //# sourceMappingURL=validator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/interfaces/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,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AG,OAAO,CAAC,gBAAgB,EAAE,GAAG,SAAS,CAAC,CAAC;IAEnG,sBAAsB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC5G,0BAA0B,CACxB,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,SAAS,CAAC,CAAC;CACvB"}
@@ -1,7 +1,8 @@
1
1
  import { Buffer32 } from '@aztec/foundation/buffer';
2
2
  export declare enum SignatureDomainSeparator {
3
3
  blockProposal = 0,
4
- blockAttestation = 1
4
+ blockAttestation = 1,
5
+ attestationsAndSigners = 2
5
6
  }
6
7
  export interface Signable {
7
8
  getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer;
@@ -1 +1 @@
1
- {"version":3,"file":"signature_utils.d.ts","sourceRoot":"","sources":["../../src/p2p/signature_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,oBAAY,wBAAwB;IAClC,aAAa,IAAI;IACjB,gBAAgB,IAAI;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,gBAAgB,CAAC,eAAe,EAAE,wBAAwB,GAAG,MAAM,CAAC;CACrE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,wBAAwB,GAAG,QAAQ,CAE1G;AAED;;;;GAIG;AACH,wBAAgB,yCAAyC,CACvD,CAAC,EAAE,QAAQ,EACX,eAAe,EAAE,wBAAwB,GACxC,QAAQ,CAGV"}
1
+ {"version":3,"file":"signature_utils.d.ts","sourceRoot":"","sources":["../../src/p2p/signature_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,oBAAY,wBAAwB;IAClC,aAAa,IAAI;IACjB,gBAAgB,IAAI;IACpB,sBAAsB,IAAI;CAC3B;AAED,MAAM,WAAW,QAAQ;IACvB,gBAAgB,CAAC,eAAe,EAAE,wBAAwB,GAAG,MAAM,CAAC;CACrE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,wBAAwB,GAAG,QAAQ,CAE1G;AAED;;;;GAIG;AACH,wBAAgB,yCAAyC,CACvD,CAAC,EAAE,QAAQ,EACX,eAAe,EAAE,wBAAwB,GACxC,QAAQ,CAGV"}
@@ -3,6 +3,7 @@ import { keccak256, makeEthSignDigest } from '@aztec/foundation/crypto';
3
3
  export var SignatureDomainSeparator = /*#__PURE__*/ function(SignatureDomainSeparator) {
4
4
  SignatureDomainSeparator[SignatureDomainSeparator["blockProposal"] = 0] = "blockProposal";
5
5
  SignatureDomainSeparator[SignatureDomainSeparator["blockAttestation"] = 1] = "blockAttestation";
6
+ SignatureDomainSeparator[SignatureDomainSeparator["attestationsAndSigners"] = 2] = "attestationsAndSigners";
6
7
  return SignatureDomainSeparator;
7
8
  }({});
8
9
  /**
@@ -3,6 +3,7 @@ import { Fr } from '@aztec/foundation/fields';
3
3
  import type { ContractArtifact } from '../abi/abi.js';
4
4
  import { AztecAddress } from '../aztec-address/index.js';
5
5
  import { L2Block } from '../block/l2_block.js';
6
+ import type { CommitteeAttestationsAndSigners } from '../block/proposal/attestations_and_signers.js';
6
7
  import { PublishedL2Block } from '../block/published_l2_block.js';
7
8
  import type { ContractInstanceWithAddress } from '../contract/index.js';
8
9
  import { GasFees } from '../gas/gas_fees.js';
@@ -48,6 +49,7 @@ export interface MakeConsensusPayloadOptions {
48
49
  txHashes?: TxHash[];
49
50
  txs?: Tx[];
50
51
  }
52
+ export declare const makeAndSignCommitteeAttestationsAndSigners: (attestationsAndSigners: CommitteeAttestationsAndSigners, signer?: Secp256k1Signer) => import("../block/index.js").Signature;
51
53
  export declare const makeBlockProposal: (options?: MakeConsensusPayloadOptions) => BlockProposal;
52
54
  export declare const makeBlockAttestation: (options?: MakeConsensusPayloadOptions) => BlockAttestation;
53
55
  export declare const makeBlockAttestationFromBlock: (block: L2Block, signer?: Secp256k1Signer) => BlockAttestation;
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAe,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIlE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,WAAW,EAIX,cAAc,EACd,EAAE,EACH,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAiC,MAAM,uBAAuB,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,eAAO,MAAM,YAAY,QAAO,MAAyB,CAAC;AAE1D,eAAO,MAAM,kBAAkB,GAAU,6DAMtC,OAAO,CAAC,YAAY,CA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,eAAO,MAAM,sBAAsB;;;EAIlC,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,EAAE,CAAC;IACb,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;CACZ;AAqBD,eAAO,MAAM,0CAA0C,GACrD,wBAAwB,+BAA+B,EACvD,SAAQ,eAA0C,0CAOnD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,2BAA2B,KAAG,aAOzE,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAAI,UAAU,2BAA2B,KAAG,gBAM5E,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,OAAO,OAAO,EAAE,SAAS,eAAe,KAAG,gBAQxF,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,eAAe,EAAE,CAAA;CAAO,GACzC,OAAO,CAAC,gBAAgB,CAAC,CAc3B"}
@@ -148,6 +148,10 @@ const makeAndSignConsensusPayload = (domainSeparator, options)=>{
148
148
  signature
149
149
  };
150
150
  };
151
+ export const makeAndSignCommitteeAttestationsAndSigners = (attestationsAndSigners, signer = Secp256k1Signer.random())=>{
152
+ const hash = getHashedSignaturePayloadEthSignedMessage(attestationsAndSigners, SignatureDomainSeparator.attestationsAndSigners);
153
+ return signer.sign(hash);
154
+ };
151
155
  export const makeBlockProposal = (options)=>{
152
156
  const { blockNumber, payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockProposal, options);
153
157
  const txHashes = options?.txHashes ?? [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "2.0.3-rc.19",
3
+ "version": "2.0.3-rc.20",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -69,13 +69,13 @@
69
69
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
70
70
  },
71
71
  "dependencies": {
72
- "@aztec/bb.js": "2.0.3-rc.19",
73
- "@aztec/blob-lib": "2.0.3-rc.19",
74
- "@aztec/constants": "2.0.3-rc.19",
75
- "@aztec/ethereum": "2.0.3-rc.19",
76
- "@aztec/foundation": "2.0.3-rc.19",
77
- "@aztec/l1-artifacts": "2.0.3-rc.19",
78
- "@aztec/noir-noirc_abi": "2.0.3-rc.19",
72
+ "@aztec/bb.js": "2.0.3-rc.20",
73
+ "@aztec/blob-lib": "2.0.3-rc.20",
74
+ "@aztec/constants": "2.0.3-rc.20",
75
+ "@aztec/ethereum": "2.0.3-rc.20",
76
+ "@aztec/foundation": "2.0.3-rc.20",
77
+ "@aztec/l1-artifacts": "2.0.3-rc.20",
78
+ "@aztec/noir-noirc_abi": "2.0.3-rc.20",
79
79
  "@google-cloud/storage": "^7.15.0",
80
80
  "axios": "^1.9.0",
81
81
  "json-stringify-deterministic": "1.0.12",
@@ -0,0 +1,121 @@
1
+ import type { ViemCommitteeAttestations } from '@aztec/ethereum';
2
+ import { hexToBuffer } from '@aztec/foundation/string';
3
+
4
+ import { encodeAbiParameters, parseAbiParameters } from 'viem';
5
+ import { z } from 'zod';
6
+
7
+ import type { Signable, SignatureDomainSeparator } from '../../p2p/signature_utils.js';
8
+ import { CommitteeAttestation } from './committee_attestation.js';
9
+
10
+ export class CommitteeAttestationsAndSigners implements Signable {
11
+ constructor(public attestations: CommitteeAttestation[]) {}
12
+
13
+ static get schema() {
14
+ return z
15
+ .object({
16
+ attestations: CommitteeAttestation.schema.array(),
17
+ })
18
+ .transform(obj => new CommitteeAttestationsAndSigners(obj.attestations));
19
+ }
20
+
21
+ getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
22
+ const abi = parseAbiParameters('uint8,(bytes,bytes),address[]');
23
+ const packed = this.getPackedAttestations();
24
+
25
+ const encodedData = encodeAbiParameters(abi, [
26
+ domainSeparator,
27
+ [packed.signatureIndices, packed.signaturesOrAddresses],
28
+ this.getSigners().map(s => s.toString()),
29
+ ]);
30
+
31
+ return hexToBuffer(encodedData);
32
+ }
33
+
34
+ static empty(): CommitteeAttestationsAndSigners {
35
+ return new CommitteeAttestationsAndSigners([]);
36
+ }
37
+
38
+ toString() {
39
+ return `CommitteeAttestationsAndSigners(${this.attestations.map(a => a.toString()).join(',')})`;
40
+ }
41
+
42
+ getSigners() {
43
+ return this.attestations.filter(a => !a.signature.isEmpty()).map(a => a.address);
44
+ }
45
+
46
+ getSignedAttestations() {
47
+ return this.attestations.filter(a => !a.signature.isEmpty());
48
+ }
49
+
50
+ /**
51
+ * Packs an array of committee attestations into the format expected by the Solidity contract
52
+ *
53
+ * @param attestations - Array of committee attestations with addresses and signatures
54
+ * @returns Packed attestations with bitmap and tightly packed signature/address data
55
+ */
56
+ getPackedAttestations(): ViemCommitteeAttestations {
57
+ const length = this.attestations.length;
58
+ const attestations = this.attestations.map(a => a.toViem());
59
+
60
+ // Calculate bitmap size (1 bit per attestation, rounded up to nearest byte)
61
+ const bitmapSize = Math.ceil(length / 8);
62
+ const signatureIndices = new Uint8Array(bitmapSize);
63
+
64
+ // Calculate total data size needed
65
+ let totalDataSize = 0;
66
+ for (let i = 0; i < length; i++) {
67
+ const signature = attestations[i].signature;
68
+ // Check if signature is empty (v = 0)
69
+ const isEmpty = signature.v === 0;
70
+
71
+ if (!isEmpty) {
72
+ totalDataSize += 65; // v (1) + r (32) + s (32)
73
+ } else {
74
+ totalDataSize += 20; // address only
75
+ }
76
+ }
77
+
78
+ const signaturesOrAddresses = new Uint8Array(totalDataSize);
79
+ let dataIndex = 0;
80
+
81
+ // Pack the data
82
+ for (let i = 0; i < length; i++) {
83
+ const attestation = attestations[i];
84
+ const signature = attestation.signature;
85
+
86
+ // Check if signature is empty
87
+ const isEmpty = signature.v === 0;
88
+
89
+ if (!isEmpty) {
90
+ // Set bit in bitmap (bit 7-0 in each byte, left to right)
91
+ const byteIndex = Math.floor(i / 8);
92
+ const bitIndex = 7 - (i % 8);
93
+ signatureIndices[byteIndex] |= 1 << bitIndex;
94
+
95
+ // Pack signature: v + r + s
96
+ signaturesOrAddresses[dataIndex] = signature.v;
97
+ dataIndex++;
98
+
99
+ // Pack r (32 bytes)
100
+ const rBytes = Buffer.from(signature.r.slice(2), 'hex');
101
+ signaturesOrAddresses.set(rBytes, dataIndex);
102
+ dataIndex += 32;
103
+
104
+ // Pack s (32 bytes)
105
+ const sBytes = Buffer.from(signature.s.slice(2), 'hex');
106
+ signaturesOrAddresses.set(sBytes, dataIndex);
107
+ dataIndex += 32;
108
+ } else {
109
+ // Pack address only (20 bytes)
110
+ const addrBytes = Buffer.from(attestation.addr.slice(2), 'hex');
111
+ signaturesOrAddresses.set(addrBytes, dataIndex);
112
+ dataIndex += 20;
113
+ }
114
+ }
115
+
116
+ return {
117
+ signatureIndices: `0x${Buffer.from(signatureIndices).toString('hex')}`,
118
+ signaturesOrAddresses: `0x${Buffer.from(signaturesOrAddresses).toString('hex')}`,
119
+ };
120
+ }
121
+ }
@@ -111,6 +111,10 @@ export class CommitteeAttestation {
111
111
  return this.address.equals(other.address) && this.signature.equals(other.signature);
112
112
  }
113
113
 
114
+ toString(): string {
115
+ return `CommitteeAttestation(${this.address.toString()}, ${this.signature.toString()})`;
116
+ }
117
+
114
118
  toViem(): ViemCommitteeAttestation {
115
119
  return {
116
120
  addr: this.address.toString(),
@@ -1 +1,2 @@
1
1
  export * from './committee_attestation.js';
2
+ export * from './attestations_and_signers.js';
@@ -1,5 +1,6 @@
1
1
  import type { SecretValue } from '@aztec/foundation/config';
2
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
+ import type { Signature } from '@aztec/foundation/eth-signature';
3
4
  import { Fr } from '@aztec/foundation/fields';
4
5
  import { type ZodFor, schemas } from '@aztec/foundation/schemas';
5
6
  import type { SequencerConfig, SlasherConfig } from '@aztec/stdlib/interfaces/server';
@@ -9,6 +10,8 @@ import type { ProposedBlockHeader, StateReference, Tx } from '@aztec/stdlib/tx';
9
10
  import type { PeerId } from '@libp2p/interface';
10
11
  import { z } from 'zod';
11
12
 
13
+ import type { CommitteeAttestationsAndSigners } from '../block/index.js';
14
+
12
15
  /**
13
16
  * Validator client configuration
14
17
  */
@@ -70,4 +73,8 @@ export interface Validator {
70
73
 
71
74
  broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
72
75
  collectAttestations(proposal: BlockProposal, required: number, deadline: Date): Promise<BlockAttestation[]>;
76
+ signAttestationsAndSigners(
77
+ attestationsAndSigners: CommitteeAttestationsAndSigners,
78
+ proposer: EthAddress,
79
+ ): Promise<Signature>;
73
80
  }
@@ -4,6 +4,7 @@ import { keccak256, makeEthSignDigest } from '@aztec/foundation/crypto';
4
4
  export enum SignatureDomainSeparator {
5
5
  blockProposal = 0,
6
6
  blockAttestation = 1,
7
+ attestationsAndSigners = 2,
7
8
  }
8
9
 
9
10
  export interface Signable {
@@ -8,6 +8,7 @@ import type { ContractArtifact } from '../abi/abi.js';
8
8
  import { AztecAddress } from '../aztec-address/index.js';
9
9
  import { CommitteeAttestation, L1PublishedData } from '../block/index.js';
10
10
  import { L2Block } from '../block/l2_block.js';
11
+ import type { CommitteeAttestationsAndSigners } from '../block/proposal/attestations_and_signers.js';
11
12
  import { PublishedL2Block } from '../block/published_l2_block.js';
12
13
  import { computeContractAddressFromInstance } from '../contract/contract_address.js';
13
14
  import { getContractClassFromArtifact } from '../contract/contract_class.js';
@@ -273,6 +274,17 @@ const makeAndSignConsensusPayload = (
273
274
  return { blockNumber: header.globalVariables.blockNumber, payload, signature };
274
275
  };
275
276
 
277
+ export const makeAndSignCommitteeAttestationsAndSigners = (
278
+ attestationsAndSigners: CommitteeAttestationsAndSigners,
279
+ signer: Secp256k1Signer = Secp256k1Signer.random(),
280
+ ) => {
281
+ const hash = getHashedSignaturePayloadEthSignedMessage(
282
+ attestationsAndSigners,
283
+ SignatureDomainSeparator.attestationsAndSigners,
284
+ );
285
+ return signer.sign(hash);
286
+ };
287
+
276
288
  export const makeBlockProposal = (options?: MakeConsensusPayloadOptions): BlockProposal => {
277
289
  const { blockNumber, payload, signature } = makeAndSignConsensusPayload(
278
290
  SignatureDomainSeparator.blockProposal,