Skip to content

Instantly share code, notes, and snippets.

View Turupawn's full-sized avatar
🇭🇳
Karaoke veteran

Ahmed Castro Turupawn

🇭🇳
Karaoke veteran
View GitHub Profile
import createAlchemyWeb3 from "@alch/alchemy-web3"
import dotenv from "dotenv"
dotenv.config();
const BRIDGE_CONTRACT_ADDRESS = "0xe5E30E7c24e4dFcb281A682562E53154C15D3332"
const MY_WALLET_ADDRESS = "0x707e55a12557E89915D121932F83dEeEf09E5d70"
var web3 = null
var bridgeContract = null
@Turupawn
Turupawn / simple_commit_reveal.sol
Created May 1, 2023 21:57
Simple Commit-Reveal Scheme in Solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
contract CommitReveal
{
bytes32 public commitedValue;
uint public secretValue;
function hashValue(uint _secretValue) public pure returns(bytes32)
{
@Turupawn
Turupawn / multi_commit_reveal.sol
Created May 2, 2023 21:24
Randomness using Multi Commit Reveal
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
contract MutiCommitReveal
{
enum CommitmentState {NotCommited, Commited, Revealed}
bytes32 public randomness;
uint public commitmentDeadline;
uint public revealDeadline;
@Turupawn
Turupawn / zkVoting.sol
Last active May 8, 2023 19:21
Aztec simple voting example
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;
contract zkVoting is UltraVerifier {
struct Proposal {
string description;
uint deadline;
uint forVotes;
uint againstVotes;
@Turupawn
Turupawn / zkVoting.nr
Created May 8, 2023 19:25
Simple ZK Voting circuit for noir
use dep::std;
fn main(root : pub Field, index : Field, hash_path : [Field; 2], secret: Field, priv_key: Field, proposalId: pub Field, vote: pub Field) -> pub Field {
constrain index == index;
let pubkey = std::scalar_mul::fixed_base(priv_key);
let pubkey_x = pubkey[0];
let pubkey_y = pubkey[1];
let note_commitment = std::hash::pedersen([pubkey_x, pubkey_y, secret]);
@Turupawn
Turupawn / zkVotingWithNullifier.sol
Created May 11, 2023 03:33
Simple ZK Voting with nullifier
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;
contract zkVoting is UltraVerifier {
struct Proposal {
string description;
uint deadline;
uint forVotes;
uint againstVotes;
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@scroll-tech/contracts/libraries/token/IScrollStandardERC20.sol";
contract L2Token is ERC20, IScrollStandardERC20 {
// We store the gateway and the L1 token address to provide the gateway() and counterpart() functions which are needed from the Scroll Standard ERC20 interface
address _gateway;
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*