@aztec/accounts 0.76.4 → 0.77.0-testnet-ignition.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/README.md +11 -8
- package/artifacts/EcdsaKAccount.d.json.ts +1 -1
- package/artifacts/EcdsaKAccount.json +850 -690
- package/artifacts/EcdsaRAccount.d.json.ts +1 -1
- package/artifacts/EcdsaRAccount.json +684 -524
- package/artifacts/SchnorrAccount.d.json.ts +1 -1
- package/artifacts/SchnorrAccount.json +692 -459
- package/artifacts/SchnorrSingleKeyAccount.d.json.ts +1 -1
- package/artifacts/SchnorrSingleKeyAccount.json +227 -301
- package/dest/dapp/dapp_interface.d.ts +1 -2
- package/dest/dapp/dapp_interface.d.ts.map +1 -1
- package/dest/dapp/dapp_interface.js +3 -5
- package/dest/dapp/index.js +0 -1
- package/dest/defaults/account_contract.d.ts +5 -7
- package/dest/defaults/account_contract.d.ts.map +1 -1
- package/dest/defaults/account_contract.js +2 -9
- package/dest/defaults/account_interface.d.ts +8 -4
- package/dest/defaults/account_interface.d.ts.map +1 -1
- package/dest/defaults/account_interface.js +8 -5
- package/dest/defaults/index.js +1 -3
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts +5 -3
- package/dest/ecdsa/ecdsa_k/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/account_contract.js +19 -14
- package/dest/ecdsa/ecdsa_k/index.d.ts +15 -5
- package/dest/ecdsa/ecdsa_k/index.d.ts.map +1 -1
- package/dest/ecdsa/ecdsa_k/index.js +21 -10
- package/dest/ecdsa/ecdsa_k/lazy.d.ts +47 -0
- package/dest/ecdsa/ecdsa_k/lazy.d.ts.map +1 -0
- package/dest/ecdsa/ecdsa_k/lazy.js +52 -0
- package/dest/ecdsa/index.js +0 -1
- package/dest/ecdsa/lazy.d.ts +3 -0
- package/dest/ecdsa/lazy.d.ts.map +1 -0
- package/dest/ecdsa/lazy.js +2 -0
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts +5 -3
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/account_contract.js +55 -51
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts +18 -5
- package/dest/ecdsa/ssh_ecdsa_r/index.d.ts.map +1 -1
- package/dest/ecdsa/ssh_ecdsa_r/index.js +24 -10
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts +49 -0
- package/dest/ecdsa/ssh_ecdsa_r/lazy.d.ts.map +1 -0
- package/dest/ecdsa/ssh_ecdsa_r/lazy.js +57 -0
- package/dest/schnorr/account_contract.d.ts +13 -4
- package/dest/schnorr/account_contract.d.ts.map +1 -1
- package/dest/schnorr/account_contract.js +18 -14
- package/dest/schnorr/index.d.ts +32 -6
- package/dest/schnorr/index.d.ts.map +1 -1
- package/dest/schnorr/index.js +43 -10
- package/dest/schnorr/lazy.d.ts +61 -0
- package/dest/schnorr/lazy.d.ts.map +1 -0
- package/dest/schnorr/lazy.js +74 -0
- package/dest/single_key/account_contract.d.ts +6 -3
- package/dest/single_key/account_contract.d.ts.map +1 -1
- package/dest/single_key/account_contract.js +17 -13
- package/dest/single_key/index.d.ts +16 -8
- package/dest/single_key/index.d.ts.map +1 -1
- package/dest/single_key/index.js +23 -13
- package/dest/single_key/lazy.d.ts +43 -0
- package/dest/single_key/lazy.d.ts.map +1 -0
- package/dest/single_key/lazy.js +53 -0
- package/dest/testing/configuration.d.ts +23 -24
- package/dest/testing/configuration.d.ts.map +1 -1
- package/dest/testing/configuration.js +8 -79
- package/dest/testing/create_account.d.ts +38 -15
- package/dest/testing/create_account.d.ts.map +1 -1
- package/dest/testing/create_account.js +53 -49
- package/dest/testing/index.d.ts +28 -4
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +42 -6
- package/dest/testing/lazy.d.ts +34 -0
- package/dest/testing/lazy.d.ts.map +1 -0
- package/dest/testing/lazy.js +46 -0
- package/dest/utils/index.js +0 -1
- package/dest/utils/ssh_agent.js +75 -31
- package/package.json +12 -10
- package/src/dapp/dapp_interface.ts +7 -2
- package/src/defaults/account_contract.ts +5 -9
- package/src/defaults/account_interface.ts +8 -4
- package/src/ecdsa/ecdsa_k/account_contract.ts +9 -8
- package/src/ecdsa/ecdsa_k/index.ts +25 -5
- package/src/ecdsa/ecdsa_k/lazy.ts +71 -0
- package/src/ecdsa/lazy.ts +2 -0
- package/src/ecdsa/ssh_ecdsa_r/account_contract.ts +9 -8
- package/src/ecdsa/ssh_ecdsa_r/index.ts +29 -5
- package/src/ecdsa/ssh_ecdsa_r/lazy.ts +78 -0
- package/src/schnorr/account_contract.ts +10 -9
- package/src/schnorr/index.ts +56 -7
- package/src/schnorr/lazy.ts +107 -0
- package/src/single_key/account_contract.ts +9 -8
- package/src/single_key/index.ts +29 -11
- package/src/single_key/lazy.ts +71 -0
- package/src/testing/configuration.ts +21 -103
- package/src/testing/create_account.ts +79 -57
- package/src/testing/index.ts +85 -4
- package/src/testing/lazy.ts +86 -0
- package/dest/ecdsa/ecdsa_k/artifact.d.ts +0 -3
- package/dest/ecdsa/ecdsa_k/artifact.d.ts.map +0 -1
- package/dest/ecdsa/ecdsa_k/artifact.js +0 -4
- package/dest/ecdsa/ssh_ecdsa_r/artifact.d.ts +0 -2
- package/dest/ecdsa/ssh_ecdsa_r/artifact.d.ts.map +0 -1
- package/dest/ecdsa/ssh_ecdsa_r/artifact.js +0 -4
- package/dest/schnorr/artifact.d.ts +0 -2
- package/dest/schnorr/artifact.d.ts.map +0 -1
- package/dest/schnorr/artifact.js +0 -4
- package/dest/single_key/artifact.d.ts +0 -2
- package/dest/single_key/artifact.d.ts.map +0 -1
- package/dest/single_key/artifact.js +0 -4
- package/src/ecdsa/ecdsa_k/artifact.ts +0 -7
- package/src/ecdsa/ssh_ecdsa_r/artifact.ts +0 -5
- package/src/schnorr/artifact.ts +0 -5
- package/src/single_key/artifact.ts +0 -7
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { AuthWitness } from '@aztec/circuit-types';
|
|
4
|
-
import { EcdsaSignature } from '@aztec/circuits.js/barretenberg';
|
|
1
|
+
import { EcdsaSignature } from '@aztec/foundation/crypto';
|
|
2
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
3
|
import { DefaultAccountContract } from '../../defaults/account_contract.js';
|
|
6
4
|
import { signWithAgent } from '../../utils/ssh_agent.js';
|
|
7
|
-
import { EcdsaRAccountContractArtifact } from './artifact.js';
|
|
8
5
|
const secp256r1N = 115792089210356248762697446949407573529996955224135760342422259061068512044369n;
|
|
9
6
|
/**
|
|
10
7
|
* Account contract that authenticates transactions using ECDSA signatures
|
|
@@ -12,65 +9,72 @@ const secp256r1N = 1157920892103562487626974469494075735299969552241357603424222
|
|
|
12
9
|
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
13
10
|
* public key here not for signature verification, but to identify actual identity
|
|
14
11
|
* that will be used to sign authwitnesses.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
13
|
+
* can be implemented with or without lazy loading.
|
|
14
|
+
*/ export class EcdsaRSSHBaseAccountContract extends DefaultAccountContract {
|
|
15
|
+
signingPublicKey;
|
|
16
|
+
constructor(signingPublicKey){
|
|
17
|
+
super(), this.signingPublicKey = signingPublicKey;
|
|
20
18
|
}
|
|
21
19
|
getDeploymentArgs() {
|
|
22
|
-
return Promise.resolve([
|
|
20
|
+
return Promise.resolve([
|
|
21
|
+
this.signingPublicKey.subarray(0, 32),
|
|
22
|
+
this.signingPublicKey.subarray(32, 64)
|
|
23
|
+
]);
|
|
23
24
|
}
|
|
24
25
|
getAuthWitnessProvider(_address) {
|
|
25
26
|
return new SSHEcdsaRAuthWitnessProvider(this.signingPublicKey);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
/** Creates auth witnesses using ECDSA signatures. */
|
|
29
|
-
|
|
30
|
-
constructor(signingPublicKey)
|
|
31
|
-
_SSHEcdsaRAuthWitnessProvider_instances.add(this);
|
|
29
|
+
/** Creates auth witnesses using ECDSA signatures. */ class SSHEcdsaRAuthWitnessProvider {
|
|
30
|
+
signingPublicKey;
|
|
31
|
+
constructor(signingPublicKey){
|
|
32
32
|
this.signingPublicKey = signingPublicKey;
|
|
33
33
|
}
|
|
34
|
+
#parseECDSASignature(data) {
|
|
35
|
+
// Extract ECDSA signature components
|
|
36
|
+
let offset = 0;
|
|
37
|
+
const sigTypeLen = data.readUInt32BE(offset);
|
|
38
|
+
offset += 4;
|
|
39
|
+
const sigType = data.subarray(offset, offset + sigTypeLen).toString();
|
|
40
|
+
offset += sigTypeLen;
|
|
41
|
+
if (sigType !== 'ecdsa-sha2-nistp256') {
|
|
42
|
+
throw new Error(`Unexpected signature type: ${sigType}`);
|
|
43
|
+
}
|
|
44
|
+
offset += 4;
|
|
45
|
+
const rLen = data.readUInt32BE(offset);
|
|
46
|
+
offset += 4;
|
|
47
|
+
let r = data.subarray(offset, offset + rLen);
|
|
48
|
+
offset += rLen;
|
|
49
|
+
const sLen = data.readUInt32BE(offset);
|
|
50
|
+
offset += 4;
|
|
51
|
+
let s = data.subarray(offset, offset + sLen);
|
|
52
|
+
// R and S are encoded using ASN.1 DER format, which may include a leading zero byte to avoid interpreting the value as negative
|
|
53
|
+
if (r.length > 32) {
|
|
54
|
+
r = Buffer.from(Uint8Array.prototype.slice.call(r, 1));
|
|
55
|
+
}
|
|
56
|
+
if (s.length > 32) {
|
|
57
|
+
s = Buffer.from(Uint8Array.prototype.slice.call(s, 1));
|
|
58
|
+
}
|
|
59
|
+
const maybeHighS = BigInt(`0x${s.toString('hex')}`);
|
|
60
|
+
// ECDSA signatures must have a low S value so they can be used as a nullifier. BB forces a value of 27 for v, so
|
|
61
|
+
// only one PublicKey can verify the signature (and not its negated counterpart) https://ethereum.stackexchange.com/a/55728
|
|
62
|
+
if (maybeHighS > secp256r1N / 2n + 1n) {
|
|
63
|
+
s = Buffer.from((secp256r1N - maybeHighS).toString(16), 'hex');
|
|
64
|
+
}
|
|
65
|
+
return new EcdsaSignature(r, s, Buffer.from([
|
|
66
|
+
0
|
|
67
|
+
]));
|
|
68
|
+
}
|
|
34
69
|
async createAuthWit(messageHash) {
|
|
35
70
|
// Key type and curve name
|
|
36
71
|
const keyType = Buffer.from('ecdsa-sha2-nistp256');
|
|
37
72
|
const curveName = Buffer.from('nistp256');
|
|
38
73
|
const data = await signWithAgent(keyType, curveName, this.signingPublicKey, messageHash.toBuffer());
|
|
39
|
-
const signature =
|
|
40
|
-
return new AuthWitness(messageHash, [
|
|
74
|
+
const signature = this.#parseECDSASignature(data);
|
|
75
|
+
return new AuthWitness(messageHash, [
|
|
76
|
+
...signature.r,
|
|
77
|
+
...signature.s
|
|
78
|
+
]);
|
|
41
79
|
}
|
|
42
80
|
}
|
|
43
|
-
_SSHEcdsaRAuthWitnessProvider_instances = new WeakSet(), _SSHEcdsaRAuthWitnessProvider_parseECDSASignature = function _SSHEcdsaRAuthWitnessProvider_parseECDSASignature(data) {
|
|
44
|
-
// Extract ECDSA signature components
|
|
45
|
-
let offset = 0;
|
|
46
|
-
const sigTypeLen = data.readUInt32BE(offset);
|
|
47
|
-
offset += 4;
|
|
48
|
-
const sigType = data.subarray(offset, offset + sigTypeLen).toString();
|
|
49
|
-
offset += sigTypeLen;
|
|
50
|
-
if (sigType !== 'ecdsa-sha2-nistp256') {
|
|
51
|
-
throw new Error(`Unexpected signature type: ${sigType}`);
|
|
52
|
-
}
|
|
53
|
-
offset += 4;
|
|
54
|
-
const rLen = data.readUInt32BE(offset);
|
|
55
|
-
offset += 4;
|
|
56
|
-
let r = data.subarray(offset, offset + rLen);
|
|
57
|
-
offset += rLen;
|
|
58
|
-
const sLen = data.readUInt32BE(offset);
|
|
59
|
-
offset += 4;
|
|
60
|
-
let s = data.subarray(offset, offset + sLen);
|
|
61
|
-
// R and S are encoded using ASN.1 DER format, which may include a leading zero byte to avoid interpreting the value as negative
|
|
62
|
-
if (r.length > 32) {
|
|
63
|
-
r = Buffer.from(Uint8Array.prototype.slice.call(r, 1));
|
|
64
|
-
}
|
|
65
|
-
if (s.length > 32) {
|
|
66
|
-
s = Buffer.from(Uint8Array.prototype.slice.call(s, 1));
|
|
67
|
-
}
|
|
68
|
-
const maybeHighS = BigInt(`0x${s.toString('hex')}`);
|
|
69
|
-
// ECDSA signatures must have a low S value so they can be used as a nullifier. BB forces a value of 27 for v, so
|
|
70
|
-
// only one PublicKey can verify the signature (and not its negated counterpart) https://ethereum.stackexchange.com/a/55728
|
|
71
|
-
if (maybeHighS > secp256r1N / 2n + 1n) {
|
|
72
|
-
s = Buffer.from((secp256r1N - maybeHighS).toString(16), 'hex');
|
|
73
|
-
}
|
|
74
|
-
return new EcdsaSignature(r, s, Buffer.from([0]));
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudF9jb250cmFjdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9lY2RzYS9zc2hfZWNkc2Ffci9hY2NvdW50X2NvbnRyYWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQ0EsT0FBTyxFQUFFLFdBQVcsRUFBd0IsTUFBTSxzQkFBc0IsQ0FBQztBQUN6RSxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFJakUsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFDNUUsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ3pELE9BQU8sRUFBRSw2QkFBNkIsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUU5RCxNQUFNLFVBQVUsR0FBRywrRUFBK0UsQ0FBQztBQU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sTUFBTSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztBQUNwRCxDQUFDIn0=
|
|
@@ -8,11 +8,24 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
10
10
|
import { type AccountWallet } from '@aztec/aztec.js/wallet';
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
12
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
13
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
15
|
+
import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
|
|
16
|
+
export declare const EcdsaRAccountContractArtifact: ContractArtifact;
|
|
17
|
+
/**
|
|
18
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
19
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
20
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
21
|
+
* public key here not for signature verification, but to identify actual identity
|
|
22
|
+
* that will be used to sign authwitnesses.
|
|
23
|
+
* Eagerly loads the contract artifact
|
|
24
|
+
*/
|
|
25
|
+
export declare class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
|
|
26
|
+
constructor(signingPrivateKey: Buffer);
|
|
27
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
28
|
+
}
|
|
16
29
|
/**
|
|
17
30
|
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
18
31
|
* @param pxe - An PXE server instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/index.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/index.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAI3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,eAAO,MAAM,6BAA6B,EAAE,gBAE3C,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpH"}
|
|
@@ -3,12 +3,29 @@
|
|
|
3
3
|
* Consider using this account type when working with integrations with Ethereum wallets.
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
import { AccountManager } from '@aztec/aztec.js/account';
|
|
6
|
+
*/ import { AccountManager } from '@aztec/aztec.js/account';
|
|
8
7
|
import { getWallet } from '@aztec/aztec.js/wallet';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
9
|
+
import EcdsaRAccountContractJson from '../../../artifacts/EcdsaKAccount.json' assert {
|
|
10
|
+
type: 'json'
|
|
11
|
+
};
|
|
12
|
+
import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
|
|
13
|
+
export const EcdsaRAccountContractArtifact = loadContractArtifact(EcdsaRAccountContractJson);
|
|
14
|
+
/**
|
|
15
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
16
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
17
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
18
|
+
* public key here not for signature verification, but to identify actual identity
|
|
19
|
+
* that will be used to sign authwitnesses.
|
|
20
|
+
* Eagerly loads the contract artifact
|
|
21
|
+
*/ export class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
|
|
22
|
+
constructor(signingPrivateKey){
|
|
23
|
+
super(signingPrivateKey);
|
|
24
|
+
}
|
|
25
|
+
getContractArtifact() {
|
|
26
|
+
return Promise.resolve(EcdsaRAccountContractArtifact);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
12
29
|
/**
|
|
13
30
|
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
14
31
|
* @param pxe - An PXE server instance.
|
|
@@ -16,8 +33,7 @@ export { EcdsaRSSHAccountContract };
|
|
|
16
33
|
* @param signingPublicKey - Secp2561 key used to identify its corresponding private key in the SSH Agent.
|
|
17
34
|
* @param salt - Deployment salt.
|
|
18
35
|
* @returns An account manager initialized with the account contract and its deployment params
|
|
19
|
-
*/
|
|
20
|
-
export function getEcdsaRSSHAccount(pxe, secretKey, signingPublicKey, salt) {
|
|
36
|
+
*/ export function getEcdsaRSSHAccount(pxe, secretKey, signingPublicKey, salt) {
|
|
21
37
|
return AccountManager.create(pxe, secretKey, new EcdsaRSSHAccountContract(signingPublicKey), salt);
|
|
22
38
|
}
|
|
23
39
|
/**
|
|
@@ -26,8 +42,6 @@ export function getEcdsaRSSHAccount(pxe, secretKey, signingPublicKey, salt) {
|
|
|
26
42
|
* @param address - Address for the account.
|
|
27
43
|
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
28
44
|
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
29
|
-
*/
|
|
30
|
-
export function getEcdsaRSSHWallet(pxe, address, signingPublicKey) {
|
|
45
|
+
*/ export function getEcdsaRSSHWallet(pxe, address, signingPublicKey) {
|
|
31
46
|
return getWallet(pxe, address, new EcdsaRSSHAccountContract(signingPublicKey));
|
|
32
47
|
}
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZWNkc2Evc3NoX2VjZHNhX3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7O0dBS0c7QUFDSCxPQUFPLEVBQUUsY0FBYyxFQUFhLE1BQU0seUJBQXlCLENBQUM7QUFDcEUsT0FBTyxFQUFzQixTQUFTLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUl2RSxPQUFPLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUVqRSxPQUFPLEVBQUUsNkJBQTZCLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDOUQsT0FBTyxFQUFFLHdCQUF3QixFQUFFLENBQUM7QUFFcEM7Ozs7Ozs7R0FPRztBQUNILE1BQU0sVUFBVSxtQkFBbUIsQ0FDakMsR0FBUSxFQUNSLFNBQWEsRUFDYixnQkFBd0IsRUFDeEIsSUFBVztJQUVYLE9BQU8sY0FBYyxDQUFDLE1BQU0sQ0FBQyxHQUFHLEVBQUUsU0FBUyxFQUFFLElBQUksd0JBQXdCLENBQUMsZ0JBQWdCLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQztBQUNyRyxDQUFDO0FBRUQ7Ozs7OztHQU1HO0FBQ0gsTUFBTSxVQUFVLGtCQUFrQixDQUFDLEdBQVEsRUFBRSxPQUFxQixFQUFFLGdCQUF3QjtJQUMxRixPQUFPLFNBQVMsQ0FBQyxHQUFHLEVBQUUsT0FBTyxFQUFFLElBQUksd0JBQXdCLENBQUMsZ0JBQWdCLENBQUMsQ0FBQyxDQUFDO0FBQ2pGLENBQUMifQ==
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/**
|
|
4
|
+
* The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
|
|
5
|
+
* Consider using this account type when working with integrations with Ethereum wallets.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
10
|
+
import { type AccountWallet } from '@aztec/aztec.js/wallet';
|
|
11
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
12
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
13
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
15
|
+
import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export declare function getEcdsaRAccountContractArtifact(): Promise<ContractArtifact>;
|
|
20
|
+
/**
|
|
21
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
22
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
23
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
24
|
+
* public key here not for signature verification, but to identify actual identity
|
|
25
|
+
* that will be used to sign authwitnesses.
|
|
26
|
+
* Lazily loads the contract artifact
|
|
27
|
+
*/
|
|
28
|
+
export declare class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
|
|
29
|
+
constructor(signingPrivateKey: Buffer);
|
|
30
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
34
|
+
* @param pxe - An PXE server instance.
|
|
35
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
36
|
+
* @param signingPublicKey - Secp2561 key used to identify its corresponding private key in the SSH Agent.
|
|
37
|
+
* @param salt - Deployment salt.
|
|
38
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
39
|
+
*/
|
|
40
|
+
export declare function getEcdsaRSSHAccount(pxe: PXE, secretKey: Fr, signingPublicKey: Buffer, salt?: Salt): Promise<AccountManager>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
43
|
+
* @param pxe - An PXE server instance.
|
|
44
|
+
* @param address - Address for the account.
|
|
45
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
46
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getEcdsaRSSHWallet(pxe: PXE, address: AztecAddress, signingPublicKey: Buffer): Promise<AccountWallet>;
|
|
49
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../src/ecdsa/ssh_ecdsa_r/lazy.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAMrE;;GAEG;AACH,wBAAsB,gCAAgC,8BAQrD;AAED;;;;;;;GAOG;AACH,qBAAa,wBAAyB,SAAQ,4BAA4B;gBAC5D,iBAAiB,EAAE,MAAM;IAI5B,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,gBAAgB,EAAE,MAAM,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpH"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/ecdsa` export provides an ECDSA account contract implementation, that uses an ECDSA private key for authentication, and a Grumpkin key for encryption.
|
|
3
|
+
* Consider using this account type when working with integrations with Ethereum wallets.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/ import { AccountManager } from '@aztec/aztec.js/account';
|
|
7
|
+
import { getWallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
9
|
+
import { EcdsaRSSHBaseAccountContract } from './account_contract.js';
|
|
10
|
+
/*
|
|
11
|
+
* Lazily loads the contract artifact
|
|
12
|
+
* @returns The contract artifact for the ecdsa R account contract
|
|
13
|
+
*/ /**
|
|
14
|
+
*
|
|
15
|
+
*/ export async function getEcdsaRAccountContractArtifact() {
|
|
16
|
+
// Cannot assert this import as it's incompatible with browsers
|
|
17
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
18
|
+
// Use the new "with" syntax once supported by firefox
|
|
19
|
+
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
20
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
21
|
+
const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaRAccount.json');
|
|
22
|
+
return loadContractArtifact(ecdsaKAccountContractJson);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Account contract that authenticates transactions using ECDSA signatures
|
|
26
|
+
* verified against a secp256r1 public key stored in an immutable encrypted note.
|
|
27
|
+
* Since this implementation relays signatures to an SSH agent, we provide the
|
|
28
|
+
* public key here not for signature verification, but to identify actual identity
|
|
29
|
+
* that will be used to sign authwitnesses.
|
|
30
|
+
* Lazily loads the contract artifact
|
|
31
|
+
*/ export class EcdsaRSSHAccountContract extends EcdsaRSSHBaseAccountContract {
|
|
32
|
+
constructor(signingPrivateKey){
|
|
33
|
+
super(signingPrivateKey);
|
|
34
|
+
}
|
|
35
|
+
getContractArtifact() {
|
|
36
|
+
return getEcdsaRAccountContractArtifact();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an Account that relies on an ECDSA signing key for authentication.
|
|
41
|
+
* @param pxe - An PXE server instance.
|
|
42
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
43
|
+
* @param signingPublicKey - Secp2561 key used to identify its corresponding private key in the SSH Agent.
|
|
44
|
+
* @param salt - Deployment salt.
|
|
45
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
46
|
+
*/ export function getEcdsaRSSHAccount(pxe, secretKey, signingPublicKey, salt) {
|
|
47
|
+
return AccountManager.create(pxe, secretKey, new EcdsaRSSHAccountContract(signingPublicKey), salt);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets a wallet for an already registered account using ECDSA signatures.
|
|
51
|
+
* @param pxe - An PXE server instance.
|
|
52
|
+
* @param address - Address for the account.
|
|
53
|
+
* @param signingPrivateKey - ECDSA key used for signing transactions.
|
|
54
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
55
|
+
*/ export function getEcdsaRSSHWallet(pxe, address, signingPublicKey) {
|
|
56
|
+
return getWallet(pxe, address, new EcdsaRSSHAccountContract(signingPublicKey));
|
|
57
|
+
}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
|
|
2
|
+
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
3
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
|
+
import { CompleteAddress } from '@aztec/stdlib/contract';
|
|
4
5
|
import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
5
6
|
/**
|
|
6
7
|
* Account contract that authenticates transactions using Schnorr signatures
|
|
7
8
|
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
9
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
10
|
+
* can be implemented with or without lazy loading.
|
|
8
11
|
*/
|
|
9
|
-
export declare class
|
|
12
|
+
export declare abstract class SchnorrBaseAccountContract extends DefaultAccountContract {
|
|
10
13
|
private signingPrivateKey;
|
|
11
14
|
constructor(signingPrivateKey: GrumpkinScalar);
|
|
12
15
|
getDeploymentArgs(): Promise<Fr[]>;
|
|
13
16
|
getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider;
|
|
14
17
|
}
|
|
18
|
+
/** Creates auth witnesses using Schnorr signatures. */
|
|
19
|
+
export declare class SchnorrAuthWitnessProvider implements AuthWitnessProvider {
|
|
20
|
+
private signingPrivateKey;
|
|
21
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
22
|
+
createAuthWit(messageHash: Fr): Promise<AuthWitness>;
|
|
23
|
+
}
|
|
15
24
|
//# sourceMappingURL=account_contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/schnorr/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"account_contract.d.ts","sourceRoot":"","sources":["../../src/schnorr/account_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE;;;;;GAKG;AACH,8BAAsB,0BAA2B,SAAQ,sBAAsB;IACjE,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,cAAc;IAI/C,iBAAiB;IAKvB,sBAAsB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB;CAGvE;AAED,uDAAuD;AACvD,qBAAa,0BAA2B,YAAW,mBAAmB;IACxD,OAAO,CAAC,iBAAiB;gBAAjB,iBAAiB,EAAE,cAAc;IAE/C,aAAa,CAAC,WAAW,EAAE,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;CAK3D"}
|
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Schnorr } from '@aztec/foundation/crypto';
|
|
2
|
+
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
3
|
import { DefaultAccountContract } from '../defaults/account_contract.js';
|
|
4
|
-
import { SchnorrAccountContractArtifact } from './artifact.js';
|
|
5
4
|
/**
|
|
6
5
|
* Account contract that authenticates transactions using Schnorr signatures
|
|
7
6
|
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
* This abstract version does not provide a way to retrieve the artifact, as it
|
|
8
|
+
* can be implemented with or without lazy loading.
|
|
9
|
+
*/ export class SchnorrBaseAccountContract extends DefaultAccountContract {
|
|
10
|
+
signingPrivateKey;
|
|
11
|
+
constructor(signingPrivateKey){
|
|
12
|
+
super(), this.signingPrivateKey = signingPrivateKey;
|
|
13
13
|
}
|
|
14
14
|
async getDeploymentArgs() {
|
|
15
15
|
const signingPublicKey = await new Schnorr().computePublicKey(this.signingPrivateKey);
|
|
16
|
-
return [
|
|
16
|
+
return [
|
|
17
|
+
signingPublicKey.x,
|
|
18
|
+
signingPublicKey.y
|
|
19
|
+
];
|
|
17
20
|
}
|
|
18
21
|
getAuthWitnessProvider(_address) {
|
|
19
22
|
return new SchnorrAuthWitnessProvider(this.signingPrivateKey);
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
|
-
/** Creates auth witnesses using Schnorr signatures. */
|
|
23
|
-
|
|
24
|
-
constructor(signingPrivateKey)
|
|
25
|
+
/** Creates auth witnesses using Schnorr signatures. */ export class SchnorrAuthWitnessProvider {
|
|
26
|
+
signingPrivateKey;
|
|
27
|
+
constructor(signingPrivateKey){
|
|
25
28
|
this.signingPrivateKey = signingPrivateKey;
|
|
26
29
|
}
|
|
27
30
|
async createAuthWit(messageHash) {
|
|
28
31
|
const schnorr = new Schnorr();
|
|
29
32
|
const signature = await schnorr.constructSignature(messageHash.toBuffer(), this.signingPrivateKey);
|
|
30
|
-
return new AuthWitness(messageHash, [
|
|
33
|
+
return new AuthWitness(messageHash, [
|
|
34
|
+
...signature.toBuffer()
|
|
35
|
+
]);
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudF9jb250cmFjdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hub3JyL2FjY291bnRfY29udHJhY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFdBQVcsRUFBNkMsTUFBTSxzQkFBc0IsQ0FBQztBQUM5RixPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFJMUQsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDekUsT0FBTyxFQUFFLDhCQUE4QixFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRS9EOzs7R0FHRztBQUNILE1BQU0sT0FBTyxzQkFBdUIsU0FBUSxzQkFBc0I7SUFDaEUsWUFBb0IsaUJBQWlDO1FBQ25ELEtBQUssQ0FBQyw4QkFBa0QsQ0FBQyxDQUFDO1FBRHhDLHNCQUFpQixHQUFqQixpQkFBaUIsQ0FBZ0I7SUFFckQsQ0FBQztJQUVELEtBQUssQ0FBQyxpQkFBaUI7UUFDckIsTUFBTSxnQkFBZ0IsR0FBRyxNQUFNLElBQUksT0FBTyxFQUFFLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxDQUFDLGlCQUFpQixDQUFDLENBQUM7UUFDdEYsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBQUMsRUFBRSxnQkFBZ0IsQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUNsRCxDQUFDO0lBRUQsc0JBQXNCLENBQUMsUUFBeUI7UUFDOUMsT0FBTyxJQUFJLDBCQUEwQixDQUFDLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO0lBQ2hFLENBQUM7Q0FDRjtBQUVELHVEQUF1RDtBQUN2RCxNQUFNLDBCQUEwQjtJQUM5QixZQUFvQixpQkFBaUM7UUFBakMsc0JBQWlCLEdBQWpCLGlCQUFpQixDQUFnQjtJQUFHLENBQUM7SUFFekQsS0FBSyxDQUFDLGFBQWEsQ0FBQyxXQUFlO1FBQ2pDLE1BQU0sT0FBTyxHQUFHLElBQUksT0FBTyxFQUFFLENBQUM7UUFDOUIsTUFBTSxTQUFTLEdBQUcsTUFBTSxPQUFPLENBQUMsa0JBQWtCLENBQUMsV0FBVyxDQUFDLFFBQVEsRUFBRSxFQUFFLElBQUksQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDO1FBQ25HLE9BQU8sSUFBSSxXQUFXLENBQUMsV0FBVyxFQUFFLENBQUMsR0FBRyxTQUFTLENBQUMsUUFBUSxFQUFFLENBQUMsQ0FBQyxDQUFDO0lBQ2pFLENBQUM7Q0FDRiJ9
|
package/dest/schnorr/index.d.ts
CHANGED
|
@@ -5,12 +5,22 @@
|
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
import { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
8
|
-
import { type AccountWallet } from '@aztec/aztec.js/wallet';
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import { type AccountWallet, type AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
|
|
9
|
+
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
10
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
13
|
+
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
14
|
+
export declare const SchnorrAccountContractArtifact: ContractArtifact;
|
|
15
|
+
/**
|
|
16
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
17
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
18
|
+
* Eagerly loads the contract artifact
|
|
19
|
+
*/
|
|
20
|
+
export declare class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
21
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
22
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
23
|
+
}
|
|
14
24
|
/**
|
|
15
25
|
* Creates an Account Manager that relies on a Grumpkin signing key for authentication.
|
|
16
26
|
* @param pxe - An PXE server instance.
|
|
@@ -28,4 +38,20 @@ export declare function getSchnorrAccount(pxe: PXE, secretKey: Fr, signingPrivat
|
|
|
28
38
|
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
29
39
|
*/
|
|
30
40
|
export declare function getSchnorrWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: GrumpkinScalar): Promise<AccountWallet>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
43
|
+
* @param pxe - An PXE server instance.
|
|
44
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
45
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
46
|
+
* @param salt - Deployment salt.
|
|
47
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getSchnorrWalletWithSecretKey(pxe: PXE, secretKey: Fr, signingPrivateKey: GrumpkinScalar, salt: Salt): Promise<AccountWalletWithSecretKey>;
|
|
50
|
+
/**
|
|
51
|
+
* Compute the address of a schnorr account contract.
|
|
52
|
+
* @param secret - A seed for deriving the signing key and public keys.
|
|
53
|
+
* @param salt - The contract address salt.
|
|
54
|
+
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getSchnorrAccountContractAddress(secret: Fr, salt: Fr, signingPrivateKey?: GrumpkinScalar): Promise<AztecAddress>;
|
|
31
57
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schnorr/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schnorr/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAA6B,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,0BAA0B,EAAa,MAAM,wBAAwB,CAAC;AACxG,OAAO,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAK3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,eAAO,MAAM,8BAA8B,kBAA2E,CAAC;AAEvH;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,0BAA0B;gBACxD,iBAAiB,EAAE,cAAc;IAIpC,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,cAAc,EACjC,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,YAAY,EACrB,iBAAiB,EAAE,cAAc,GAChC,OAAO,CAAC,aAAa,CAAC,CAExB;AAED;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,EACb,iBAAiB,EAAE,cAAc,EACjC,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,0BAA0B,CAAC,CAGrC;AAED;;;;;GAKG;AACH,wBAAsB,gCAAgC,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,CAAC,EAAE,cAAc,yBAI9G"}
|
package/dest/schnorr/index.js
CHANGED
|
@@ -3,12 +3,27 @@
|
|
|
3
3
|
* This is the suggested account contract type for most use cases within Aztec.
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
import { AccountManager } from '@aztec/aztec.js/account';
|
|
6
|
+
*/ import { AccountManager, getAccountContractAddress } from '@aztec/aztec.js/account';
|
|
8
7
|
import { getWallet } from '@aztec/aztec.js/wallet';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
9
|
+
import { deriveSigningKey } from '@aztec/stdlib/keys';
|
|
10
|
+
import SchnorrAccountContractJson from '../../artifacts/SchnorrAccount.json' assert {
|
|
11
|
+
type: 'json'
|
|
12
|
+
};
|
|
13
|
+
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
14
|
+
export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractJson);
|
|
15
|
+
/**
|
|
16
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
17
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
18
|
+
* Eagerly loads the contract artifact
|
|
19
|
+
*/ export class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
20
|
+
constructor(signingPrivateKey){
|
|
21
|
+
super(signingPrivateKey);
|
|
22
|
+
}
|
|
23
|
+
getContractArtifact() {
|
|
24
|
+
return Promise.resolve(SchnorrAccountContractArtifact);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
12
27
|
/**
|
|
13
28
|
* Creates an Account Manager that relies on a Grumpkin signing key for authentication.
|
|
14
29
|
* @param pxe - An PXE server instance.
|
|
@@ -16,8 +31,7 @@ export { SchnorrAccountContractArtifact } from './artifact.js';
|
|
|
16
31
|
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
17
32
|
* @param salt - Deployment salt.
|
|
18
33
|
* @returns An account manager initialized with the account contract and its deployment params
|
|
19
|
-
*/
|
|
20
|
-
export function getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt) {
|
|
34
|
+
*/ export function getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt) {
|
|
21
35
|
return AccountManager.create(pxe, secretKey, new SchnorrAccountContract(signingPrivateKey), salt);
|
|
22
36
|
}
|
|
23
37
|
/**
|
|
@@ -26,8 +40,27 @@ export function getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt) {
|
|
|
26
40
|
* @param address - Address for the account.
|
|
27
41
|
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
28
42
|
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
29
|
-
*/
|
|
30
|
-
export function getSchnorrWallet(pxe, address, signingPrivateKey) {
|
|
43
|
+
*/ export function getSchnorrWallet(pxe, address, signingPrivateKey) {
|
|
31
44
|
return getWallet(pxe, address, new SchnorrAccountContract(signingPrivateKey));
|
|
32
45
|
}
|
|
33
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
48
|
+
* @param pxe - An PXE server instance.
|
|
49
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
50
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
51
|
+
* @param salt - Deployment salt.
|
|
52
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
53
|
+
*/ export async function getSchnorrWalletWithSecretKey(pxe, secretKey, signingPrivateKey, salt) {
|
|
54
|
+
const account = await getSchnorrAccount(pxe, secretKey, signingPrivateKey, salt);
|
|
55
|
+
return account.getWallet();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Compute the address of a schnorr account contract.
|
|
59
|
+
* @param secret - A seed for deriving the signing key and public keys.
|
|
60
|
+
* @param salt - The contract address salt.
|
|
61
|
+
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
62
|
+
*/ export async function getSchnorrAccountContractAddress(secret, salt, signingPrivateKey) {
|
|
63
|
+
const signingKey = signingPrivateKey ?? deriveSigningKey(secret);
|
|
64
|
+
const accountContract = new SchnorrAccountContract(signingKey);
|
|
65
|
+
return await getAccountContractAddress(accountContract, secret, salt);
|
|
66
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `@aztec/accounts/schnorr` export provides an account contract implementation that uses Schnorr signatures with a Grumpkin key for authentication, and a separate Grumpkin key for encryption.
|
|
3
|
+
* This is the suggested account contract type for most use cases within Aztec.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import { AccountManager, type Salt } from '@aztec/aztec.js/account';
|
|
8
|
+
import { type AccountWallet, type AccountWalletWithSecretKey } from '@aztec/aztec.js/wallet';
|
|
9
|
+
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
10
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
11
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
12
|
+
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
13
|
+
import { SchnorrBaseAccountContract } from './account_contract.js';
|
|
14
|
+
/**
|
|
15
|
+
* Lazily loads the contract artifact
|
|
16
|
+
* @returns The contract artifact for the schnorr account contract
|
|
17
|
+
*/
|
|
18
|
+
export declare function getSchnorrAccountContractArtifact(): Promise<ContractArtifact>;
|
|
19
|
+
/**
|
|
20
|
+
* Account contract that authenticates transactions using Schnorr signatures
|
|
21
|
+
* verified against a Grumpkin public key stored in an immutable encrypted note.
|
|
22
|
+
* Lazily loads the contract artifact
|
|
23
|
+
*/
|
|
24
|
+
export declare class SchnorrAccountContract extends SchnorrBaseAccountContract {
|
|
25
|
+
constructor(signingPrivateKey: GrumpkinScalar);
|
|
26
|
+
getContractArtifact(): Promise<ContractArtifact>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates an Account Manager that relies on a Grumpkin signing key for authentication.
|
|
30
|
+
* @param pxe - An PXE server instance.
|
|
31
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
32
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
33
|
+
* @param salt - Deployment salt.
|
|
34
|
+
* @returns An account manager initialized with the account contract and its deployment params
|
|
35
|
+
*/
|
|
36
|
+
export declare function getSchnorrAccount(pxe: PXE, secretKey: Fr, signingPrivateKey: GrumpkinScalar, salt?: Salt): Promise<AccountManager>;
|
|
37
|
+
/**
|
|
38
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
39
|
+
* @param pxe - An PXE server instance.
|
|
40
|
+
* @param address - Address for the account.
|
|
41
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
42
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getSchnorrWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: GrumpkinScalar): Promise<AccountWallet>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets a wallet for an already registered account using Schnorr signatures.
|
|
47
|
+
* @param pxe - An PXE server instance.
|
|
48
|
+
* @param secretKey - Secret key used to derive all the keystore keys.
|
|
49
|
+
* @param signingPrivateKey - Grumpkin key used for signing transactions.
|
|
50
|
+
* @param salt - Deployment salt.
|
|
51
|
+
* @returns A wallet for this account that can be used to interact with a contract instance.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getSchnorrWalletWithSecretKey(pxe: PXE, secretKey: Fr, signingPrivateKey: GrumpkinScalar, salt: Salt): Promise<AccountWalletWithSecretKey>;
|
|
54
|
+
/**
|
|
55
|
+
* Compute the address of a schnorr account contract.
|
|
56
|
+
* @param secret - A seed for deriving the signing key and public keys.
|
|
57
|
+
* @param salt - The contract address salt.
|
|
58
|
+
* @param signingPrivateKey - A specific signing private key that's not derived from the secret.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getSchnorrAccountContractAddress(secret: Fr, salt: Fr, signingPrivateKey?: GrumpkinScalar): Promise<AztecAddress>;
|
|
61
|
+
//# sourceMappingURL=lazy.d.ts.map
|