Skip to content

Commit a7531b3

Browse files
committed
get rid of "deriveSigningKey"
1 parent 5bc8a62 commit a7531b3

File tree

7 files changed

+44
-32
lines changed

7 files changed

+44
-32
lines changed

β€Ž.github/workflows/tests.yamlβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Run tests
5555
run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test"
5656

57-
- name: Deploy account and capture SECRET/SALT
57+
- name: Deploy account and capture SECRET/SIGNING_KEY/SALT
5858
run: |
5959
script -e -c "yarn clear-store"
6060
# Create a temporary file to store the output
@@ -73,24 +73,27 @@ jobs:
7373
# Show the full output for debugging
7474
cat "$TEMP_OUTPUT"
7575
76-
# Extract SECRET and SALT from the output
76+
# Extract SECRET, SIGNING_KEY, and SALT from the output
7777
SECRET_KEY=$(grep -o "πŸ”‘ Secret key generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/πŸ”‘ Secret key generated: //' || echo "")
78+
SIGNING_KEY=$(grep -o "πŸ–ŠοΈ Signing key generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/πŸ–ŠοΈ Signing key generated: //' || echo "")
7879
SALT_VALUE=$(grep -o "πŸ§‚ Salt generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/πŸ§‚ Salt generated: //' || echo "")
7980
8081
# Clean up temp file
8182
rm "$TEMP_OUTPUT"
8283
8384
# Validate and create .env file
84-
if [ -n "$SECRET_KEY" ] && [ -n "$SALT_VALUE" ]; then
85+
if [ -n "$SECRET_KEY" ] && [ -n "$SIGNING_KEY" ] && [ -n "$SALT_VALUE" ]; then
8586
8687
# Create .env file with all necessary values
8788
echo "SECRET=\"$SECRET_KEY\"" >> .env
89+
echo "SIGNING_KEY=\"$SIGNING_KEY\"" >> .env
8890
echo "SALT=\"$SALT_VALUE\"" >> .env
8991
echo "πŸ“‹ Current .env file contents:"
9092
cat .env
9193
else
92-
echo "❌ Failed to extract SECRET and/or SALT from deploy output"
94+
echo "❌ Failed to extract SECRET, SIGNING_KEY and/or SALT from deploy output"
9395
echo "πŸ” SECRET_KEY: '$SECRET_KEY'"
96+
echo "πŸ” SIGNING_KEY: '$SIGNING_KEY'"
9497
echo "πŸ” SALT_VALUE: '$SALT_VALUE'"
9598
exit 1
9699
fi

β€Žscripts/fees.tsβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ import { getDeployedSponsoredFPCAddress, getSponsoredFPCInstance } from "../src/
1414
import { createEthereumChain, createExtendedL1Client } from "@aztec/ethereum";
1515
import { deploySchnorrAccount } from "../src/utils/deploy_account.js";
1616
import { setupPXE } from "../src/utils/setup_pxe.js";
17-
import { createLogger, FeeJuicePaymentMethod, FeeJuicePaymentMethodWithClaim, Fr, L1FeeJuicePortalManager, Logger, PrivateFeePaymentMethod, PublicFeePaymentMethod, PXE } from '@aztec/aztec.js';
17+
import { createLogger, FeeJuicePaymentMethod, FeeJuicePaymentMethodWithClaim, Fq, Fr, L1FeeJuicePortalManager, Logger, PrivateFeePaymentMethod, PublicFeePaymentMethod, PXE } from '@aztec/aztec.js';
1818
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
1919
import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
2020
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
21-
import { deriveSigningKey } from '@aztec/stdlib/keys';
2221

2322
const MNEMONIC = 'test test test test test test test test test test test junk';
2423
const FEE_FUNDING_FOR_TESTER_ACCOUNT = 1000000000000000000000n;
@@ -43,8 +42,9 @@ async function main() {
4342
const wallet1 = await account1.getWallet();
4443

4544
let secretKey = Fr.random();
45+
let signingKey = Fq.random();
4646
let salt = Fr.random();
47-
let account2 = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
47+
let account2 = await getSchnorrAccount(pxe, secretKey, signingKey, salt);
4848
const wallet2 = await account2.getWallet();
4949
const feeJuiceRecipient = account2.getAddress();
5050

β€Žscripts/multiple_pxe.tsβ€Ž

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { waitForPXE, getContractInstanceFromInstantiationParams, Fr, ContractInstanceWithAddress, AztecAddress, SponsoredFeePaymentMethod, createAztecNodeClient } from "@aztec/aztec.js";
1+
import { waitForPXE, getContractInstanceFromInstantiationParams, Fr, ContractInstanceWithAddress, AztecAddress, SponsoredFeePaymentMethod, createAztecNodeClient, Fq } from "@aztec/aztec.js";
22
import { TokenContract } from "@aztec/noir-contracts.js/Token"
33
import { getSponsoredFPCInstance } from "../src/utils/sponsored_fpc.js";
4-
import { deriveSigningKey } from "@aztec/stdlib/keys";
54
import { getSchnorrAccount } from "@aztec/accounts/schnorr";
65
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
76
import { createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
@@ -25,13 +24,13 @@ const store2 = await createStore('pxe2', {
2524
});
2625

2726
const setupPxe1 = async () => {
28-
const pxe = await createPXEService(node, fullConfig, {store: store1});
27+
const pxe = await createPXEService(node, fullConfig, { store: store1 });
2928
await waitForPXE(pxe);
3029
return pxe;
3130
};
3231

3332
const setupPxe2 = async () => {
34-
const pxe = await createPXEService(node, fullConfig, {store: store2});
33+
const pxe = await createPXEService(node, fullConfig, { store: store2 });
3534
await waitForPXE(pxe);
3635
return pxe;
3736
};
@@ -65,8 +64,9 @@ async function main() {
6564
// deploy token contract
6665

6766
let secretKey = Fr.random();
67+
let signingKey = Fq.random();
6868
let salt = Fr.random();
69-
let schnorrAccount = await getSchnorrAccount(pxe1, secretKey, deriveSigningKey(secretKey), salt);
69+
let schnorrAccount = await getSchnorrAccount(pxe1, secretKey, signingKey, salt);
7070
let tx = await schnorrAccount.deploy({ fee: { paymentMethod } }).wait();
7171
let ownerWallet = await schnorrAccount.getWallet();
7272
let ownerAddress = ownerWallet.getAddress();
@@ -81,8 +81,9 @@ async function main() {
8181
await pxe2.registerSender(ownerAddress)
8282

8383
let secretKey2 = Fr.random();
84+
let signingKey2 = Fq.random();
8485
let salt2 = Fr.random();
85-
let schnorrAccount2 = await getSchnorrAccount(pxe2, secretKey2, deriveSigningKey(secretKey2), salt2);
86+
let schnorrAccount2 = await getSchnorrAccount(pxe2, secretKey2, signingKey2, salt2);
8687

8788
// deploy account on 2nd pxe
8889
let tx2 = await schnorrAccount2.deploy({ fee: { paymentMethod } }).wait();

β€Žsrc/test/e2e/accounts.test.tsβ€Ž

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { PrivateVotingContractArtifact, PrivateVotingContract } from "../../artifacts/PrivateVoting.js"
2-
import { AccountManager, AccountWallet, ContractDeployer, createLogger, Fr, PXE, TxStatus, getContractInstanceFromInstantiationParams, Logger } from "@aztec/aztec.js";
2+
import { AccountManager, AccountWallet, ContractDeployer, createLogger, Fr, PXE, TxStatus, getContractInstanceFromInstantiationParams, Logger, Fq } from "@aztec/aztec.js";
33
import { generateSchnorrAccounts } from "@aztec/accounts/testing"
44
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
55
import { spawn, spawnSync } from 'child_process';
6-
import { deriveSigningKey } from '@aztec/stdlib/keys';
76

87
import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing";
98
import { getFeeJuiceBalance, type L2AmountClaim, L1FeeJuicePortalManager, FeeJuicePaymentMethodWithClaim, AztecAddress } from "@aztec/aztec.js";
109
import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
1110
import { getSponsoredFPCInstance } from "../../utils/sponsored_fpc.js";
1211
import { setupPXE } from "../../utils/setup_pxe.js";
1312
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
13+
import { sign } from "crypto";
1414

1515
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
1616

@@ -73,8 +73,9 @@ describe("Accounts", () => {
7373
);
7474

7575
let secretKey = Fr.random();
76+
let signingKey = Fq.random();
7677
let salt = Fr.random();
77-
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt)
78+
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, signingKey, salt)
7879
await schnorrAccount.deploy({ fee: { paymentMethod: sponsoredPaymentMethod } }).wait();
7980
ownerWallet = await schnorrAccount.getWallet();
8081
})

β€Žsrc/test/e2e/index.test.tsβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PrivateVotingContractArtifact, PrivateVotingContract } from "../../artifacts/PrivateVoting.js"
2-
import { AccountWallet, ContractDeployer, createLogger, Fr, PXE, TxStatus, getContractInstanceFromInstantiationParams, Logger, ContractInstanceWithAddress } from "@aztec/aztec.js";
2+
import { AccountWallet, ContractDeployer, createLogger, Fr, PXE, TxStatus, getContractInstanceFromInstantiationParams, Logger, ContractInstanceWithAddress, Fq } from "@aztec/aztec.js";
33
import { generateSchnorrAccounts } from "@aztec/accounts/testing"
44
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
55
import { spawn, spawnSync } from 'child_process';
@@ -9,7 +9,6 @@ import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
99
import { getSponsoredFPCInstance } from "../../utils/sponsored_fpc.js";
1010
import { setupPXE } from "../../utils/setup_pxe.js";
1111
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
12-
import { deriveSigningKey } from "@aztec/stdlib/keys";
1312

1413
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
1514

@@ -47,8 +46,9 @@ describe("Voting", () => {
4746

4847
// Set up a wallet
4948
let secretKey = Fr.random();
49+
let signingKey = Fq.random();
5050
let salt = Fr.random();
51-
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt)
51+
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, signingKey, salt)
5252
await schnorrAccount.deploy({ fee: { paymentMethod: sponsoredPaymentMethod } }).wait();
5353
firstWallet = await schnorrAccount.getWallet();
5454
const existingSenders = await pxe.getSenders();

β€Žsrc/utils/create_account_from_env.tsβ€Ž

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { createLogger, Fr, PXE, Logger, AccountManager } from "@aztec/aztec.js";
1+
import { createLogger, Fr, PXE, Logger, AccountManager, Fq } from "@aztec/aztec.js";
22
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
3-
import { deriveSigningKey } from '@aztec/stdlib/keys';
43
import * as dotenv from 'dotenv';
54

65
// Load environment variables
@@ -14,22 +13,29 @@ export async function createAccountFromEnv(pxe: PXE): Promise<AccountManager> {
1413

1514
// Read SECRET and SALT from environment variables
1615
const secretEnv = process.env.SECRET;
16+
const signingKeyEnv = process.env.SIGNING_KEY;
1717
const saltEnv = process.env.SALT;
1818

1919
if (!secretEnv) {
2020
throw new Error('SECRET environment variable is required. Please set it in your .env file.');
2121
}
2222

23+
if (!signingKeyEnv) {
24+
throw new Error('SIGNING_KEY environment variable is required. Please set it in your .env file.');
25+
}
26+
2327
if (!saltEnv) {
2428
throw new Error('SALT environment variable is required. Please set it in your .env file.');
2529
}
2630

2731
// Convert hex strings to Fr values
2832
let secretKey: Fr;
33+
let signingKey: Fq;
2934
let salt: Fr;
3035

3136
try {
3237
secretKey = Fr.fromString(secretEnv);
38+
signingKey = Fq.fromString(signingKeyEnv);
3339
salt = Fr.fromString(saltEnv);
3440
logger.info('βœ… Successfully parsed SECRET and SALT values');
3541
} catch (error) {
@@ -39,7 +45,7 @@ export async function createAccountFromEnv(pxe: PXE): Promise<AccountManager> {
3945

4046
// Create Schnorr account with specified values
4147
logger.info('πŸ—οΈ Creating Schnorr account instance with environment values...');
42-
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
48+
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, signingKey, salt);
4349
const accountAddress = schnorrAccount.getAddress();
4450
logger.info(`πŸ“ Account address: ${accountAddress}`);
4551

@@ -48,7 +54,7 @@ export async function createAccountFromEnv(pxe: PXE): Promise<AccountManager> {
4854
try {
4955
const registeredAccounts = await pxe.getRegisteredAccounts();
5056
const isRegistered = registeredAccounts.some(acc => acc.address.equals(accountAddress));
51-
57+
5258
if (isRegistered) {
5359
logger.info('βœ… Account is already registered with PXE');
5460
} else {

β€Žsrc/utils/deploy_account.tsβ€Ž

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import { createLogger, Fr, PXE, Logger, AccountManager } from "@aztec/aztec.js";
1+
import { createLogger, Fr, PXE, Logger, AccountManager, Fq } from "@aztec/aztec.js";
22
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
3-
import { deriveSigningKey } from '@aztec/stdlib/keys';
43
import { SponsoredFeePaymentMethod } from "@aztec/aztec.js/fee/testing";
54
import { getSponsoredFPCInstance } from "./sponsored_fpc.js";
65
import { SponsoredFPCContract } from "@aztec/noir-contracts.js/SponsoredFPC";
76

87
export async function deploySchnorrAccount(pxe: PXE): Promise<AccountManager> {
98
let logger: Logger;
109
logger = createLogger('aztec:aztec-starter');
11-
10+
1211
logger.info('πŸ‘€ Starting Schnorr account deployment...');
1312

1413
// Setup sponsored FPC
1514
logger.info('πŸ’° Setting up sponsored fee payment for account deployment...');
1615
const sponsoredFPC = await getSponsoredFPCInstance();
1716
logger.info(`πŸ’° Sponsored FPC instance obtained at: ${sponsoredFPC.address}`);
18-
17+
1918
logger.info('πŸ“ Registering sponsored FPC contract with PXE...');
2019
await pxe.registerContract({ instance: sponsoredFPC, artifact: SponsoredFPCContract.artifact });
2120
const sponsoredPaymentMethod = new SponsoredFeePaymentMethod(sponsoredFPC.address);
@@ -24,24 +23,26 @@ export async function deploySchnorrAccount(pxe: PXE): Promise<AccountManager> {
2423
// Generate account keys
2524
logger.info('πŸ” Generating account keys...');
2625
let secretKey = Fr.random();
26+
let signingKey = Fq.random();
2727
let salt = Fr.random();
2828
logger.info(`Save the following SECRET and SALT in .env for future use.`);
2929
logger.info(`πŸ”‘ Secret key generated: ${secretKey.toString()}`);
30+
logger.info(`πŸ–ŠοΈ Signing key generated: ${signingKey.toString()}`);
3031
logger.info(`πŸ§‚ Salt generated: ${salt.toString()}`);
3132

3233
// Create Schnorr account
3334
logger.info('πŸ—οΈ Creating Schnorr account instance...');
34-
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
35+
let schnorrAccount = await getSchnorrAccount(pxe, secretKey, signingKey, salt);
3536
const accountAddress = schnorrAccount.getAddress();
3637
logger.info(`πŸ“ Account address will be: ${accountAddress}`);
3738

3839
// Deploy the account
3940
logger.info('πŸš€ Deploying account to the network...');
4041
logger.info('⏳ Waiting for account deployment transaction to be mined...');
41-
let tx = await schnorrAccount.deploy({
42-
fee: { paymentMethod: sponsoredPaymentMethod }
42+
let tx = await schnorrAccount.deploy({
43+
fee: { paymentMethod: sponsoredPaymentMethod }
4344
}).wait({ timeout: 120000 });
44-
45+
4546
logger.info(`βœ… Account deployment transaction successful!`);
4647
logger.info(`πŸ“‹ Transaction hash: ${tx.txHash}`);
4748

@@ -56,7 +57,7 @@ export async function deploySchnorrAccount(pxe: PXE): Promise<AccountManager> {
5657
try {
5758
const registeredAccounts = await pxe.getRegisteredAccounts();
5859
const isRegistered = registeredAccounts.some(acc => acc.address.equals(deployedAddress));
59-
60+
6061
if (isRegistered) {
6162
logger.info('βœ… Account successfully registered with PXE');
6263
} else {

0 commit comments

Comments
Β (0)