Michael Amadi pfp

Michael Amadi

@michaels

91 Following
276 Followers


Michael Amadi pfp
Michael Amadi
@michaels
Thanks!
0 reply
0 recast
1 reaction

Michael Amadi pfp
Michael Amadi
@michaels
Thanks!!
0 reply
0 recast
0 reaction

Michael Amadi pfp
Michael Amadi
@michaels
Thanks!
0 reply
0 recast
1 reaction

Michael Amadi pfp
Michael Amadi
@michaels
Happy to share that I'm joining @ OPLabsPBC as a Protocol Engineer. Excited to collaborate with some of the brightest minds to help scale Ethereum and build the future 🔴
13 replies
16 recasts
156 reactions

Michael Amadi pfp
Michael Amadi
@michaels
Thanks, my mistake 😅
0 reply
0 recast
2 reactions

Michael Amadi pfp
Michael Amadi
@michaels
Found an elliptic curve lib I was writing from scratch last year but didn't have the time to work much on it. I spent the weekend completing it. It's not as optimized as standard cryptography libs, but I can say it's way faster than it was initially. https://github.com/AmadiMichael/EllipticCurves
1 reply
0 recast
12 reactions

Michael Amadi pfp
Michael Amadi
@michaels
Gist: https://gist.github.com/AmadiMichael/dab482d9273d86bbb20febdbca1f8be3
0 reply
0 recast
1 reaction

Michael Amadi pfp
Michael Amadi
@michaels
Wrote a generic (over the number of `bitsPerIteration`) Strauss Shamir impl. The space complexity is O(2 ** 2n), where n is the bitsPerIteration. Because of this, it's important to find a balance between gas cost per iteration and memory expansion cost that comes with reducing the number of iterations by storing precomputed values in memory. OpenZeppelin for example, uses 2 bits per iteration for their P256 verifier. This example uses scalar numbers for simplicity but would also work if used with EC points and operations.
4 replies
0 recast
7 reactions

Michael Amadi pfp
Michael Amadi
@michaels
Same here!
0 reply
0 recast
1 reaction

Michael Amadi pfp
Michael Amadi
@michaels
Okay, issue raised. Maybe native bytecode linking (like huffidity) will be possible with EOF Solidity... any feedback is appreciated and welcome https://github.com/ethereum/solidity/issues/15211
3 replies
1 recast
7 reactions

Michael Amadi pfp
Michael Amadi
@michaels
2) Inline assembly execution calling solidity functions with CALLF: Currently in solidity its not possible to call your contracts' solidity function while in an assembly or an assembly block's function from another assembly block. With EOF, it would be a nice feature if a shared functionality can be set as a code section and hence can be callable via CALLF from any inline assembly block within that contract.
0 reply
0 recast
2 reactions

Michael Amadi pfp
Michael Amadi
@michaels
``` contract A { CodeSection huffCode = CodeSection(0x0101e4, 3, 1, 3); // when used in code, huffCode is a constant that holds the code section index of the variable and not the struct defined above. function b(uint256 _a, uint256 _b, uint256 _c) external view returns(uint256 _d) { _d = huffCode_a, _b, _c); } // OR function c(uint256 _a, uint256 _b, uint256 _c) external view returns(uint256 _d) { assembly { // in inline assembly, huffCode is the code section index of huffCode. The solidity version above does this under the hood. _d := callf(huffCode, _a, _b, _c) } } } ``` Also since memory is shared between code sections, similar to inline assembly the concept of memory safe code sections would also be a thing.
1 reply
0 recast
2 reactions

Michael Amadi pfp
Michael Amadi
@michaels
EOF-Solidity feature requests: 1) Native support for Code Section types: Defined as a struct of 4 fields: bytecode, num of inputs, num of outputs and max stack height. This is to be defined at the contract level and must be known at compile time so that it can be validated and compiled together with the solidity code. Then within any function, the code section can be called via solidity or inline assembly and outputs are to be consumed. This feature enables using custom bytecode e.g hyper optimized hand written bytecode or from another compiler be used within solidity. Example with unchecked add 3 bytecode in comments:
1 reply
1 recast
4 reactions

Michael Amadi pfp
Michael Amadi
@michaels
Improved it a bit. Here's an example of parsing a factory contract that creates another contract. This example is cool because it shows how nested container sections are encoded. - The first command parses the factory contracts eof bytecode - The second command copies the bytecode of the factory's first and only container (which is the init container of the contract to be deployed) and parses it, - The third command copies the bytecode of the init container's first and only container (which is the eof bytecode the init container will return as the runtime code of the contract to be deployed). https://github.com/AmadiMichael/EOF-Bytecode-Parser
2 replies
0 recast
5 reactions

Michael Amadi pfp
Michael Amadi
@michaels
Repo: https://github.com/AmadiMichael/EOF-Bytecode-Parser
0 reply
0 recast
1 reaction

Michael Amadi pfp
Michael Amadi
@michaels
Spent yesterday evening making an EOF bytecode parser with some header invariant validation based on the specs. Also using this to get back into rust. Here's an example output when run with EOF bytecode: 0xef0001010004020001000304000400008000013050fe0bad60a7 Repo link in comments
2 replies
0 recast
6 reactions

Michael Amadi pfp
Michael Amadi
@michaels
POC of one that supports checking if an opcode is supported, supporting an unsupported opcode and deprecating an already supported one to get new opcodeBitmap values: https://github.com/AmadiMichael/OpcodesBitmap
0 reply
0 recast
3 reactions

Michael Amadi pfp
Michael Amadi
@michaels
Here's an interesting way to encode all of the supported opcodes of an EVM chain in 256 bits. This is that of Ethereum mainnet currently. Base 2: 1110010000111111000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000111111111111111111111111111000000000000000100111111111111110000111111111111 Base 10: 103238640842065774761881656312677524192904604960857204817777740543577286447103 Base 16: 0xe43f0000000000000000001fffffffffffffffffffff07ffffff00013fff0fff Its also easy to check if a particular `opcode` is supported, like so: ``` uint256 opcodesBitmap = 103238640842065774761881656312677524192904604960857204817777740543577286447103; uint256 mask = shl(opcode, 0x01); bool isSupported = and(opcodesBitmap, mask); return isSupported; ```
2 replies
1 recast
6 reactions

Michael Amadi pfp
Michael Amadi
@michaels
Favorite thing? Hard to pick but I'd say it's the structured code format itself and well defined rules. Makes it way easier to analyze and decompile unverified contracts.
0 reply
0 recast
1 reaction

Michael Amadi pfp
Michael Amadi
@michaels
Officially an EOF Maxi
1 reply
0 recast
4 reactions