Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ curl -s https://install.aztec.network | bash

### 3. Set Aztec Version

The project uses Aztec version `v3.0.0-devnet.2`. Set it using:
The project uses Aztec version `v3.0.0-nightly.20251120`. Set it using:

```bash
aztec-up 3.0.0-devnet.2
docker tag aztecprotocol/aztec:3.0.0-devnet.2 aztecprotocol/aztec:latest # Temporary workaround for aztec-nargo issues
aztec-up 3.0.0-nightly.20251120
docker tag aztecprotocol/aztec:3.0.0-nightly.20251120 aztecprotocol/aztec:latest # Temporary workaround for aztec-nargo issues
```

## Development Setup
Expand Down
6 changes: 3 additions & 3 deletions contracts/proof_of_password/Nargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type = "contract"
authors = [""]

[dependencies]
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-devnet.2", directory = "noir-projects/aztec-nr/aztec" }
token = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-devnet.2", directory = "noir-projects/noir-contracts/contracts/app/token_contract" }
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-nightly.20251120", directory = "noir-projects/aztec-nr/aztec" }
token = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-nightly.20251120", directory = "noir-projects/noir-contracts/contracts/app/token_contract" }
poseidon = { tag = "v0.1.1", git = "https://github.com/noir-lang/poseidon" }
compressed_string = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-devnet.2", directory = "noir-projects/aztec-nr/compressed-string" }
compressed_string = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-nightly.20251120", directory = "noir-projects/aztec-nr/compressed-string" }
35 changes: 16 additions & 19 deletions contracts/proof_of_password/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ use aztec::macros::aztec;
pub contract ProofOfPassword {

use aztec::{
macros::{functions::{external, initializer, internal}, storage::storage},
macros::{functions::{external, initializer, only_self}, storage::storage},
oracle::notes::set_sender_for_tags,
protocol_types::{
address::AztecAddress,
hash::poseidon2_hash,
traits::{Serialize, ToField},
},
protocol_types::{address::AztecAddress, hash::poseidon2_hash, traits::{Serialize, ToField}},
state_vars::PublicImmutable,
};
use compressed_string::FieldCompressedString;
Expand All @@ -29,30 +25,31 @@ pub contract ProofOfPassword {
fn constructor(grego_coin_address: AztecAddress, password: str<31>) {
let field_compressed_str = FieldCompressedString::from_string(password);
let password_hash = poseidon2_hash(field_compressed_str.serialize());
ProofOfPassword::at(context.this_address())
._init_storage(grego_coin_address, password_hash)
.enqueue(&mut context);
self.enqueue(ProofOfPassword::at(self.address)._init_storage(
grego_coin_address,
password_hash,
));
}

#[external("public")]
#[internal]
#[only_self]
fn _init_storage(grego_coin_address: AztecAddress, password_hash: Field) {
storage.grego_coin_address.initialize(grego_coin_address);
storage.password_hash.initialize(password_hash);
self.storage.grego_coin_address.initialize(grego_coin_address);
self.storage.password_hash.initialize(password_hash);
}

#[external("private")]
fn check_password_and_mint(password: str<31>, to: AztecAddress) {
let field_compressed_str = FieldCompressedString::from_string(password);
let password_hash = storage.password_hash.read();
let password_hash = self.storage.password_hash.read();
assert(
poseidon2_hash(field_compressed_str.serialize()) == password_hash,
f"Invalid password {password}",
);

// Safety: PXE will enforce a sender for the tags of the notes created
// in the Token.mint function, but this one intented to be called by anyone
// that knows the passord, not necessarily the recipient. Chances are this fn
// that knows the passord, not necessarily the recipient. Chances are this fn
// will be invoked by the MultiCallEntrypoint protocol contract,
// which does not set a sender for tags.
// We intend the "to" of this function to claim the notes, so we're just calling
Expand All @@ -61,13 +58,13 @@ pub contract ProofOfPassword {
set_sender_for_tags(to);
}

let address = storage.grego_coin_address.read();
Token::at(address).mint_to_private(to, 1000).call(&mut context);
let address = self.storage.grego_coin_address.read();
self.call(Token::at(address).mint_to_private(to, 1000));

// Derive nullifier from sender and password. This is still a privacy leak, since
// Derive nullifier from sender and password. This is still a privacy leak, since
// knowing the password and an address is sufficient to know if someone has used this
// contract or not. But at least, they need the password
let nullifier = poseidon2_hash([to.to_field(), field_compressed_str.serialize()[0]]);
context.push_nullifier(nullifier);
let nullifier = poseidon2_hash([to.to_field(), field_compressed_str.serialize()[0]]);
self.context.push_nullifier(nullifier);
}
}
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"serve": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"copy:dependencies": "cd contracts && aztec-nargo check && WORKDIR=$(pwd) && cd $HOME/nargo/github.com/AztecProtocol/aztec-packages/v3.0.0-devnet.2/noir-projects/noir-contracts && aztec-nargo compile --package token_contract && cp $HOME/nargo/github.com/AztecProtocol/aztec-packages/v3.0.0-devnet.2/noir-projects/noir-contracts/target/token_contract-Token.json $WORKDIR/contracts/target/token_contract-Token.json",
"compile:contracts": "cd contracts && aztec-nargo compile && aztec-postprocess-contract && aztec codegen ./target/proof_of_password-ProofOfPassword.json",
"copy:dependencies": "cd contracts && aztec check && WORKDIR=$(pwd) && cd $HOME/nargo/github.com/AztecProtocol/aztec-packages/v3.0.0-nightly.20251120/noir-projects/noir-contracts && aztec compile --package token_contract && mkdir -p $WORKDIR/target && cp $HOME/nargo/github.com/AztecProtocol/aztec-packages/v3.0.0-nightly.20251120/noir-projects/noir-contracts/target/token_contract-Token.json $WORKDIR/target/token_contract-Token.json",
"compile:contracts": "cd contracts && aztec compile --package proof_of_password && aztec codegen ./target/proof_of_password-ProofOfPassword.json",
"test": "cd contracts && aztec test",
"preview": "vite preview",
"deploy:local": "node --experimental-transform-types scripts/deploy.ts --network local",
Expand All @@ -19,14 +19,14 @@
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src"
},
"dependencies": {
"@aztec/accounts": "v3.0.0-devnet.2",
"@aztec/aztec.js": "v3.0.0-devnet.2",
"@aztec/constants": "v3.0.0-devnet.2",
"@aztec/entrypoints": "v3.0.0-devnet.2",
"@aztec/foundation": "v3.0.0-devnet.2",
"@aztec/noir-contracts.js": "v3.0.0-devnet.2",
"@aztec/pxe": "v3.0.0-devnet.2",
"@aztec/stdlib": "v3.0.0-devnet.2",
"@aztec/accounts": "v3.0.0-nightly.20251120",
"@aztec/aztec.js": "v3.0.0-nightly.20251120",
"@aztec/constants": "v3.0.0-nightly.20251120",
"@aztec/entrypoints": "v3.0.0-nightly.20251120",
"@aztec/foundation": "v3.0.0-nightly.20251120",
"@aztec/noir-contracts.js": "v3.0.0-nightly.20251120",
"@aztec/pxe": "v3.0.0-nightly.20251120",
"@aztec/stdlib": "v3.0.0-nightly.20251120",
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@mui/icons-material": "^6.3.1",
Expand All @@ -39,7 +39,7 @@
"zod": "^3.23.8"
},
"devDependencies": {
"@aztec/test-wallet": "v3.0.0-devnet.2",
"@aztec/test-wallet": "v3.0.0-nightly.20251120",
"@eslint/js": "^9.18.0",
"@playwright/test": "1.49.0",
"@types/buffer-json": "^2",
Expand Down
8 changes: 4 additions & 4 deletions src/contexts/ContractsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ export function ContractsProvider({ children }: ContractsProviderProps) {
] as unknown as any);

// After registration, instantiate the contracts
const gregoCoinContract = await TokenContract.at(gregoCoinAddress, wallet);
const gregoCoinPremiumContract = await TokenContract.at(gregoCoinPremiumAddress, wallet);
const ammContract = await AMMContract.at(ammAddress, wallet);
const gregoCoinContract = TokenContract.at(gregoCoinAddress, wallet);
const gregoCoinPremiumContract = TokenContract.at(gregoCoinPremiumAddress, wallet);
const ammContract = AMMContract.at(ammAddress, wallet);

setGregoCoin(gregoCoinContract);
setGregoCoinPremium(gregoCoinPremiumContract);
Expand All @@ -213,7 +213,7 @@ export function ContractsProvider({ children }: ContractsProviderProps) {
]);

// After registration, instantiate the ProofOfPassword contract
const popContract = await ProofOfPasswordContract.at(popAddress, wallet);
const popContract = ProofOfPasswordContract.at(popAddress, wallet);
setPop(popContract);

setIsLoadingContracts(false);
Expand Down
7 changes: 3 additions & 4 deletions src/embedded_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { SchnorrAccountContract } from '@aztec/accounts/schnorr/lazy';

import { getPXEConfig, type PXEConfig } from '@aztec/pxe/config';
import { createPXE, PXE } from '@aztec/pxe/client/lazy';
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
import { AztecAddress } from '@aztec/stdlib/aztec-address';
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
import type { TxSimulationResult } from '@aztec/stdlib/tx';
import { mergeExecutionPayloads, type ExecutionPayload, type TxSimulationResult } from '@aztec/stdlib/tx';
import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
import { deriveSigningKey } from '@aztec/stdlib/keys';
import { SignerlessAccount, type Account, type AccountContract } from '@aztec/aztec.js/account';
Expand Down Expand Up @@ -127,8 +126,8 @@ export class EmbeddedWallet extends BaseWallet {
opts: SimulateInteractionOptions,
): Promise<TxSimulationResult> {
const feeOptions = opts.fee?.estimateGas
? await this.getFeeOptionsForGasEstimation(opts.from, opts.fee)
: await this.getDefaultFeeOptions(opts.from, opts.fee);
? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee.gasSettings)
: await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee.gasSettings);
const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
const executionOptions: DefaultAccountEntrypointOptions = {
txNonce: Fr.random(),
Expand Down
Loading
Loading