@aztec/foundation 0.87.3-nightly.20250528 → 0.87.3
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/eth-signature/eth_signature.d.ts +6 -3
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/eth-signature/eth_signature.js +13 -13
- package/dest/types/index.d.ts +0 -19
- package/dest/types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/eth-signature/eth_signature.ts +20 -15
- package/src/types/index.ts +0 -19
|
@@ -8,6 +8,7 @@ export type ViemSignature = {
|
|
|
8
8
|
r: `0x${string}`;
|
|
9
9
|
s: `0x${string}`;
|
|
10
10
|
v: number;
|
|
11
|
+
isEmpty: boolean;
|
|
11
12
|
};
|
|
12
13
|
/**
|
|
13
14
|
* Contains a signature split into it's primary components (r,s,v)
|
|
@@ -19,15 +20,18 @@ export declare class Signature {
|
|
|
19
20
|
readonly s: Buffer32;
|
|
20
21
|
/** The v value of the signature */
|
|
21
22
|
readonly v: number;
|
|
23
|
+
/** Does this struct store an empty signature */
|
|
24
|
+
readonly isEmpty: boolean;
|
|
22
25
|
private size;
|
|
23
|
-
readonly empty: boolean;
|
|
24
26
|
constructor(
|
|
25
27
|
/** The r value of the signature */
|
|
26
28
|
r: Buffer32,
|
|
27
29
|
/** The s value of the signature */
|
|
28
30
|
s: Buffer32,
|
|
29
31
|
/** The v value of the signature */
|
|
30
|
-
v: number
|
|
32
|
+
v: number,
|
|
33
|
+
/** Does this struct store an empty signature */
|
|
34
|
+
isEmpty?: boolean);
|
|
31
35
|
static fromBuffer(buf: Buffer | BufferReader): Signature;
|
|
32
36
|
static isValidString(sig: `0x${string}`): boolean;
|
|
33
37
|
/**
|
|
@@ -39,7 +43,6 @@ export declare class Signature {
|
|
|
39
43
|
static fromViemSignature(sig: ViemSignature): Signature;
|
|
40
44
|
static random(): Signature;
|
|
41
45
|
static empty(): Signature;
|
|
42
|
-
isEmpty(): boolean;
|
|
43
46
|
equals(other: Signature): boolean;
|
|
44
47
|
toBuffer(): Buffer;
|
|
45
48
|
getSize(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth_signature.d.ts","sourceRoot":"","sources":["../../src/eth-signature/eth_signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACjB,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"eth_signature.d.ts","sourceRoot":"","sources":["../../src/eth-signature/eth_signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACjB,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS;IAKlB,mCAAmC;aACnB,CAAC,EAAE,QAAQ;IAC3B,mCAAmC;aACnB,CAAC,EAAE,QAAQ;IAC3B,mCAAmC;aACnB,CAAC,EAAE,MAAM;IACzB,gDAAgD;aAChC,OAAO,EAAE,OAAO;IAVlC,OAAO,CAAC,IAAI,CAAqB;;IAG/B,mCAAmC;IACnB,CAAC,EAAE,QAAQ;IAC3B,mCAAmC;IACnB,CAAC,EAAE,QAAQ;IAC3B,mCAAmC;IACnB,CAAC,EAAE,MAAM;IACzB,gDAAgD;IAChC,OAAO,GAAE,OAAe;IAG1C,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAYxD,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,MAAM,EAAE,GAAG,OAAO;IAIjD;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,MAAM,EAAE,GAAG,SAAS;IAYhD,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,SAAS;IASvD,MAAM,CAAC,MAAM,IAAI,SAAS;IAI1B,MAAM,CAAC,KAAK,IAAI,SAAS;IAIzB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;IAIjC,QAAQ,IAAI,MAAM;IAMlB,OAAO,IAAI,MAAM;IAUjB,QAAQ,IAAI,KAAK,MAAM,EAAE;IAIzB;;OAEG;IACH,eAAe,IAAI,aAAa;IAShC,MAAM;IAIN,MAAM,KAAK,MAAM,2HAMhB;CACF"}
|
|
@@ -8,21 +8,22 @@ import { hasHexPrefix, hexToBuffer } from '../string/index.js';
|
|
|
8
8
|
r;
|
|
9
9
|
s;
|
|
10
10
|
v;
|
|
11
|
+
isEmpty;
|
|
11
12
|
// Cached values
|
|
12
13
|
size;
|
|
13
|
-
empty
|
|
14
|
-
constructor(/** The r value of the signature */ r, /** The s value of the signature */ s, /** The v value of the signature */ v){
|
|
14
|
+
constructor(/** The r value of the signature */ r, /** The s value of the signature */ s, /** The v value of the signature */ v, /** Does this struct store an empty signature */ isEmpty = false){
|
|
15
15
|
this.r = r;
|
|
16
16
|
this.s = s;
|
|
17
17
|
this.v = v;
|
|
18
|
-
this.
|
|
18
|
+
this.isEmpty = isEmpty;
|
|
19
19
|
}
|
|
20
20
|
static fromBuffer(buf) {
|
|
21
21
|
const reader = BufferReader.asReader(buf);
|
|
22
22
|
const r = reader.readObject(Buffer32);
|
|
23
23
|
const s = reader.readObject(Buffer32);
|
|
24
24
|
const v = reader.readNumber();
|
|
25
|
-
|
|
25
|
+
const isEmpty = r.isZero() && s.isZero();
|
|
26
|
+
return new Signature(r, s, v, isEmpty);
|
|
26
27
|
}
|
|
27
28
|
static isValidString(sig) {
|
|
28
29
|
return /^0x[0-9a-f]{129,}$/i.test(sig);
|
|
@@ -37,22 +38,20 @@ import { hasHexPrefix, hexToBuffer } from '../string/index.js';
|
|
|
37
38
|
const r = reader.readObject(Buffer32);
|
|
38
39
|
const s = reader.readObject(Buffer32);
|
|
39
40
|
const v = parseInt(sig.slice(2 + 64 * 2), 16);
|
|
40
|
-
|
|
41
|
+
const isEmpty = r.isZero() && s.isZero();
|
|
42
|
+
return new Signature(r, s, v, isEmpty);
|
|
41
43
|
}
|
|
42
44
|
static fromViemSignature(sig) {
|
|
43
|
-
return new Signature(Buffer32.fromBuffer(hexToBuffer(sig.r)), Buffer32.fromBuffer(hexToBuffer(sig.s)), sig.v);
|
|
45
|
+
return new Signature(Buffer32.fromBuffer(hexToBuffer(sig.r)), Buffer32.fromBuffer(hexToBuffer(sig.s)), sig.v, sig.isEmpty);
|
|
44
46
|
}
|
|
45
47
|
static random() {
|
|
46
|
-
return new Signature(Buffer32.random(), Buffer32.random(), Math.floor(Math.random() * 2));
|
|
48
|
+
return new Signature(Buffer32.random(), Buffer32.random(), Math.floor(Math.random() * 2), false);
|
|
47
49
|
}
|
|
48
50
|
static empty() {
|
|
49
|
-
return new Signature(Buffer32.ZERO, Buffer32.ZERO, 0);
|
|
50
|
-
}
|
|
51
|
-
isEmpty() {
|
|
52
|
-
return this.empty;
|
|
51
|
+
return new Signature(Buffer32.ZERO, Buffer32.ZERO, 0, true);
|
|
53
52
|
}
|
|
54
53
|
equals(other) {
|
|
55
|
-
return this.r.equals(other.r) && this.s.equals(other.s) && this.v === other.v && this.
|
|
54
|
+
return this.r.equals(other.r) && this.s.equals(other.s) && this.v === other.v && this.isEmpty === other.isEmpty;
|
|
56
55
|
}
|
|
57
56
|
toBuffer() {
|
|
58
57
|
const buffer = serializeToBuffer([
|
|
@@ -80,7 +79,8 @@ import { hasHexPrefix, hexToBuffer } from '../string/index.js';
|
|
|
80
79
|
return {
|
|
81
80
|
r: this.r.toString(),
|
|
82
81
|
s: this.s.toString(),
|
|
83
|
-
v: this.v
|
|
82
|
+
v: this.v,
|
|
83
|
+
isEmpty: this.isEmpty
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
toJSON() {
|
package/dest/types/index.d.ts
CHANGED
|
@@ -14,23 +14,4 @@ export type Writeable<T> = {
|
|
|
14
14
|
};
|
|
15
15
|
/** Removes readonly modifiers for an object. */
|
|
16
16
|
export declare function unfreeze<T>(obj: T): Writeable<T>;
|
|
17
|
-
/**
|
|
18
|
-
* Type-safe Event Emitter type
|
|
19
|
-
* @example
|
|
20
|
-
* export type ArchiverEmitter = TypedEventEmitter<{
|
|
21
|
-
* [L2BlockSourceEvents.L2PruneDetected]: (args: L2BlockSourceEvent) => void;
|
|
22
|
-
* [L2BlockSourceEvents.L2BlockProven]: (args: L2BlockSourceEvent) => void;
|
|
23
|
-
* }>;
|
|
24
|
-
* class Archiver extends (EventEmitter as new () => ArchiverEmitter) {
|
|
25
|
-
* // ...
|
|
26
|
-
* }
|
|
27
|
-
*/
|
|
28
|
-
export interface TypedEventEmitter<TEventMap extends {
|
|
29
|
-
[key in keyof TEventMap]: (...args: any[]) => void;
|
|
30
|
-
}> {
|
|
31
|
-
on<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
|
|
32
|
-
off<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
|
|
33
|
-
emit<K extends keyof TEventMap>(event: K, ...args: Parameters<TEventMap[K]>): boolean;
|
|
34
|
-
removeListener<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
|
|
35
|
-
}
|
|
36
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACvB,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,kCAAkC;AAClC,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE/E,6CAA6C;AAC7C,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE9D,gDAAgD;AAChD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAEhD
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KACvB,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,kCAAkC;AAClC,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE/E,6CAA6C;AAC7C,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAE9D,gDAAgD;AAChD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAEhD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/foundation",
|
|
3
|
-
"version": "0.87.3
|
|
3
|
+
"version": "0.87.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dest/index.js",
|
|
6
6
|
"types": "./dest/index.d.ts",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
]
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@aztec/bb.js": "0.87.3
|
|
103
|
+
"@aztec/bb.js": "0.87.3",
|
|
104
104
|
"@koa/cors": "^5.0.0",
|
|
105
105
|
"@noble/curves": "^1.2.0",
|
|
106
106
|
"c-kzg": "4.0.0-alpha.1",
|
|
@@ -12,6 +12,7 @@ export type ViemSignature = {
|
|
|
12
12
|
r: `0x${string}`;
|
|
13
13
|
s: `0x${string}`;
|
|
14
14
|
v: number;
|
|
15
|
+
isEmpty: boolean;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -21,8 +22,6 @@ export class Signature {
|
|
|
21
22
|
// Cached values
|
|
22
23
|
private size: number | undefined;
|
|
23
24
|
|
|
24
|
-
public readonly empty: boolean;
|
|
25
|
-
|
|
26
25
|
constructor(
|
|
27
26
|
/** The r value of the signature */
|
|
28
27
|
public readonly r: Buffer32,
|
|
@@ -30,9 +29,9 @@ export class Signature {
|
|
|
30
29
|
public readonly s: Buffer32,
|
|
31
30
|
/** The v value of the signature */
|
|
32
31
|
public readonly v: number,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
32
|
+
/** Does this struct store an empty signature */
|
|
33
|
+
public readonly isEmpty: boolean = false,
|
|
34
|
+
) {}
|
|
36
35
|
|
|
37
36
|
static fromBuffer(buf: Buffer | BufferReader): Signature {
|
|
38
37
|
const reader = BufferReader.asReader(buf);
|
|
@@ -41,7 +40,9 @@ export class Signature {
|
|
|
41
40
|
const s = reader.readObject(Buffer32);
|
|
42
41
|
const v = reader.readNumber();
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
const isEmpty = r.isZero() && s.isZero();
|
|
44
|
+
|
|
45
|
+
return new Signature(r, s, v, isEmpty);
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
static isValidString(sig: `0x${string}`): boolean {
|
|
@@ -60,27 +61,30 @@ export class Signature {
|
|
|
60
61
|
const s = reader.readObject(Buffer32);
|
|
61
62
|
const v = parseInt(sig.slice(2 + 64 * 2), 16);
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
const isEmpty = r.isZero() && s.isZero();
|
|
65
|
+
|
|
66
|
+
return new Signature(r, s, v, isEmpty);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
static fromViemSignature(sig: ViemSignature): Signature {
|
|
67
|
-
return new Signature(
|
|
70
|
+
return new Signature(
|
|
71
|
+
Buffer32.fromBuffer(hexToBuffer(sig.r)),
|
|
72
|
+
Buffer32.fromBuffer(hexToBuffer(sig.s)),
|
|
73
|
+
sig.v,
|
|
74
|
+
sig.isEmpty,
|
|
75
|
+
);
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
static random(): Signature {
|
|
71
|
-
return new Signature(Buffer32.random(), Buffer32.random(), Math.floor(Math.random() * 2));
|
|
79
|
+
return new Signature(Buffer32.random(), Buffer32.random(), Math.floor(Math.random() * 2), false);
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
static empty(): Signature {
|
|
75
|
-
return new Signature(Buffer32.ZERO, Buffer32.ZERO, 0);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
isEmpty(): boolean {
|
|
79
|
-
return this.empty;
|
|
83
|
+
return new Signature(Buffer32.ZERO, Buffer32.ZERO, 0, true);
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
equals(other: Signature): boolean {
|
|
83
|
-
return this.r.equals(other.r) && this.s.equals(other.s) && this.v === other.v && this.
|
|
87
|
+
return this.r.equals(other.r) && this.s.equals(other.s) && this.v === other.v && this.isEmpty === other.isEmpty;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
toBuffer(): Buffer {
|
|
@@ -111,6 +115,7 @@ export class Signature {
|
|
|
111
115
|
r: this.r.toString(),
|
|
112
116
|
s: this.s.toString(),
|
|
113
117
|
v: this.v,
|
|
118
|
+
isEmpty: this.isEmpty,
|
|
114
119
|
};
|
|
115
120
|
}
|
|
116
121
|
|
package/src/types/index.ts
CHANGED
|
@@ -18,22 +18,3 @@ export type Writeable<T> = { -readonly [P in keyof T]: T[P] };
|
|
|
18
18
|
export function unfreeze<T>(obj: T): Writeable<T> {
|
|
19
19
|
return obj as Writeable<T>;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Type-safe Event Emitter type
|
|
24
|
-
* @example
|
|
25
|
-
* export type ArchiverEmitter = TypedEventEmitter<{
|
|
26
|
-
* [L2BlockSourceEvents.L2PruneDetected]: (args: L2BlockSourceEvent) => void;
|
|
27
|
-
* [L2BlockSourceEvents.L2BlockProven]: (args: L2BlockSourceEvent) => void;
|
|
28
|
-
* }>;
|
|
29
|
-
* class Archiver extends (EventEmitter as new () => ArchiverEmitter) {
|
|
30
|
-
* // ...
|
|
31
|
-
* }
|
|
32
|
-
*/
|
|
33
|
-
export interface TypedEventEmitter<TEventMap extends { [key in keyof TEventMap]: (...args: any[]) => void }> {
|
|
34
|
-
on<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
|
|
35
|
-
off<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
|
|
36
|
-
emit<K extends keyof TEventMap>(event: K, ...args: Parameters<TEventMap[K]>): boolean;
|
|
37
|
-
removeListener<K extends keyof TEventMap>(event: K, listener: TEventMap[K]): this;
|
|
38
|
-
// Can add other EventEmitter methods if needed, like once(), listenerCount(), etc.
|
|
39
|
-
}
|