Skip to content

Commit c8d8fe9

Browse files
committed
Merge branch 'main' into dark-pool
2 parents 2a2faab + 671e1fe commit c8d8fe9

File tree

13 files changed

+57
-51
lines changed

13 files changed

+57
-51
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Waztec
1+
<img align="right" width="150" height="150" top="100" src="https://github.com/user-attachments/assets/c80982e6-103e-45b0-8bd1-b6c38c5debe5">
22

3-
Walmart version of [Aztec](https://aztec.network).
3+
# Mezcal
4+
5+
Mezcal (Nahuatl: mexcalli) - agave booze.
46

57
## TODO
68

@@ -14,12 +16,11 @@ Walmart version of [Aztec](https://aztec.network).
1416
- [x] use bignumber for amounts
1517
- [ ] support ETH
1618
- [ ] fees
17-
- [ ] get the remained of tokens from router to relayer/treasury
19+
- [ ] prove against a historical note hash tree root
1820
- [x] PublicInputsBuilder
1921
- [ ] deploy as proxy
2022
- [ ] test contracts with larger token amounts
21-
- [x] Rename ValueNote to Erc20Note and namespace all erc20 circuit names
22-
- [ ] Make PoolGeneric permissionless and make PoolERC20.execute permissionless (if possible)
23+
- [ ] TODO(security): parse inputs to circuits instead of assuming they are correct. Same applies to types returned from `unconstrained` functions. <https://github.com/noir-lang/noir/issues/7181> <https://github.com/noir-lang/noir/issues/4218>
2324

2425
### Backend
2526

@@ -33,9 +34,9 @@ Walmart version of [Aztec](https://aztec.network).
3334
- [x] transfer
3435
- [ ] join (maybe behind the scenes, multicall)
3536
- [ ] unshield
36-
- [ ] wallet connect to interact with dapps
3737

38-
### compliance (so I don't go to jail)
38+
### compliance
3939

4040
- [ ] unshield only mode
4141
- [ ] set shield limit to 10 USDC
42+
- [ ] disclaimer that the rollup is not audited

apps/interface/src/lib/reown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const core = new Core({
99
});
1010

1111
const metadata = {
12-
name: "Walmart Aztec",
12+
name: "Mezcal",
1313
description: "Private anything",
1414
url: "https://reown.com/appkit", // origin must match your domain & subdomain
1515
icons: ["https://assets.reown.com/reown-profile-pic.png"],

apps/interface/src/lib/services/EvmAccountService.svelte.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ export class EvmAccountService {
4040
}
4141

4242
async getSecretKey(account: ethers.Signer) {
43-
const message =
44-
"Sign this message to generate a encrypted-evm.oleh.wtf secret key"; // TODO(security): put the correct domain here
43+
const message = "Sign this message to derive a Mezcal secret key"; // TODO(security): put the correct domain here
4544
const address = (await account.getAddress()).toLowerCase();
4645
if (!this.#secretKeys[address]) {
4746
this.#secretKeys[address] = utils.iife(async () => {

packages/contracts/contracts/PoolGeneric.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ contract PoolGeneric {
5454
.root = 0x1fd848aa69e1633722fe249a5b7f53b094f1c9cef9f5c694b073fd1cc5850dfb; // empty tree
5555
_poolGenericStorage()
5656
.nullifierTree
57-
.root = 0x0aa63c509390ad66ecd821998aabb16a818bcc5db5cf4accc0ce1821745244e9; // nullifier tree filled with 1 canonical subtree of nullifiers
57+
.root = 0x2767ce7e247423302eb0ea55fd0aa14294d1b2e9914bce677373d932c0bd1b75; // nullifier tree filled with 1 canonical subtree of nullifiers
5858
_poolGenericStorage()
5959
.nullifierTree
6060
.nextAvailableLeafIndex = MAX_NULLIFIERS_PER_ROLLUP;

packages/contracts/noir/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/contracts/noir/common/src/erc20_note.nr

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub struct Erc20Note {
66
pub randomness: Field,
77
}
88

9+
impl crate::Note for Erc20Note {}
10+
911
impl Erc20Note {
1012
pub fn sub_and_emit_change<let N: u32>(
1113
context: &mut crate::Context,
@@ -39,14 +41,6 @@ impl crate::Serialize<4> for Erc20Note {
3941
}
4042
}
4143

42-
impl crate::Note for Erc20Note {
43-
fn hash(self) -> Field {
44-
let serialized = self.serialize();
45-
// TODO(security): use poseidon2_hash_with_separator
46-
std::hash::poseidon2::Poseidon2::hash(serialized, serialized.len())
47-
}
48-
}
49-
5044
impl crate::OwnedNote for Erc20Note {
5145
fn owner(self) -> crate::WaAddress {
5246
self.owner

packages/contracts/noir/common/src/lib.nr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ mod note;
77
mod owned_note;
88

99
pub use context::{Context, Result};
10-
pub use erc20_note::{Erc20Note, Erc20NoteConsumptionInputs};
11-
pub use note::Note;
10+
pub use note::{compute_note_hash, Note};
1211
pub use owned_note::{NoteConsumptionInputs, OwnedNote};
1312
pub use protocol_types::{address::EthAddress, traits::Serialize};
1413

@@ -41,13 +40,15 @@ pub global MAX_TOKENS_OUT_PER_EXECUTION: u32 = 4;
4140
pub global GENERATOR_INDEX__WA_ADDRESS: Field = 1;
4241
// Note: keep in sync with other languages
4342
pub global GENERATOR_INDEX__NOTE_NULLIFIER: Field = 2;
43+
// Note: keep in sync with other languages
44+
pub global GENERATOR_INDEX__NOTE_HASH: Field = 3;
4445

4546
// Note: keep in sync with other languages
4647
pub global U256_LIMBS: u32 = 3;
4748

4849
pub type U256 = uint252::U252;
4950

50-
/// Walmart Aztec address
51+
/// User address within the rollup
5152
#[derive(Eq, Serialize)]
5253
pub struct WaAddress {
5354
inner: Field,
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
pub trait Note {
2-
fn hash(self) -> Field;
1+
use protocol_types::hash::poseidon2_hash_with_separator;
2+
3+
/// A marker trait to mark structs as notes
4+
pub trait Note: crate::Serialize<_> {
35

46
pub fn emit(self, context: &mut crate::Context) {
5-
context.push_note_hash(self.hash());
7+
context.push_note_hash(crate::compute_note_hash(self));
68
}
79
}
10+
11+
pub fn compute_note_hash<T>(note: T) -> Field
12+
where
13+
T: Note,
14+
{
15+
let serialized = note.serialize();
16+
// TODO(security): add note type to the hash (erc20, erc721, etc.)
17+
poseidon2_hash_with_separator(serialized, crate::GENERATOR_INDEX__NOTE_HASH)
18+
}

packages/contracts/noir/common/src/owned_note.nr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ fn compute_nullifier_of_owned_note<T>(note: T, secret_key: Field) -> Field
1111
where
1212
T: OwnedNote,
1313
{
14+
// TODO(perf): pass note hash as an argument to avoid hashing twice?
1415
assert_eq(note.owner(), crate::WaAddress::from_secret_key(secret_key), "invalid secret key");
1516
poseidon2_hash_with_separator(
16-
[note.hash(), secret_key],
17+
[crate::compute_note_hash(note), secret_key],
1718
crate::GENERATOR_INDEX__NOTE_NULLIFIER,
1819
)
1920
}
@@ -32,7 +33,7 @@ where
3233
{
3334
pub fn consume(self, context: &mut crate::Context, secret_key: Field) {
3435
merkle_tree::assert_check_membership(
35-
self.note.hash(),
36+
crate::compute_note_hash(self.note),
3637
self.note_index,
3738
self.note_sibling_path,
3839
context.tree_roots().note_hash_root,

packages/contracts/noir/erc20/src/lib.nr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub use common::{Erc20Note, Erc20NoteConsumptionInputs};
1+
pub use common::erc20_note::{Erc20Note, Erc20NoteConsumptionInputs};
22

33
pub mod Token {
44
pub fn mint(
@@ -7,17 +7,17 @@ pub mod Token {
77
amount: common::TokenAmount,
88
randomness: Field,
99
) {
10-
common::Erc20Note { owner: to, amount, randomness }.emit(context);
10+
crate::Erc20Note { owner: to, amount, randomness }.emit(context);
1111
}
1212

1313
pub fn burn(
1414
context: &mut common::Context,
1515
from_secret_key: Field,
16-
from_note_inputs: common::Erc20NoteConsumptionInputs,
16+
from_note_inputs: crate::Erc20NoteConsumptionInputs,
1717
amount: common::TokenAmount,
1818
change_randomness: Field,
1919
) {
20-
common::Erc20Note::sub_and_emit_change(
20+
crate::Erc20Note::sub_and_emit_change(
2121
context,
2222
[from_note_inputs],
2323
amount,
@@ -29,7 +29,7 @@ pub mod Token {
2929
pub fn join<let N: u32>(
3030
context: &mut common::Context,
3131
from_secret_key: Field,
32-
notes: [common::Erc20NoteConsumptionInputs; N],
32+
notes: [crate::Erc20NoteConsumptionInputs; N],
3333
to: common::WaAddress,
3434
join_randomness: Field,
3535
) {
@@ -42,27 +42,27 @@ pub mod Token {
4242
joined_amount += notes[i].note.amount;
4343
}
4444

45-
common::Erc20Note { owner: to, amount: joined_amount, randomness: join_randomness }.emit(
45+
crate::Erc20Note { owner: to, amount: joined_amount, randomness: join_randomness }.emit(
4646
context,
4747
);
4848
}
4949

5050
pub fn transfer(
5151
context: &mut common::Context,
5252
from_secret_key: Field,
53-
from_note_inputs: common::Erc20NoteConsumptionInputs,
53+
from_note_inputs: crate::Erc20NoteConsumptionInputs,
5454
to: common::WaAddress,
5555
amount: common::TokenAmount,
5656
to_randomness: Field,
5757
change_randomness: Field,
5858
) {
59-
common::Erc20Note::sub_and_emit_change(
59+
crate::Erc20Note::sub_and_emit_change(
6060
context,
6161
[from_note_inputs],
6262
amount,
6363
change_randomness,
6464
from_secret_key,
6565
);
66-
common::Erc20Note { owner: to, amount, randomness: to_randomness }.emit(context);
66+
crate::Erc20Note { owner: to, amount, randomness: to_randomness }.emit(context);
6767
}
6868
}

0 commit comments

Comments
 (0)