Skip to content

Instantly share code, notes, and snippets.

View bshastry's full-sized avatar

Bhargava Shastry bshastry

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bshastry on github.
  • I am shastry (https://keybase.io/shastry) on keybase.
  • I have a public key whose fingerprint is 724A D7B9 9CC5 E904 A184 B298 BCC7 B7AF 2A03 C0E7

To claim this, I am signing this object:

@bshastry
bshastry / trace.txt
Created March 1, 2024 08:41
EVM trace for out of gas
INFO: found LLVMFuzzerCustomMutator (0x64f5d0). Disabling -len_control by default.
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 1979826077
INFO: Loaded 1 modules (404663 inline 8-bit counters): 404663 [0x2a9eb70, 0x2b01827),
INFO: Loaded 1 PC tables (404663 PCs): 404663 [0x2b01828,0x312e398),
./solc_mutator_ossfuzz: Running 1 inputs 1 time(s) each.
Running: crash-5e4272982726d507f4720ed8c158601c692d35a6
No library names found in the input.
Setting Name: language
Setting Value: yul
@bshastry
bshastry / test.yul
Created March 1, 2024 08:35
Yul code that makes EVM run out of gas
==== Source: su0.yul ====
{
let al0 := verbatim_1i_1o(hex"31", 8)
function af0(ai0, ai1, ai2) -> ao0
{
let al1, al2, al3, al4, al5, al6, al7, al8, al9, al10, al11 := verbatim_10i_11o(hex"89", eq(verbatim_2i_1o(hex"10", ai1, 544), lt(192, 384)), af0(create2(196, 384, 193, 992), byte(832, 288), exp(256, 960)), call(gas(), 7, 247, 320, 24, 384, 135), byte(tload(320), delegatecall(gas(), 6, 320, 173, 192, 163)), mload(224), byte(mload(128), or(448, 832)), blobbasefee(), sload(160), shr(mload(128), eq(480, 128)), ai2)
let al12 := verbatim_1i_1o(hex"40", gt(verbatim_0i_1o(hex"64ddeb13295d"), verbatim_0i_1o(hex"7641c62b293953bb6d76d01a758b807b442ced6cd35d82d9")))
{
}
let al13 := af0(mload(256), create2(226, 352, 99, tload(288)), create(176, 320, 98))
@bshastry
bshastry / via_ir_ice.sol
Created February 28, 2024 05:50
Experimental via IR ICE
pragma experimental solidity;
type uint256 = __builtin("word");
instantiation uint256: + {
function add(x, y) -> uint256 {
let a = uint256.rep(x);
let b = uint256.rep(y);
assembly {
a := add(a,b)
@bshastry
bshastry / test.sol
Created February 19, 2024 08:29
Invalid Deposit assembly via legacy codegen
contract C0 {
fallback() external payable
{
}
function f1() public virtual
{
if ((bytes8(bytes27(bytes10(0x3f0802b2966e365aa0e3))) != bytes8(0x1dcb7a3da18e91f4)))
{
return;
}
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:85:2: runtime error: member call on address 0x00000b752de0 which does not point to an object of type 'solidity::frontend::Type'
0x00000b752de0: note: object has invalid vptr
00 00 00 00 00 00 00 00 00 00 00 00 10 40 71 0b 00 00 00 00 30 30 66 30 30 66 66 30 66 66 66 30
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:85:2 in
UndefinedBehaviorSanitizer:DEADLYSIGNAL
==164551==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000008 (pc 0x00000153d4c4 bp 0x7ffc7054d7f0 sp 0x7ffc7054d7c0 T164551)
==164551==The signal is caused by a READ memory access.
==164551==Hint: address points to the zero page.
Compiling fe-test-runner v0.26.0 (/home/bhargava/work/github/fe/crates/test-runner)
Compiling libfuzzer-sys v0.4.7
error[E0432]: unresolved import `revm::primitives::B160`
--> /home/bhargava/work/github/fe/crates/test-runner/src/lib.rs:5:81
|
5 | use revm::primitives::{AccountInfo, Bytecode, Env, ExecutionResult, TransactTo, B160, U256};
| ^^^^ no `B160` in the root
error[E0308]: mismatched types
--> /home/bhargava/work/github/fe/crates/test-runner/src/lib.rs:116:38
@bshastry
bshastry / abiv2_timeout.sol
Created November 14, 2023 11:36
Timeout compiling abiv2 coder test case
pragma solidity >=0.0;
pragma experimental ABIEncoderV2;
contract C {
int224 sv_0;
function test() public returns (uint) {
return test_calldata_coding();
@bshastry
bshastry / summary.txt
Created September 21, 2023 11:21
Summary of Single Secret Leader Election paper
The passage introduces the concept of Single Secret Leader Election (SSLE), where a group aims to randomly select one leader without revealing their identity. It presents three constructions of SSLE schemes with varying security and performance properties. The first construction utilizes indistinguishability obfuscation, the second relies on low-depth threshold fully homomorphic encryption (TFHE), and the third is based on the Decision Diffie-Hellman (DDH) assumption and random shuffles.
The passage discusses the practical requirements and restrictions for SSLE schemes, the syntax and security properties of an SSLE scheme, and the algorithms and protocols involved in the leader election process. It also mentions the importance of security, fairness, and unpredictability in SSLE schemes.
One of the constructions presented is a TFHE-based SSLE scheme that uses a weak pseudorandom function (PRF), a threshold FHE scheme, and a random oracle. It explains the expansion of random bits into a vector, the leader sel
{let x for{ }calldataload(0){ }{{ {{ { { for {}calldataload(0){}
{if callvalue() {break}
mstore(x,0x42)for{ }calldataload(0) { } { {x := 1
for {} calldataload(0) {}
{{{if callvalue(){{ {{
x :=2 for{ } calldataload(0){}{
if callvalue() { {{{ { {if callvalue(){x := 2{
{sstore(4, exp(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe, 1))sstore(6,exp(not(0), 1))sstore(7,exp(0xffffafffffffffffffffffffffffffff, 2))sstore(8, exp(0xffffffffffffffff,2))sstore(9,exp(0xf,3)) sstore(13, exp(0xffffffffffffffff0000000000000000, 3))
sstore(14, exp(2, 6)) sstore(15, exp(2, 255)) {
{