@verbeth/sdk 0.1.6 → 0.1.7
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/README.md +3 -3
- package/dist/esm/src/addresses.js +5 -6
- package/dist/esm/src/identity.d.ts +3 -3
- package/dist/esm/src/identity.d.ts.map +1 -1
- package/dist/esm/src/identity.js +9 -9
- package/dist/esm/src/utils.d.ts +1 -1
- package/dist/esm/src/utils.d.ts.map +1 -1
- package/dist/esm/src/utils.js +2 -2
- package/dist/esm/src/verify.js +2 -2
- package/dist/src/addresses.js +5 -6
- package/dist/src/identity.d.ts +3 -3
- package/dist/src/identity.d.ts.map +1 -1
- package/dist/src/identity.js +9 -9
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +2 -2
- package/dist/src/verify.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,10 +45,10 @@ MPL-2.0
|
|
|
45
45
|
|
|
46
46
|
## Links
|
|
47
47
|
|
|
48
|
-
- [GitHub Repository](https://github.com/okrame/verbeth
|
|
48
|
+
- [GitHub Repository](https://github.com/okrame/verbeth)
|
|
49
49
|
- [Demo App](https://verbeth-demo.vercel.app/)
|
|
50
|
-
- [Contract Source](https://github.com/okrame/verbeth
|
|
50
|
+
- [Contract Source](https://github.com/okrame/verbeth/tree/main/packages/contracts)
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
|
-
**Questions or feedback?** Open an issue on [GitHub](https://github.com/okrame/verbeth
|
|
54
|
+
**Questions or feedback?** Open an issue on [GitHub](https://github.com/okrame/verbeth/issues).
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// packages/sdk/src/addresses.ts
|
|
2
|
-
// Deterministic deployment
|
|
2
|
+
// Deterministic deployment
|
|
3
3
|
export const VERBETH_CONFIG = {
|
|
4
4
|
verbethProxy: '0x82C9c5475D63e4C9e959280e9066aBb24973a663',
|
|
5
5
|
verbethImpl: '0x51670aB6eDE1d1B11C654CCA53b7D42080802326',
|
|
6
|
-
creationBlock:
|
|
6
|
+
creationBlock: 37097547, // *** only base sepolia for now
|
|
7
7
|
};
|
|
8
|
-
//
|
|
8
|
+
// helpers for Safe session module
|
|
9
9
|
export const MODULE_SETUP_HELPERS = {
|
|
10
|
-
8453: '0xc022F74924BDB4b62D830234d89b066359bF67c0',
|
|
11
|
-
84532: '0xbd59Fea46D308eDF3b75C22a6f64AC68feFc731A',
|
|
10
|
+
8453: '0xc022F74924BDB4b62D830234d89b066359bF67c0',
|
|
11
|
+
84532: '0xbd59Fea46D308eDF3b75C22a6f64AC68feFc731A',
|
|
12
12
|
};
|
|
13
|
-
// Helper functions
|
|
14
13
|
export function getVerbethAddress() {
|
|
15
14
|
return VERBETH_CONFIG.verbethProxy;
|
|
16
15
|
}
|
|
@@ -21,9 +21,9 @@ export declare function deriveIdentityKeys(signer: any, address: string): Promis
|
|
|
21
21
|
/**
|
|
22
22
|
* Create the binding proof that ties the derived keys to the Safe address.
|
|
23
23
|
*/
|
|
24
|
-
export declare function createBindingProof(signer: any, address: string, derivedKeys: DerivedIdentityKeys,
|
|
25
|
-
export declare function deriveIdentityKeyPairWithProof(signer: any, address: string,
|
|
26
|
-
export declare function deriveIdentityWithUnifiedKeys(signer: Signer, address: string,
|
|
24
|
+
export declare function createBindingProof(signer: any, address: string, derivedKeys: DerivedIdentityKeys, executorAddress: string, ctx?: IdentityContext): Promise<IdentityProof>;
|
|
25
|
+
export declare function deriveIdentityKeyPairWithProof(signer: any, address: string, executorAddress?: string, ctx?: IdentityContext): Promise<DerivedIdentityWithProof>;
|
|
26
|
+
export declare function deriveIdentityWithUnifiedKeys(signer: Signer, address: string, executorAddress?: string, ctx?: IdentityContext): Promise<{
|
|
27
27
|
identityProof: IdentityProof;
|
|
28
28
|
identityPubKey: Uint8Array;
|
|
29
29
|
signingPubKey: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/identity.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAqC,MAAM,QAAQ,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwE7E,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,OAAO,EAAE,eAAe,CAAC;IACzB,2DAA2D;IAC3D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE,aAAa,EAAE,aAAa,CAAC;CAC9B;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CA8D9B;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,mBAAmB,EAChC,
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/identity.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAqC,MAAM,QAAQ,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwE7E,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,OAAO,EAAE,eAAe,CAAC;IACzB,2DAA2D;IAC3D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE,aAAa,EAAE,aAAa,CAAC;CAC9B;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CA8D9B;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,mBAAmB,EAChC,eAAe,EAAE,MAAM,EACvB,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,aAAa,CAAC,CAsBxB;AAID,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,EACxB,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,wBAAwB,CAAC,CAcnC;AAED,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,EACxB,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC;IACT,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,UAAU,CAAC;IAC3B,aAAa,EAAE,UAAU,CAAC;IAC1B,cAAc,EAAE,UAAU,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,CAqBD"}
|
package/dist/esm/src/identity.js
CHANGED
|
@@ -50,13 +50,13 @@ function buildSeedMessage(addrLower) {
|
|
|
50
50
|
];
|
|
51
51
|
return lines.join("\n");
|
|
52
52
|
}
|
|
53
|
-
function buildBindingMessage(addrLower, pkEd25519Hex, pkX25519Hex,
|
|
53
|
+
function buildBindingMessage(addrLower, pkEd25519Hex, pkX25519Hex, executorAddress, ctx) {
|
|
54
54
|
const lines = [
|
|
55
55
|
"VerbEth Key Binding v1",
|
|
56
56
|
`Address: ${addrLower}`,
|
|
57
57
|
`PkEd25519: ${pkEd25519Hex}`,
|
|
58
58
|
`PkX25519: ${pkX25519Hex}`,
|
|
59
|
-
`
|
|
59
|
+
`ExecutorAddress: ${executorAddress ?? ""}`,
|
|
60
60
|
];
|
|
61
61
|
if (typeof ctx?.chainId === "number")
|
|
62
62
|
lines.push(`ChainId: ${ctx.chainId}`);
|
|
@@ -129,10 +129,10 @@ export async function deriveIdentityKeys(signer, address) {
|
|
|
129
129
|
/**
|
|
130
130
|
* Create the binding proof that ties the derived keys to the Safe address.
|
|
131
131
|
*/
|
|
132
|
-
export async function createBindingProof(signer, address, derivedKeys,
|
|
132
|
+
export async function createBindingProof(signer, address, derivedKeys, executorAddress, ctx) {
|
|
133
133
|
const addrLower = address.toLowerCase();
|
|
134
|
-
const
|
|
135
|
-
const message = buildBindingMessage(addrLower, derivedKeys.pkEd25519Hex, derivedKeys.pkX25519Hex,
|
|
134
|
+
const executorAddressLower = executorAddress.toLowerCase();
|
|
135
|
+
const message = buildBindingMessage(addrLower, derivedKeys.pkEd25519Hex, derivedKeys.pkX25519Hex, executorAddressLower, ctx);
|
|
136
136
|
const signature = await signer.signMessage(message);
|
|
137
137
|
const messageRawHex = ("0x" +
|
|
138
138
|
Buffer.from(message, "utf-8").toString("hex"));
|
|
@@ -143,16 +143,16 @@ export async function createBindingProof(signer, address, derivedKeys, executorS
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
// this is when the Safe address is known upfront
|
|
146
|
-
export async function deriveIdentityKeyPairWithProof(signer, address,
|
|
146
|
+
export async function deriveIdentityKeyPairWithProof(signer, address, executorAddress, ctx) {
|
|
147
147
|
const derivedKeys = await deriveIdentityKeys(signer, address);
|
|
148
|
-
const identityProof = await createBindingProof(signer, address, derivedKeys,
|
|
148
|
+
const identityProof = await createBindingProof(signer, address, derivedKeys, executorAddress ?? "", ctx);
|
|
149
149
|
return {
|
|
150
150
|
...derivedKeys,
|
|
151
151
|
identityProof,
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
export async function deriveIdentityWithUnifiedKeys(signer, address,
|
|
155
|
-
const result = await deriveIdentityKeyPairWithProof(signer, address,
|
|
154
|
+
export async function deriveIdentityWithUnifiedKeys(signer, address, executorAddress, ctx) {
|
|
155
|
+
const result = await deriveIdentityKeyPairWithProof(signer, address, executorAddress, ctx);
|
|
156
156
|
const unifiedPubKeys = encodeUnifiedPubKeys(result.keyPair.publicKey, result.keyPair.signingPublicKey);
|
|
157
157
|
return {
|
|
158
158
|
identityProof: result.identityProof,
|
package/dist/esm/src/utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EAGhB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAGd,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EAGhB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAGd,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CA4BA;AAED,MAAM,MAAM,MAAM,GACd,OAAO,QAAQ,EAAE,eAAe,GAChC,OAAO,QAAQ,EAAE,eAAe,GAChC;IAAE,OAAO,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC;AAe5E,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAmBvB;AAED,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAEvE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAIxD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC,CA+DlB"}
|
package/dist/esm/src/utils.js
CHANGED
|
@@ -23,9 +23,9 @@ export function parseBindingMessage(message) {
|
|
|
23
23
|
if (key === "pkx25519") {
|
|
24
24
|
out.pkX25519 = hexlify(val);
|
|
25
25
|
}
|
|
26
|
-
if (key === "
|
|
26
|
+
if (key === "executoraddress" || key === "executorsafe") {
|
|
27
27
|
if (val)
|
|
28
|
-
out.
|
|
28
|
+
out.executorAddress = getAddress(val);
|
|
29
29
|
}
|
|
30
30
|
if (key === "context")
|
|
31
31
|
out.context = val;
|
package/dist/esm/src/verify.js
CHANGED
|
@@ -94,8 +94,8 @@ export async function verifyIdentityProof(identityProof, address, expectedUnifie
|
|
|
94
94
|
console.error("Unexpected binding header:", parsed.header);
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
97
|
-
if (!parsed.
|
|
98
|
-
getAddress(parsed.
|
|
97
|
+
if (!parsed.executorAddress ||
|
|
98
|
+
getAddress(parsed.executorAddress) !== getAddress(inputAddress)) {
|
|
99
99
|
console.error("Binding message Safe address mismatch");
|
|
100
100
|
return false;
|
|
101
101
|
}
|
package/dist/src/addresses.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// packages/sdk/src/addresses.ts
|
|
2
|
-
// Deterministic deployment
|
|
2
|
+
// Deterministic deployment
|
|
3
3
|
export const VERBETH_CONFIG = {
|
|
4
4
|
verbethProxy: '0x82C9c5475D63e4C9e959280e9066aBb24973a663',
|
|
5
5
|
verbethImpl: '0x51670aB6eDE1d1B11C654CCA53b7D42080802326',
|
|
6
|
-
creationBlock:
|
|
6
|
+
creationBlock: 37097547, // *** only base sepolia for now
|
|
7
7
|
};
|
|
8
|
-
//
|
|
8
|
+
// helpers for Safe session module
|
|
9
9
|
export const MODULE_SETUP_HELPERS = {
|
|
10
|
-
8453: '0xc022F74924BDB4b62D830234d89b066359bF67c0',
|
|
11
|
-
84532: '0xbd59Fea46D308eDF3b75C22a6f64AC68feFc731A',
|
|
10
|
+
8453: '0xc022F74924BDB4b62D830234d89b066359bF67c0',
|
|
11
|
+
84532: '0xbd59Fea46D308eDF3b75C22a6f64AC68feFc731A',
|
|
12
12
|
};
|
|
13
|
-
// Helper functions
|
|
14
13
|
export function getVerbethAddress() {
|
|
15
14
|
return VERBETH_CONFIG.verbethProxy;
|
|
16
15
|
}
|
package/dist/src/identity.d.ts
CHANGED
|
@@ -21,9 +21,9 @@ export declare function deriveIdentityKeys(signer: any, address: string): Promis
|
|
|
21
21
|
/**
|
|
22
22
|
* Create the binding proof that ties the derived keys to the Safe address.
|
|
23
23
|
*/
|
|
24
|
-
export declare function createBindingProof(signer: any, address: string, derivedKeys: DerivedIdentityKeys,
|
|
25
|
-
export declare function deriveIdentityKeyPairWithProof(signer: any, address: string,
|
|
26
|
-
export declare function deriveIdentityWithUnifiedKeys(signer: Signer, address: string,
|
|
24
|
+
export declare function createBindingProof(signer: any, address: string, derivedKeys: DerivedIdentityKeys, executorAddress: string, ctx?: IdentityContext): Promise<IdentityProof>;
|
|
25
|
+
export declare function deriveIdentityKeyPairWithProof(signer: any, address: string, executorAddress?: string, ctx?: IdentityContext): Promise<DerivedIdentityWithProof>;
|
|
26
|
+
export declare function deriveIdentityWithUnifiedKeys(signer: Signer, address: string, executorAddress?: string, ctx?: IdentityContext): Promise<{
|
|
27
27
|
identityProof: IdentityProof;
|
|
28
28
|
identityPubKey: Uint8Array;
|
|
29
29
|
signingPubKey: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAqC,MAAM,QAAQ,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwE7E,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,OAAO,EAAE,eAAe,CAAC;IACzB,2DAA2D;IAC3D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE,aAAa,EAAE,aAAa,CAAC;CAC9B;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CA8D9B;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,mBAAmB,EAChC,
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/identity.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAqC,MAAM,QAAQ,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwE7E,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,OAAO,EAAE,eAAe,CAAC;IACzB,2DAA2D;IAC3D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE,aAAa,EAAE,aAAa,CAAC;CAC9B;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CA8D9B;AAMD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,mBAAmB,EAChC,eAAe,EAAE,MAAM,EACvB,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,aAAa,CAAC,CAsBxB;AAID,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,EACxB,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC,wBAAwB,CAAC,CAcnC;AAED,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,EACxB,GAAG,CAAC,EAAE,eAAe,GACpB,OAAO,CAAC;IACT,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,UAAU,CAAC;IAC3B,aAAa,EAAE,UAAU,CAAC;IAC1B,cAAc,EAAE,UAAU,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,CAqBD"}
|
package/dist/src/identity.js
CHANGED
|
@@ -50,13 +50,13 @@ function buildSeedMessage(addrLower) {
|
|
|
50
50
|
];
|
|
51
51
|
return lines.join("\n");
|
|
52
52
|
}
|
|
53
|
-
function buildBindingMessage(addrLower, pkEd25519Hex, pkX25519Hex,
|
|
53
|
+
function buildBindingMessage(addrLower, pkEd25519Hex, pkX25519Hex, executorAddress, ctx) {
|
|
54
54
|
const lines = [
|
|
55
55
|
"VerbEth Key Binding v1",
|
|
56
56
|
`Address: ${addrLower}`,
|
|
57
57
|
`PkEd25519: ${pkEd25519Hex}`,
|
|
58
58
|
`PkX25519: ${pkX25519Hex}`,
|
|
59
|
-
`
|
|
59
|
+
`ExecutorAddress: ${executorAddress ?? ""}`,
|
|
60
60
|
];
|
|
61
61
|
if (typeof ctx?.chainId === "number")
|
|
62
62
|
lines.push(`ChainId: ${ctx.chainId}`);
|
|
@@ -129,10 +129,10 @@ export async function deriveIdentityKeys(signer, address) {
|
|
|
129
129
|
/**
|
|
130
130
|
* Create the binding proof that ties the derived keys to the Safe address.
|
|
131
131
|
*/
|
|
132
|
-
export async function createBindingProof(signer, address, derivedKeys,
|
|
132
|
+
export async function createBindingProof(signer, address, derivedKeys, executorAddress, ctx) {
|
|
133
133
|
const addrLower = address.toLowerCase();
|
|
134
|
-
const
|
|
135
|
-
const message = buildBindingMessage(addrLower, derivedKeys.pkEd25519Hex, derivedKeys.pkX25519Hex,
|
|
134
|
+
const executorAddressLower = executorAddress.toLowerCase();
|
|
135
|
+
const message = buildBindingMessage(addrLower, derivedKeys.pkEd25519Hex, derivedKeys.pkX25519Hex, executorAddressLower, ctx);
|
|
136
136
|
const signature = await signer.signMessage(message);
|
|
137
137
|
const messageRawHex = ("0x" +
|
|
138
138
|
Buffer.from(message, "utf-8").toString("hex"));
|
|
@@ -143,16 +143,16 @@ export async function createBindingProof(signer, address, derivedKeys, executorS
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
// this is when the Safe address is known upfront
|
|
146
|
-
export async function deriveIdentityKeyPairWithProof(signer, address,
|
|
146
|
+
export async function deriveIdentityKeyPairWithProof(signer, address, executorAddress, ctx) {
|
|
147
147
|
const derivedKeys = await deriveIdentityKeys(signer, address);
|
|
148
|
-
const identityProof = await createBindingProof(signer, address, derivedKeys,
|
|
148
|
+
const identityProof = await createBindingProof(signer, address, derivedKeys, executorAddress ?? "", ctx);
|
|
149
149
|
return {
|
|
150
150
|
...derivedKeys,
|
|
151
151
|
identityProof,
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
export async function deriveIdentityWithUnifiedKeys(signer, address,
|
|
155
|
-
const result = await deriveIdentityKeyPairWithProof(signer, address,
|
|
154
|
+
export async function deriveIdentityWithUnifiedKeys(signer, address, executorAddress, ctx) {
|
|
155
|
+
const result = await deriveIdentityKeyPairWithProof(signer, address, executorAddress, ctx);
|
|
156
156
|
const unifiedPubKeys = encodeUnifiedPubKeys(result.keyPair.publicKey, result.keyPair.signingPublicKey);
|
|
157
157
|
return {
|
|
158
158
|
identityProof: result.identityProof,
|
package/dist/src/utils.d.ts
CHANGED
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EAGhB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAGd,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,eAAe,EAGhB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAGd,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CA4BA;AAED,MAAM,MAAM,MAAM,GACd,OAAO,QAAQ,EAAE,eAAe,GAChC,OAAO,QAAQ,EAAE,eAAe,GAChC;IAAE,OAAO,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC;AAe5E,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAmBvB;AAED,eAAO,MAAM,cAAc,uEAC2C,CAAC;AAEvE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAIxD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC,CA+DlB"}
|
package/dist/src/utils.js
CHANGED
|
@@ -23,9 +23,9 @@ export function parseBindingMessage(message) {
|
|
|
23
23
|
if (key === "pkx25519") {
|
|
24
24
|
out.pkX25519 = hexlify(val);
|
|
25
25
|
}
|
|
26
|
-
if (key === "
|
|
26
|
+
if (key === "executoraddress" || key === "executorsafe") {
|
|
27
27
|
if (val)
|
|
28
|
-
out.
|
|
28
|
+
out.executorAddress = getAddress(val);
|
|
29
29
|
}
|
|
30
30
|
if (key === "context")
|
|
31
31
|
out.context = val;
|
package/dist/src/verify.js
CHANGED
|
@@ -94,8 +94,8 @@ export async function verifyIdentityProof(identityProof, address, expectedUnifie
|
|
|
94
94
|
console.error("Unexpected binding header:", parsed.header);
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
97
|
-
if (!parsed.
|
|
98
|
-
getAddress(parsed.
|
|
97
|
+
if (!parsed.executorAddress ||
|
|
98
|
+
getAddress(parsed.executorAddress) !== getAddress(inputAddress)) {
|
|
99
99
|
console.error("Binding message Safe address mismatch");
|
|
100
100
|
return false;
|
|
101
101
|
}
|