Skip to content

Instantly share code, notes, and snippets.

View critesjosh's full-sized avatar
🥸

josh crites critesjosh

🥸
View GitHub Profile
@critesjosh
critesjosh / Contract_calls.sol
Last active February 20, 2024 10:45
CALL vs CALLCODE vs DELEGATECALL in Solidity
pragma solidity ^0.4.15;
contract C1 {
uint public num;
address public sender;
function callSetNum(address c2, uint _num) public {
if(!c2.call(bytes4(sha3("setNum(uint256)")), _num)) revert(); // C2's num is set
}
@critesjosh
critesjosh / deployment.json
Created December 21, 2023 02:04
private token deployment info
{
"arbitrumSepolia": {
"address": "0x1275f8f414d95508ba13c90586f933edec825cc0",
"abi": [
{
"inputs": [
{
"internalType": "address",
"name": "_processDepositVerifier",
"type": "address"
@critesjosh
critesjosh / index.js
Last active December 4, 2023 18:52
This script is a demo of how to use the ContractKit to send a transaction on the Celo network (https://celo.org)
#!/usr/bin/env node
/*
This script is a demo of how to use the ContractKit to send a transaction on the Celo network (https://celo.org)
With npm installed, run this script with the command:
npx https://gist.github.com/critesjosh/7dd9cdb3076d9d5874c061612af8057e
*/
// Import ContractKit
const ContractKit = require('@celo/contractkit')
@critesjosh
critesjosh / typescript_bbjs.ts
Created August 11, 2023 19:46
the full script for the instructive page here: https://noir-lang.org/typescript
import circuit from '../target/test.json' assert { type: 'json' };
import { decompressSync } from 'fflate';
import { Crs, newBarretenbergApiAsync, RawBuffer } from '@aztec/bb.js/dest/node/index.js';
import { ethers } from 'ethers'; // I'm lazy so I'm using ethers to pad my input
import { executeCircuit, compressWitness } from '@noir-lang/acvm_js';
async function main() {
const acirBuffer = Buffer.from(circuit.bytecode, 'base64');
const acirBufferUncompressed = decompressSync(acirBuffer);
@critesjosh
critesjosh / tsconfig.json
Created August 11, 2023 19:44
tsconfig for using bb.js, noir and typescript
{
"compilerOptions": {
"target": "es2020",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
@critesjosh
critesjosh / plonk_vk.sol
Created July 13, 2023 19:08
test noir solidity verifier contract
// Verification Key Hash: eb4cd5b33387b673f9b5de6574d97c8b7e0d0d454199710235bba681719349ba
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022 Aztec
pragma solidity >=0.8.4;
library UltraVerificationKey {
function verificationKeyHash() internal pure returns(bytes32) {
return 0xeb4cd5b33387b673f9b5de6574d97c8b7e0d0d454199710235bba681719349ba;
}
@critesjosh
critesjosh / connect_to_metamask.js
Created May 24, 2023 16:41
for testing signing messages with metamask just using the browser console.
String.prototype.hexEncode = function(){
var hex, i;
var result = "";
for (i=0; i<this.length; i++) {
hex = this.charCodeAt(i).toString(16);
result += ("000"+hex).slice(-4);
}
return result
// https://gist.github.com/Turupawn/12cefea88476ce556d01d15705efcd70
/*
Try with these iputs in Prover.toml
hash_path = ["0x2fbbcae1f6072bd17986e7d705a1a92a634d698f94620b8c5170c470be747d0b", "0x244156862f17c9aa11c1d39da925e4d9e03505e3836804c6774f0a4049ec6eac"]
index = "0"
priv_key = "1"
proposalId = "0"
root = "0x02b54b6daa0b81c12a9d75f44d39e52dcbfa2ef2ab04dbe9159559a547a9ae82"
// https://gist.github.com/Turupawn/6a4391fb54d09aae7a091ad2478c1f62#file-zkvoting-sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;
contract zkVoting is UltraVerifier {
struct Proposal {
string description;
uint deadline;
@critesjosh
critesjosh / plonk_vk.sol
Created May 3, 2023 14:48
solidity ultraplonk verifier contract
// Verification Key Hash: 584edb3633b5589bed16edc896f2c868bc72fe184f3526d873ebd68883df01f7
// SPDX-License-Identifier: Apache-2.0
// Copyright 2022 Aztec
pragma solidity >=0.8.4;
library UltraVerificationKey {
function verificationKeyHash() internal pure returns(bytes32) {
return 0x584edb3633b5589bed16edc896f2c868bc72fe184f3526d873ebd68883df01f7;
}