@aztec/foundation 2.1.0-rc.2 → 2.1.0-rc.21
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/config/network_name.d.ts +1 -1
- package/dest/config/network_name.d.ts.map +1 -1
- package/dest/config/network_name.js +2 -2
- package/dest/crypto/secp256k1-signer/utils.d.ts +8 -0
- package/dest/crypto/secp256k1-signer/utils.d.ts.map +1 -1
- package/dest/crypto/secp256k1-signer/utils.js +14 -0
- package/dest/eth-signature/eth_signature.js +1 -1
- package/package.json +3 -3
- package/src/config/network_name.ts +3 -3
- package/src/crypto/secp256k1-signer/utils.ts +16 -0
- package/src/eth-signature/eth_signature.ts +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type NetworkNames = 'local' | 'staging-ignition' | 'staging-public' | 'testnet' | '
|
|
1
|
+
export type NetworkNames = 'local' | 'staging-ignition' | 'staging-public' | 'testnet' | 'mainnet';
|
|
2
2
|
export declare function getActiveNetworkName(name?: string): NetworkNames;
|
|
3
3
|
//# sourceMappingURL=network_name.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network_name.d.ts","sourceRoot":"","sources":["../../src/config/network_name.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"network_name.d.ts","sourceRoot":"","sources":["../../src/config/network_name.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnG,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,YAAY,CAchE"}
|
|
@@ -8,8 +8,8 @@ export function getActiveNetworkName(name) {
|
|
|
8
8
|
return network;
|
|
9
9
|
} else if (network === 'testnet' || network === 'alpha-testnet') {
|
|
10
10
|
return 'testnet';
|
|
11
|
-
} else if (network === '
|
|
12
|
-
return '
|
|
11
|
+
} else if (network === 'mainnet') {
|
|
12
|
+
return 'mainnet';
|
|
13
13
|
}
|
|
14
14
|
throw new Error(`Unknown network: ${network}`);
|
|
15
15
|
}
|
|
@@ -19,8 +19,16 @@ export declare function addressFromPrivateKey(privateKey: Buffer): EthAddress;
|
|
|
19
19
|
* @param hash - The hash to recover the address from.
|
|
20
20
|
* @param signature - The signature to recover the address from.
|
|
21
21
|
* @returns The address.
|
|
22
|
+
* @throws Error if signature recovery fails.
|
|
22
23
|
*/
|
|
23
24
|
export declare function recoverAddress(hash: Buffer32, signature: Signature): EthAddress;
|
|
25
|
+
/**
|
|
26
|
+
* Safely attempts to recover an address from a hash and a signature.
|
|
27
|
+
* @param hash - The hash to recover the address from.
|
|
28
|
+
* @param signature - The signature to recover the address from.
|
|
29
|
+
* @returns The address if recovery succeeds, undefined otherwise.
|
|
30
|
+
*/
|
|
31
|
+
export declare function tryRecoverAddress(hash: Buffer32, signature: Signature): EthAddress | undefined;
|
|
24
32
|
/**
|
|
25
33
|
* @attribution - viem
|
|
26
34
|
* Converts a yParityOrV value to a recovery bit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/crypto/secp256k1-signer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAMjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAG7D;AAYD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAGpE;AAED
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/crypto/secp256k1-signer/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAMjE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAG7D;AAYD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAGpE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAS/E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAO9F;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,SAW/C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAGhE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAM7E"}
|
|
@@ -40,6 +40,7 @@ export function makeEthSignDigest(message) {
|
|
|
40
40
|
* @param hash - The hash to recover the address from.
|
|
41
41
|
* @param signature - The signature to recover the address from.
|
|
42
42
|
* @returns The address.
|
|
43
|
+
* @throws Error if signature recovery fails.
|
|
43
44
|
*/ export function recoverAddress(hash, signature) {
|
|
44
45
|
try {
|
|
45
46
|
const publicKey = recoverPublicKey(hash, signature);
|
|
@@ -48,6 +49,19 @@ export function makeEthSignDigest(message) {
|
|
|
48
49
|
throw new Error(`Error recovering Ethereum address from hash ${hash.toString()} and signature ${signature.toString()}: ${err}`);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Safely attempts to recover an address from a hash and a signature.
|
|
54
|
+
* @param hash - The hash to recover the address from.
|
|
55
|
+
* @param signature - The signature to recover the address from.
|
|
56
|
+
* @returns The address if recovery succeeds, undefined otherwise.
|
|
57
|
+
*/ export function tryRecoverAddress(hash, signature) {
|
|
58
|
+
try {
|
|
59
|
+
const publicKey = recoverPublicKey(hash, signature);
|
|
60
|
+
return publicKeyToAddress(publicKey);
|
|
61
|
+
} catch {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
51
65
|
/**
|
|
52
66
|
* @attribution - viem
|
|
53
67
|
* Converts a yParityOrV value to a recovery bit.
|
|
@@ -46,7 +46,7 @@ import { hasHexPrefix, hexToBuffer } from '../string/index.js';
|
|
|
46
46
|
return new Signature(Buffer32.fromBuffer(hexToBuffer(sig.r)), Buffer32.fromBuffer(hexToBuffer(sig.s)), sig.yParity);
|
|
47
47
|
}
|
|
48
48
|
static random() {
|
|
49
|
-
return new Signature(Buffer32.random(), Buffer32.random(),
|
|
49
|
+
return new Signature(Buffer32.random(), Buffer32.random(), 1);
|
|
50
50
|
}
|
|
51
51
|
static empty() {
|
|
52
52
|
return new Signature(Buffer32.ZERO, Buffer32.ZERO, 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/foundation",
|
|
3
|
-
"version": "2.1.0-rc.
|
|
3
|
+
"version": "2.1.0-rc.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dest/index.js",
|
|
6
6
|
"types": "./dest/index.d.ts",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"testEnvironment": "../../foundation/src/jest/env.mjs"
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@aztec/bb.js": "2.1.0-rc.
|
|
105
|
+
"@aztec/bb.js": "2.1.0-rc.21",
|
|
106
106
|
"@koa/cors": "^5.0.0",
|
|
107
107
|
"@noble/curves": "=1.7.0",
|
|
108
108
|
"bn.js": "^5.2.1",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
"ts-node": "^10.9.1",
|
|
154
154
|
"typescript": "^5.3.3",
|
|
155
155
|
"typescript-eslint": "^8.32.1",
|
|
156
|
-
"viem": "2.
|
|
156
|
+
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0"
|
|
157
157
|
},
|
|
158
158
|
"files": [
|
|
159
159
|
"dest",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type NetworkNames = 'local' | 'staging-ignition' | 'staging-public' | 'testnet' | '
|
|
1
|
+
export type NetworkNames = 'local' | 'staging-ignition' | 'staging-public' | 'testnet' | 'mainnet';
|
|
2
2
|
|
|
3
3
|
export function getActiveNetworkName(name?: string): NetworkNames {
|
|
4
4
|
const network = name || process.env.NETWORK;
|
|
@@ -10,8 +10,8 @@ export function getActiveNetworkName(name?: string): NetworkNames {
|
|
|
10
10
|
return network;
|
|
11
11
|
} else if (network === 'testnet' || network === 'alpha-testnet') {
|
|
12
12
|
return 'testnet';
|
|
13
|
-
} else if (network === '
|
|
14
|
-
return '
|
|
13
|
+
} else if (network === 'mainnet') {
|
|
14
|
+
return 'mainnet';
|
|
15
15
|
}
|
|
16
16
|
throw new Error(`Unknown network: ${network}`);
|
|
17
17
|
}
|
|
@@ -47,6 +47,7 @@ export function addressFromPrivateKey(privateKey: Buffer): EthAddress {
|
|
|
47
47
|
* @param hash - The hash to recover the address from.
|
|
48
48
|
* @param signature - The signature to recover the address from.
|
|
49
49
|
* @returns The address.
|
|
50
|
+
* @throws Error if signature recovery fails.
|
|
50
51
|
*/
|
|
51
52
|
export function recoverAddress(hash: Buffer32, signature: Signature): EthAddress {
|
|
52
53
|
try {
|
|
@@ -59,6 +60,21 @@ export function recoverAddress(hash: Buffer32, signature: Signature): EthAddress
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Safely attempts to recover an address from a hash and a signature.
|
|
65
|
+
* @param hash - The hash to recover the address from.
|
|
66
|
+
* @param signature - The signature to recover the address from.
|
|
67
|
+
* @returns The address if recovery succeeds, undefined otherwise.
|
|
68
|
+
*/
|
|
69
|
+
export function tryRecoverAddress(hash: Buffer32, signature: Signature): EthAddress | undefined {
|
|
70
|
+
try {
|
|
71
|
+
const publicKey = recoverPublicKey(hash, signature);
|
|
72
|
+
return publicKeyToAddress(publicKey);
|
|
73
|
+
} catch {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
62
78
|
/**
|
|
63
79
|
* @attribution - viem
|
|
64
80
|
* Converts a yParityOrV value to a recovery bit.
|
|
@@ -78,7 +78,7 @@ export class Signature {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
static random(): Signature {
|
|
81
|
-
return new Signature(Buffer32.random(), Buffer32.random(),
|
|
81
|
+
return new Signature(Buffer32.random(), Buffer32.random(), 1);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
static empty(): Signature {
|