Skip to content
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

PhantomGate: NFT gated event check-in system #22

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
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
28 changes: 28 additions & 0 deletions phantom-gate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
node_modules
.env

contracts/counter/target
21 changes: 21 additions & 0 deletions phantom-gate/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Ankit Agrawal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
83 changes: 83 additions & 0 deletions phantom-gate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Private NFT-Gated Event Check-in System on Aztec
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there another readme that fleshout out some other sections from the readme template?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like the component being built 👍


## Overview

`PhantomGate` implements a private NFT-gated event check-in system on Aztec Network, allowing users to prove their NFT ownership without revealing their identity or specific NFT details. The system verifies NFT ownership at specific block heights while maintaining privacy through zero-knowledge proofs. We will also provide minting the nft.

## System Architecture

## Challenge Selection

- [ ] ZKEmail Guardian
- [x] Social Cipher

## Video Demo

https://drive.google.com/file/d/18d6teeO3AaEkc0og0u-o10yNMIXbd_-V/view?usp=sharing

### Components

#### 1. Client-Side (PXE)
- Aztec.js integration for client interactions
- Private execution environment for NFT ownership verification
- Zero-knowledge proof generation for NFT ownership
- User interface for check-in process


#### 2. Smart Contracts
- Event management contract (public state)- (WIP)
- NFT verification contract (private state)
- Portal contract for Ethereum NFT communication - (WIP)

#### 3. Public VM
- Processes rollups of private check-ins
- Maintains public event statistics
- Handles state transitions

### Flow Diagram

```
User (with NFT) -> PXE (Private Verification) -> Aztec Contract
-> Portal Contract
-> Ethereum NFT Contract
```

### Local Installation
```bash
# Clone the repository
git clone https://github.com/ankit875/alpha-build2/phantom-gate

cd phantom-gate

# Install dependencies
yarn install


# Start development server
yarn run dev
```

```bash
# Go to contract Directory
cd contracts/nft_contracts

# Compile contracts
aztec-nargo compile

# Generate Artifacts
aztec codegen target --outdir ../../src/artifacts
```


## License
MIT License

## Contact
- Discord Server: ankitagrwal
- Twitter: @ankitagrwal
- Email: [email protected]

## Acknowledgments
- Aztec Network Team
- Discord API Documentation
- Community Contributors
Binary file added phantom-gate/bun.lockb
Binary file not shown.
9 changes: 9 additions & 0 deletions phantom-gate/contracts/account/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "account"
type = "contract"
authors = [""]
compiler_version = ">=0.33.0"

[dependencies]
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "aztec-packages-v0.60.0", directory = "noir-projects/aztec-nr/aztec" }
authwit = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "aztec-packages-v0.60.0", directory = "noir-projects/aztec-nr/authwit" }
6 changes: 6 additions & 0 deletions phantom-gate/contracts/account/codegenCache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"account-SchnorrAccount.json": {
"contractName": "SchnorrAccount",
"hash": "b260fbc8dd255d7045c8821152dc627bb7130bbcaf85ca7724a62e26a324e161"
}
}
149 changes: 149 additions & 0 deletions phantom-gate/contracts/account/src/artifacts/SchnorrAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@

/* Autogenerated file, do not edit! */

/* eslint-disable */
import {
type AbiType,
AztecAddress,
type AztecAddressLike,
CompleteAddress,
Contract,
type ContractArtifact,
ContractBase,
ContractFunctionInteraction,
type ContractInstanceWithAddress,
type ContractMethod,
type ContractStorageLayout,
type ContractNotes,
decodeFromAbi,
DeployMethod,
EthAddress,
type EthAddressLike,
EventSelector,
type FieldLike,
Fr,
type FunctionSelectorLike,
L1EventPayload,
loadContractArtifact,
type NoirCompiledContract,
NoteSelector,
Point,
type PublicKey,
PublicKeys,
type UnencryptedL2Log,
type Wallet,
type WrappedFieldLike,
} from '@aztec/aztec.js';
import SchnorrAccountContractArtifactJson from '../../target/account-SchnorrAccount.json' assert { type: 'json' };
export const SchnorrAccountContractArtifact = loadContractArtifact(SchnorrAccountContractArtifactJson as NoirCompiledContract);



/**
* Type-safe interface for contract SchnorrAccount;
*/
export class SchnorrAccountContract extends ContractBase {

private constructor(
instance: ContractInstanceWithAddress,
wallet: Wallet,
) {
super(instance, SchnorrAccountContractArtifact, wallet);
}



/**
* Creates a contract instance.
* @param address - The deployed contract's address.
* @param wallet - The wallet to use when interacting with the contract.
* @returns A promise that resolves to a new Contract instance.
*/
public static async at(
address: AztecAddress,
wallet: Wallet,
) {
return Contract.at(address, SchnorrAccountContract.artifact, wallet) as Promise<SchnorrAccountContract>;
}


/**
* Creates a tx to deploy a new instance of this contract.
*/
public static deploy(wallet: Wallet, signing_pub_key_x: FieldLike, signing_pub_key_y: FieldLike) {
return new DeployMethod<SchnorrAccountContract>(PublicKeys.default(), wallet, SchnorrAccountContractArtifact, SchnorrAccountContract.at, Array.from(arguments).slice(1));
}

/**
* Creates a tx to deploy a new instance of this contract using the specified public keys hash to derive the address.
*/
public static deployWithPublicKeys(publicKeys: PublicKeys, wallet: Wallet, signing_pub_key_x: FieldLike, signing_pub_key_y: FieldLike) {
return new DeployMethod<SchnorrAccountContract>(publicKeys, wallet, SchnorrAccountContractArtifact, SchnorrAccountContract.at, Array.from(arguments).slice(2));
}

/**
* Creates a tx to deploy a new instance of this contract using the specified constructor method.
*/
public static deployWithOpts<M extends keyof SchnorrAccountContract['methods']>(
opts: { publicKeys?: PublicKeys; method?: M; wallet: Wallet },
...args: Parameters<SchnorrAccountContract['methods'][M]>
) {
return new DeployMethod<SchnorrAccountContract>(
opts.publicKeys ?? PublicKeys.default(),
opts.wallet,
SchnorrAccountContractArtifact,
SchnorrAccountContract.at,
Array.from(arguments).slice(1),
opts.method ?? 'constructor',
);
}



/**
* Returns this contract's artifact.
*/
public static get artifact(): ContractArtifact {
return SchnorrAccountContractArtifact;
}


public static get storage(): ContractStorageLayout<'signing_public_key'> {
return {
signing_public_key: {
slot: new Fr(1n),
}
} as ContractStorageLayout<'signing_public_key'>;
}


public static get notes(): ContractNotes<'PublicKeyNote'> {
return {
PublicKeyNote: {
id: new NoteSelector(2806681024),
}
} as ContractNotes<'PublicKeyNote'>;
}


/** Type-safe wrappers for the public methods exposed by the contract. */
public declare methods: {

/** compute_note_hash_and_optionally_a_nullifier(contract_address: struct, nonce: field, storage_slot: field, note_type_id: field, compute_nullifier: boolean, serialized_note: array) */
compute_note_hash_and_optionally_a_nullifier: ((contract_address: AztecAddressLike, nonce: FieldLike, storage_slot: FieldLike, note_type_id: FieldLike, compute_nullifier: boolean, serialized_note: FieldLike[]) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** constructor(signing_pub_key_x: field, signing_pub_key_y: field) */
constructor: ((signing_pub_key_x: FieldLike, signing_pub_key_y: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** entrypoint(app_payload: struct, fee_payload: struct, cancellable: boolean) */
entrypoint: ((app_payload: { function_calls: { args_hash: FieldLike, function_selector: FunctionSelectorLike, target_address: AztecAddressLike, is_public: boolean, is_static: boolean }[], nonce: FieldLike }, fee_payload: { function_calls: { args_hash: FieldLike, function_selector: FunctionSelectorLike, target_address: AztecAddressLike, is_public: boolean, is_static: boolean }[], nonce: FieldLike, is_fee_payer: boolean }, cancellable: boolean) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** lookup_validity(consumer: struct, inner_hash: field) */
lookup_validity: ((consumer: AztecAddressLike, inner_hash: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;

/** verify_private_authwit(inner_hash: field) */
verify_private_authwit: ((inner_hash: FieldLike) => ContractFunctionInteraction) & Pick<ContractMethod, 'selector'>;
};


}
Loading