-
Notifications
You must be signed in to change notification settings - Fork 615
feat: client flows benchmarks #13007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0f25cd4
wip
Thunkar a5df874
wip
Thunkar 82b207b
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar e918bfc
wip
Thunkar 111bec4
wip
Thunkar ef096f3
first flow working
Thunkar f2e5357
add ECDSAR1 account
Thunkar 30e6cd2
better structure, bridging
Thunkar 52a45bc
transfer flows
Thunkar e3ccaec
wip
Thunkar 20e097f
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar b235696
add to bootstrap
Thunkar 77c0193
cleanup and comments from review
Thunkar f448290
more feedback and fixes
Thunkar 6f0dcf9
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar 770ea7f
final cleanup?
Thunkar 7254924
adjusted steps
Thunkar 3d5ad1a
fixes
Thunkar 99d31e5
removed comment
Thunkar f541fd5
fix
Thunkar cbd83ca
attempt to avoid oom
Thunkar f05c3b7
removed bench, added amm
Thunkar a0bbf4c
fmt
Thunkar da2c445
fixes
Thunkar 1895d3c
gated new profiling method
Thunkar 36c9057
gated new profiling method
Thunkar 3938b4c
data
Thunkar c2f1e36
more info on failures
Thunkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
yarn-project/accounts/src/ecdsa/ecdsa_r/account_contract.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import type { AuthWitnessProvider } from '@aztec/aztec.js/account'; | ||
| import { Ecdsa } from '@aztec/foundation/crypto'; | ||
| import type { Fr } from '@aztec/foundation/fields'; | ||
| import { AuthWitness } from '@aztec/stdlib/auth-witness'; | ||
| import { CompleteAddress } from '@aztec/stdlib/contract'; | ||
|
|
||
| import { DefaultAccountContract } from '../../defaults/account_contract.js'; | ||
|
|
||
| /** | ||
| * Account contract that authenticates transactions using ECDSA signatures | ||
| * verified against a secp256r1 public key stored in an immutable encrypted note. | ||
| * This abstract version does not provide a way to retrieve the artifact, as it | ||
| * can be implemented with or without lazy loading. | ||
| */ | ||
| export abstract class EcdsaRBaseAccountContract extends DefaultAccountContract { | ||
| constructor(private signingPrivateKey: Buffer) { | ||
| super(); | ||
| } | ||
|
|
||
| async getDeploymentFunctionAndArgs() { | ||
| const signingPublicKey = await new Ecdsa('secp256r1').computePublicKey(this.signingPrivateKey); | ||
| return { | ||
| constructorName: 'constructor', | ||
| constructorArgs: [signingPublicKey.subarray(0, 32), signingPublicKey.subarray(32, 64)], | ||
| }; | ||
| } | ||
|
|
||
| getAuthWitnessProvider(_address: CompleteAddress): AuthWitnessProvider { | ||
| return new EcdsaRAuthWitnessProvider(this.signingPrivateKey); | ||
| } | ||
| } | ||
|
|
||
| /** Creates auth witnesses using ECDSA signatures. */ | ||
| class EcdsaRAuthWitnessProvider implements AuthWitnessProvider { | ||
| constructor(private signingPrivateKey: Buffer) {} | ||
|
|
||
| async createAuthWit(messageHash: Fr): Promise<AuthWitness> { | ||
| const ecdsa = new Ecdsa('secp256r1'); | ||
| const signature = await ecdsa.constructSignature(messageHash.toBuffer(), this.signingPrivateKey); | ||
| return Promise.resolve(new AuthWitness(messageHash, [...signature.r, ...signature.s])); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /** | ||
| * 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. | ||
| * Consider using this account type when working with integrations with Ethereum wallets. | ||
| * | ||
| * @packageDocumentation | ||
| */ | ||
| import { AccountManager, type Salt } from '@aztec/aztec.js/account'; | ||
| import { type AccountWallet, getWallet } from '@aztec/aztec.js/wallet'; | ||
| import { Fr } from '@aztec/foundation/fields'; | ||
| import type { ContractArtifact } from '@aztec/stdlib/abi'; | ||
| import { loadContractArtifact } from '@aztec/stdlib/abi'; | ||
| import { AztecAddress } from '@aztec/stdlib/aztec-address'; | ||
| import type { PXE } from '@aztec/stdlib/interfaces/client'; | ||
| import type { NoirCompiledContract } from '@aztec/stdlib/noir'; | ||
|
|
||
| import EcdsaRAccountContractJson from '../../../artifacts/EcdsaRAccount.json' assert { type: 'json' }; | ||
| import { EcdsaRBaseAccountContract } from './account_contract.js'; | ||
|
|
||
| export const EcdsaRAccountContractArtifact: ContractArtifact = loadContractArtifact( | ||
| EcdsaRAccountContractJson as NoirCompiledContract, | ||
| ); | ||
|
|
||
| /** | ||
| * Account contract that authenticates transactions using ECDSA signatures | ||
| * verified against a secp256k1 public key stored in an immutable encrypted note. | ||
| * Eagerly loads the contract artifact | ||
| */ | ||
| export class EcdsaRAccountContract extends EcdsaRBaseAccountContract { | ||
| constructor(signingPrivateKey: Buffer) { | ||
| super(signingPrivateKey); | ||
| } | ||
|
|
||
| override getContractArtifact(): Promise<ContractArtifact> { | ||
| return Promise.resolve(EcdsaRAccountContractArtifact); | ||
| } | ||
| } | ||
| /** | ||
| * Creates an Account that relies on an ECDSA signing key for authentication. | ||
| * @param pxe - An PXE server instance. | ||
| * @param secretKey - Secret key used to derive all the keystore keys. | ||
| * @param signingPrivateKey - Secp256k1 key used for signing transactions. | ||
| * @param salt - Deployment salt. | ||
| * @returns An account manager initialized with the account contract and its deployment params | ||
| */ | ||
| export function getEcdsaRAccount( | ||
| pxe: PXE, | ||
| secretKey: Fr, | ||
| signingPrivateKey: Buffer, | ||
| salt?: Salt, | ||
| ): Promise<AccountManager> { | ||
| return AccountManager.create(pxe, secretKey, new EcdsaRAccountContract(signingPrivateKey), salt); | ||
| } | ||
|
|
||
| /** | ||
| * Gets a wallet for an already registered account using ECDSA signatures. | ||
| * @param pxe - An PXE server instance. | ||
| * @param address - Address for the account. | ||
| * @param signingPrivateKey - ECDSA key used for signing transactions. | ||
| * @returns A wallet for this account that can be used to interact with a contract instance. | ||
| */ | ||
| export function getEcdsaRWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet> { | ||
| return getWallet(pxe, address, new EcdsaRAccountContract(signingPrivateKey)); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /** | ||
| * 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. | ||
| * Consider using this account type when working with integrations with Ethereum wallets. | ||
| * | ||
| * @packageDocumentation | ||
| */ | ||
| import { AccountManager, type Salt } from '@aztec/aztec.js/account'; | ||
| import { type AccountWallet, getWallet } from '@aztec/aztec.js/wallet'; | ||
| import { Fr } from '@aztec/foundation/fields'; | ||
| import type { ContractArtifact } from '@aztec/stdlib/abi'; | ||
| import { loadContractArtifact } from '@aztec/stdlib/abi'; | ||
| import { AztecAddress } from '@aztec/stdlib/aztec-address'; | ||
| import type { PXE } from '@aztec/stdlib/interfaces/client'; | ||
|
|
||
| import { EcdsaRBaseAccountContract } from './account_contract.js'; | ||
|
|
||
| /** | ||
| * Lazily loads the contract artifact | ||
| * @returns The contract artifact for the ecdsa K account contract | ||
| */ | ||
| export async function getEcdsaRAccountContractArtifact() { | ||
| // Cannot assert this import as it's incompatible with browsers | ||
| // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json | ||
| // Use the new "with" syntax once supported by firefox | ||
| // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json | ||
| // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS | ||
| const { default: ecdsaKAccountContractJson } = await import('../../../artifacts/EcdsaRAccount.json'); | ||
| return loadContractArtifact(ecdsaKAccountContractJson); | ||
| } | ||
|
|
||
| /** | ||
| * Account contract that authenticates transactions using ECDSA signatures | ||
| * verified against a secp256k1 public key stored in an immutable encrypted note. | ||
| * Lazily loads the contract artifact | ||
| */ | ||
| export class EcdsaRAccountContract extends EcdsaRBaseAccountContract { | ||
| constructor(signingPrivateKey: Buffer) { | ||
| super(signingPrivateKey); | ||
| } | ||
|
|
||
| override getContractArtifact(): Promise<ContractArtifact> { | ||
| return getEcdsaRAccountContractArtifact(); | ||
| } | ||
| } | ||
| /** | ||
| * Creates an Account that relies on an ECDSA signing key for authentication. | ||
| * @param pxe - An PXE server instance. | ||
| * @param secretKey - Secret key used to derive all the keystore keys. | ||
| * @param signingPrivateKey - Secp256k1 key used for signing transactions. | ||
| * @param salt - Deployment salt. | ||
| * @returns An account manager initialized with the account contract and its deployment params | ||
| */ | ||
| export function getEcdsaRAccount( | ||
| pxe: PXE, | ||
| secretKey: Fr, | ||
| signingPrivateKey: Buffer, | ||
| salt?: Salt, | ||
| ): Promise<AccountManager> { | ||
| return AccountManager.create(pxe, secretKey, new EcdsaRAccountContract(signingPrivateKey), salt); | ||
| } | ||
|
|
||
| /** | ||
| * Gets a wallet for an already registered account using ECDSA signatures. | ||
| * @param pxe - An PXE server instance. | ||
| * @param address - Address for the account. | ||
| * @param signingPrivateKey - ECDSA key used for signing transactions. | ||
| * @returns A wallet for this account that can be used to interact with a contract instance. | ||
| */ | ||
| export function getEcdsaRWallet(pxe: PXE, address: AztecAddress, signingPrivateKey: Buffer): Promise<AccountWallet> { | ||
| return getWallet(pxe, address, new EcdsaRAccountContract(signingPrivateKey)); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from './ecdsa_k/index.js'; | ||
| export * from './ecdsa_r/index.js'; | ||
|
Thunkar marked this conversation as resolved.
|
||
| export * from './ssh_ecdsa_r/index.js'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from './ecdsa_k/lazy.js'; | ||
| export * from './ecdsa_r/lazy.js'; | ||
| export * from './ssh_ecdsa_r/lazy.js'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.