Aztec Snap is the first MetaMask Snap on Aztec that enables private function calls to any Aztec contract.
AztecSnap deterministically derives private keys from the existing seed phrase managed by Metamask via Snap's api call snap_getBip44Entropy to offer great security and UX for ethereum users.
More specifically, it currently uses the derived private key as a signing key for ECDSAAccountContract, while the encryption key is the one reduced from the same private key to a new valid grumpkin scalar value.
git clone git@github.com:porco-rosso-j/aztec-snap.gitcd .aztec
aztec-sandboxinstall dependencies:
yarnstart snap server:
cd packages/snap
yarn startstart frontend:
cd packages/site
yarn devThe current implementation is an app for managing AztecSnap Wallet. But you can build any frontend dapp modifying this directory.
This directory contains snap's backend source code.
aztec-snap-lib is a library that exports SnapWallet instance.
SnapWallet can be thought of as ethers's Signer intance that can be instantiated and used like following.
example:
import { AztecSnap, SnapWallet } from '@abstract-crypto/aztec-snap-lib';
const aztecSnap = new AztecSnap(pxe);
const wallet: SnapWallet = aztecSnap.connect();
const token = await TokenContract.at(
AztecAddress.fromString(TOKEN_ADDRESS),
wallet,
);
const sentTx: SentTx = await token.methods
.transfer_public(
AztecAddress.fromString(fromAddress),
AztecAddress.fromString(toAddress),
Number(amount),
0,
)
.send();
await sentTx.wait();