Skip to content

Commit 94a7911

Browse files
authored
chore: granular crypto imports (#18859)
As title. A push to fix cli startup times. This is one of several import granularization efforts. At the end of it all we can at least print the cli help in 0.5s. I propose the following: * We **remove barrel imports**. So no more `index.ts` that's just a list of `export * from 'foo'`. * In any project, there are files that are deemed part of the public api (they were exported directly or indirectly via the barrel import), and there are files that are not deemed part of the public api. * Any file that is deemed part of the public api is exported directly through the `package.json` `export` api. If it's good enough to be exported through a barrel, it's good enough to have it's own export on the package. * This will make it *explicit and clear* what we're presenting as the packages public api. * It makes it easier to trivially time the importation of each entrypoint for debugging slow stuff. * It makes it easier to see messy apis and take action to clean them up.
2 parents f8068c5 + f58ebe2 commit 94a7911

File tree

201 files changed

+376
-337
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+376
-337
lines changed

boxes/boxes/vanilla/app/embedded-wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { type FeeOptions, BaseWallet } from '@aztec/wallet-sdk/base-wallet';
1414
import { SPONSORED_FPC_SALT } from '@aztec/constants';
1515
import type { FieldsOf } from '@aztec/foundation/types';
16-
import { randomBytes } from '@aztec/foundation/crypto';
16+
import { randomBytes } from '@aztec/foundation/crypto/random';
1717
import { EcdsaRAccountContract } from '@aztec/accounts/ecdsa/lazy';
1818
import { SchnorrAccountContract } from '@aztec/accounts/schnorr/lazy';
1919

docs/docs/developers/docs/resources/migration_notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All note struct fields are now public, and the `new()` constructor methods and g
1616
The motivation for this change has been enshrining of randomness which lead to the `new` method being unnecessary boilerplate.
1717

1818
**Affected notes:**
19+
1920
- `UintNote` - `value` is now public, `new()` and `get_value()` removed
2021
- `AddressNote` - `address` is now public, `new()` and `get_address()` removed
2122
- `FieldNote` - `value` is now public, `new()` and `value()` removed
@@ -571,6 +572,7 @@ Having the recipient in the return value has been redundant as the same outcome
571572
#### Changes to `getPrivateEvents`
572573

573574
The signature of `getPrivateEvents` has changed for two reasons:
575+
574576
1. To align it with how other query methods that include filtering by block range work (for example, `AztecNode#getPublicLogs`)
575577
2. To enrich the returned private events with metadata.
576578

@@ -627,7 +629,6 @@ Also note we're replacing _recipient_ terminology with _scope_. While underlying
627629

628630
Please refer to the wallet interface js-docs for further details.
629631

630-
631632
### [CLI] Command refactor
632633

633634
The sandbox command has been renamed and remapped to "local network". We believe this conveys better what is actually being spun up when running it.

playground/src/components/home/components/Landing.tsx

Lines changed: 120 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Box, Button, CircularProgress, Tooltip } from '@mui/material';
99
import { AztecContext } from '../../../aztecContext';
1010
import { useContext, useEffect, useState } from 'react';
1111
import { PREDEFINED_CONTRACTS } from '../../../constants';
12-
import { randomBytes } from '@aztec/foundation/crypto';
12+
import { randomBytes } from '@aztec/foundation/crypto/random';
1313
import { loadContractArtifact } from '@aztec/aztec.js/abi';
1414
import { useTransaction } from '../../../hooks/useTransaction';
1515
import {
@@ -429,127 +429,133 @@ export function Landing() {
429429
<div css={container}>
430430
<div css={contentScroll}>
431431
<div css={welcomeCardContainer}>
432-
<div css={featureCard}>
433-
<div>
434-
<div css={cardTitle}>Deploy Privacy-Preserving Smart Contracts</div>
435-
<div css={cardDescription}>
436-
Get started deploying and interacting with smart contracts on Aztec. Create an aztec account, try one of
437-
our default contracts or upload your own and interact with public and private functions made possible by
438-
client-side ZK proofs created in your browser.
432+
<div css={featureCard}>
433+
<div>
434+
<div css={cardTitle}>Deploy Privacy-Preserving Smart Contracts</div>
435+
<div css={cardDescription}>
436+
Get started deploying and interacting with smart contracts on Aztec. Create an aztec account, try one of
437+
our default contracts or upload your own and interact with public and private functions made possible by
438+
client-side ZK proofs created in your browser.
439+
</div>
440+
</div>
441+
<div
442+
style={{
443+
width: '40%',
444+
display: 'flex',
445+
justifyContent: 'center',
446+
alignItems: 'center',
447+
marginLeft: '1rem',
448+
}}
449+
>
450+
<img src={welcomeIconURL} alt="Welcome visualization" style={{ maxWidth: '100%', maxHeight: '140px' }} />
439451
</div>
440-
</div>
441-
<div
442-
style={{
443-
width: '40%',
444-
display: 'flex',
445-
justifyContent: 'center',
446-
alignItems: 'center',
447-
marginLeft: '1rem',
448-
}}
449-
>
450-
<img src={welcomeIconURL} alt="Welcome visualization" style={{ maxWidth: '100%', maxHeight: '140px' }} />
451452
</div>
452453
</div>
453-
</div>
454454

455-
<div css={cardsContainer}>
456-
<div css={featureCard}>
457-
<Box>
458-
<div css={cardIcon}>
459-
<AccountAbstractionIcon />
460-
</div>
461-
<div css={cardTitle}>Account Abstraction</div>
462-
<div css={cardDescription}>
463-
Aztec's native account abstraction turns every account into a smart contract, enabling highly flexible and
464-
programmable user identities that unlock features like gas sponsorship, nonce abstraction (setting your
465-
own tx ordering), and the use of alternative signature schemes to control smart contracts with e.g.
466-
passkeys.{' '}
467-
</div>
468-
</Box>
469-
470-
<Tooltip
471-
title={
472-
!wallet || !embeddedWalletSelected ? 'Connect to a network and use a wallet to create an account' : ''
473-
}
474-
placement="top"
475-
>
476-
<span>
477-
<Button
478-
variant="contained"
479-
css={cardButton}
480-
onClick={handleCreateAccountButtonClick}
481-
disabled={isCreatingAccount || !wallet}
482-
>
483-
{isCreatingAccount ? <CircularProgress size={20} sx={{ color: 'white' }} /> : 'Create Account'}
484-
</Button>
485-
</span>
486-
</Tooltip>
487-
</div>
455+
<div css={cardsContainer}>
456+
<div css={featureCard}>
457+
<Box>
458+
<div css={cardIcon}>
459+
<AccountAbstractionIcon />
460+
</div>
461+
<div css={cardTitle}>Account Abstraction</div>
462+
<div css={cardDescription}>
463+
Aztec's native account abstraction turns every account into a smart contract, enabling highly flexible
464+
and programmable user identities that unlock features like gas sponsorship, nonce abstraction (setting
465+
your own tx ordering), and the use of alternative signature schemes to control smart contracts with e.g.
466+
passkeys.{' '}
467+
</div>
468+
</Box>
469+
470+
<Tooltip
471+
title={
472+
!wallet || !embeddedWalletSelected ? 'Connect to a network and use a wallet to create an account' : ''
473+
}
474+
placement="top"
475+
>
476+
<span>
477+
<Button
478+
variant="contained"
479+
css={cardButton}
480+
onClick={handleCreateAccountButtonClick}
481+
disabled={isCreatingAccount || !wallet}
482+
>
483+
{isCreatingAccount ? <CircularProgress size={20} sx={{ color: 'white' }} /> : 'Create Account'}
484+
</Button>
485+
</span>
486+
</Tooltip>
487+
</div>
488488

489-
<div css={featureCard}>
490-
<Box>
491-
<div css={cardIcon}>
492-
<PrivateVotingIcon />
493-
</div>
494-
<div css={cardTitle}>Private Voting</div>
495-
<div css={cardDescription}>
496-
Developers can seamlessly integrate public and private functions to unlock use cases like private voting.
497-
Voters can hide their address and cast their votes privately through a private function, which internally
498-
calls a public function to update the vote count transparently.{' '}
499-
</div>
500-
</Box>
501-
502-
<Tooltip title={!wallet ? 'Connect and account to deploy and interact with a contract' : ''} placement="top">
503-
<span>
504-
<Button
505-
variant="contained"
506-
css={cardButton}
507-
onClick={async () => {
508-
setIsLoadingPrivateVoting(true);
509-
await handleContractButtonClick(PREDEFINED_CONTRACTS.SIMPLE_VOTING);
510-
setIsLoadingPrivateVoting(false);
511-
}}
512-
disabled={isLoadingPrivateVoting || !wallet || isCreatingAccount}
513-
>
514-
{isLoadingPrivateVoting ? <CircularProgress size={20} sx={{ color: 'white' }} /> : 'Check it out'}
515-
</Button>
516-
</span>
517-
</Tooltip>
518-
</div>
489+
<div css={featureCard}>
490+
<Box>
491+
<div css={cardIcon}>
492+
<PrivateVotingIcon />
493+
</div>
494+
<div css={cardTitle}>Private Voting</div>
495+
<div css={cardDescription}>
496+
Developers can seamlessly integrate public and private functions to unlock use cases like private
497+
voting. Voters can hide their address and cast their votes privately through a private function, which
498+
internally calls a public function to update the vote count transparently.{' '}
499+
</div>
500+
</Box>
501+
502+
<Tooltip
503+
title={!wallet ? 'Connect and account to deploy and interact with a contract' : ''}
504+
placement="top"
505+
>
506+
<span>
507+
<Button
508+
variant="contained"
509+
css={cardButton}
510+
onClick={async () => {
511+
setIsLoadingPrivateVoting(true);
512+
await handleContractButtonClick(PREDEFINED_CONTRACTS.SIMPLE_VOTING);
513+
setIsLoadingPrivateVoting(false);
514+
}}
515+
disabled={isLoadingPrivateVoting || !wallet || isCreatingAccount}
516+
>
517+
{isLoadingPrivateVoting ? <CircularProgress size={20} sx={{ color: 'white' }} /> : 'Check it out'}
518+
</Button>
519+
</span>
520+
</Tooltip>
521+
</div>
519522

520-
<div css={featureCard}>
521-
<Box>
522-
<div css={cardIcon}>
523-
<PrivateTokensIcon />
524-
</div>
525-
<div css={cardTitle}>Private Tokens</div>
526-
<div css={cardDescription}>
527-
Accounts, transactions, and execution on Aztec can be done privately using client-side proofs, enabling
528-
you to private mint or transfer tokens, move public tokens into private domain or the reverse - transfer
529-
tokens from private to public, all without revealing your address or even the amount and recipient (in
530-
case of private transfer), all the while maintaining the total supply of tokens publicly.
531-
</div>
532-
</Box>
533-
534-
<Tooltip title={!wallet ? 'Connect and account to deploy and interact with a contract' : ''} placement="top">
535-
<span>
536-
<Button
537-
variant="contained"
538-
css={cardButton}
539-
onClick={async () => {
540-
setIsLoadingPrivateTokens(true);
541-
await handleContractButtonClick(PREDEFINED_CONTRACTS.SIMPLE_TOKEN);
542-
setIsLoadingPrivateTokens(false);
543-
}}
544-
disabled={isLoadingPrivateTokens || !wallet || isCreatingAccount}
545-
>
546-
{isLoadingPrivateTokens ? <CircularProgress size={20} sx={{ color: 'white' }} /> : 'Check it out'}
547-
</Button>
548-
</span>
549-
</Tooltip>
523+
<div css={featureCard}>
524+
<Box>
525+
<div css={cardIcon}>
526+
<PrivateTokensIcon />
527+
</div>
528+
<div css={cardTitle}>Private Tokens</div>
529+
<div css={cardDescription}>
530+
Accounts, transactions, and execution on Aztec can be done privately using client-side proofs, enabling
531+
you to private mint or transfer tokens, move public tokens into private domain or the reverse - transfer
532+
tokens from private to public, all without revealing your address or even the amount and recipient (in
533+
case of private transfer), all the while maintaining the total supply of tokens publicly.
534+
</div>
535+
</Box>
536+
537+
<Tooltip
538+
title={!wallet ? 'Connect and account to deploy and interact with a contract' : ''}
539+
placement="top"
540+
>
541+
<span>
542+
<Button
543+
variant="contained"
544+
css={cardButton}
545+
onClick={async () => {
546+
setIsLoadingPrivateTokens(true);
547+
await handleContractButtonClick(PREDEFINED_CONTRACTS.SIMPLE_TOKEN);
548+
setIsLoadingPrivateTokens(false);
549+
}}
550+
disabled={isLoadingPrivateTokens || !wallet || isCreatingAccount}
551+
>
552+
{isLoadingPrivateTokens ? <CircularProgress size={20} sx={{ color: 'white' }} /> : 'Check it out'}
553+
</Button>
554+
</span>
555+
</Tooltip>
556+
</div>
550557
</div>
551558
</div>
552-
</div>
553559
</div>
554560
);
555561
}

playground/src/wallet/components/CreateAccountDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import FormControl from '@mui/material/FormControl';
1212
import Select from '@mui/material/Select';
1313
import MenuItem from '@mui/material/MenuItem';
1414
import type { AccountType } from '../wallet_db';
15-
import { randomBytes } from '@aztec/foundation/crypto';
15+
import { randomBytes } from '@aztec/foundation/crypto/random';
1616
import { FeePaymentSelector } from '../../components/common/FeePaymentSelector';
1717
import CircularProgress from '@mui/material/CircularProgress';
1818
import InputLabel from '@mui/material/InputLabel';

yarn-project/accounts/src/ecdsa/ecdsa_k/account_contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2-
import { Ecdsa } from '@aztec/foundation/crypto';
2+
import { Ecdsa } from '@aztec/foundation/crypto/ecdsa';
33
import type { Fr } from '@aztec/foundation/curves/bn254';
44
import { AuthWitness } from '@aztec/stdlib/auth-witness';
55
import { CompleteAddress } from '@aztec/stdlib/contract';

yarn-project/accounts/src/ecdsa/ecdsa_r/account_contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2-
import { Ecdsa } from '@aztec/foundation/crypto';
2+
import { Ecdsa } from '@aztec/foundation/crypto/ecdsa';
33
import type { Fr } from '@aztec/foundation/curves/bn254';
44
import { AuthWitness } from '@aztec/stdlib/auth-witness';
55
import { CompleteAddress } from '@aztec/stdlib/contract';

yarn-project/accounts/src/ecdsa/ssh_ecdsa_r/account_contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2-
import { EcdsaSignature } from '@aztec/foundation/crypto';
2+
import { EcdsaSignature } from '@aztec/foundation/crypto/ecdsa';
33
import type { Fr } from '@aztec/foundation/curves/bn254';
44
import { AuthWitness } from '@aztec/stdlib/auth-witness';
55
import { CompleteAddress } from '@aztec/stdlib/contract';

yarn-project/accounts/src/schnorr/account_contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2-
import { Schnorr } from '@aztec/foundation/crypto';
2+
import { Schnorr } from '@aztec/foundation/crypto/schnorr';
33
import { Fr } from '@aztec/foundation/curves/bn254';
44
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
55
import { AuthWitness } from '@aztec/stdlib/auth-witness';

yarn-project/accounts/src/single_key/account_contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AuthWitnessProvider } from '@aztec/aztec.js/account';
2-
import { Schnorr } from '@aztec/foundation/crypto';
2+
import { Schnorr } from '@aztec/foundation/crypto/schnorr';
33
import type { Fr } from '@aztec/foundation/curves/bn254';
44
import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
55
import { AuthWitness } from '@aztec/stdlib/auth-witness';

yarn-project/archiver/src/archiver/archiver.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { DefaultL1ContractsConfig, InboxContract, RollupContract, type ViemPubli
88
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
99
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
1010
import { times } from '@aztec/foundation/collection';
11-
import { Secp256k1Signer } from '@aztec/foundation/crypto';
11+
import { Secp256k1Signer } from '@aztec/foundation/crypto/secp256k1-signer';
1212
import { Fr } from '@aztec/foundation/curves/bn254';
1313
import { EthAddress } from '@aztec/foundation/eth-address';
1414
import { type Logger, createLogger } from '@aztec/foundation/log';

0 commit comments

Comments
 (0)