alexweb3dev

137 posts

alexweb3dev banner
alexweb3dev

alexweb3dev

@alexweb310

Blockchain Developer | Available for work

Katılım Haziran 2023
218 Takip Edilen294 Takipçiler
alexweb3dev
alexweb3dev@alexweb310·
The difference between Memory and Calldata in function arguments: Calldata is read only, so it can not be modified, the data lives directly in the transaction calldata and it is also the cheapest to use. With memory, the data is copied into memory (duh... :D), it is more expensive than using calldata, but it allows you to modify the data if you wish to do so.
English
0
0
11
575
alexweb3dev
alexweb3dev@alexweb310·
In Solidity, interfaces only declare function signatures, not their implementations, and because of that, most modifiers are not allowed. You can only use modifiers that describe the external ABI: external (this one is required), view, pure and payable. Modifiers related to implementation or internal behavior are not allowed, so you can not use internal, private, virtual, override or custom modifiers like onlyOwner, nonReentrant etc. That is because interfaces can not contain function code, and those modifiers either affect execution of the function or depend on function body code being present.
English
0
0
2
42
alexweb3dev
alexweb3dev@alexweb310·
In what cases could abi.encodePacked create a vulnerability? It can become dangerous when its output is used in cases where each the result must be unique, because the encoding itself does not guarantee that. If the output is used for things like hashing, signing, authentication, authorization or other cases where uniqueness is a requirement, then you should use abi.encode instead, unless every field used in the encoding is of fixed size.
English
0
0
2
37
alexweb3dev
alexweb3dev@alexweb310·
As a general rule, use abi.encode by default and only use abi.encodePacked when all the types have a fixed size and the risk of hash collisions is acceptable
English
0
0
1
24
alexweb3dev
alexweb3dev@alexweb310·
abi.encodePacked encodes the data in a tightly packed form, the values are not padded to 32 bytes and can potentially create hash collisions
English
1
0
1
28
alexweb3dev
alexweb3dev@alexweb310·
In Solidity, abi.encode and abi.encodePacked are both used to serialize data. However, they both do it differently and if you choose the wrong one, you can potentially introduce bugs. abi.encode encodes data using the standard ABI encoding, the output is unambiguous, each value is padded to 32 bytes and it is safe for decoding and using with dynamic types.
English
1
0
1
32
alexweb3dev
alexweb3dev@alexweb310·
Storage collisions can be avoided by using unstructured storage (EIP-1967), leaving storage gaps, thus allowing for future variables to be added without changing storage layout. Also, never reorder variables, only append new variables and keep the inheritance order the same.
English
0
0
2
25
alexweb3dev
alexweb3dev@alexweb310·
A storage collision in a proxy contract occurs when the proxy and an implementation use the same storage slot for different variables. In Ethereum, state variables are stored in fixed storage slots (0, 1, 2...). When a proxy contract calls an implementation contract using "delegatecall", the code of the implementation will be executed in the proxy's context (affecting the proxy's storage variables). If the proxy and implementation contracts do not agree on which slots are used for which variable, it can lead to serious security vulnerabilities.
English
1
0
2
28
alexweb3dev
alexweb3dev@alexweb310·
This can cause big problems if not handled correctly, so if protocols want to support fee on transfer tokens they have to account for this behavior when designing their system.
English
0
0
1
25
alexweb3dev
alexweb3dev@alexweb310·
Most DeFi protocols assume that balanceAfter = balanceBefore + amount, but for fee on transfer tokens it is balanceAfter = balanceBefore + (amount - fee).
English
1
0
1
26
alexweb3dev
alexweb3dev@alexweb310·
A fee-on-transfer token is like an ERC-20 token that charges a fee every time it is transferred. When a transfer takes place, the token contract deducts a fee from the amount to be sent and sends only the remaining amount to the recipient, while sending the fee to a destination address (e.g. a treasury).
English
1
0
1
36
alexweb3dev retweetledi
Eli Ben-Sasson | Starknet.io
Eli Ben-Sasson | Starknet.io@EliBenSasson·
Privacy matters: (another very long tweet) I'm trying to explain the difference between TEE, ZK, MPC and FHE. If we're talking privacy, security and blockchains, this is important to understand. Last time I explained TEE, today I'll explain ZK: 📚 ZK stands for Zero Knowledge. Among the technologies I’m surveying (TEE, ZK, MPC, FHE) it's the most mature and battle tested one in blockchain settings. - @Zcash has been using ZK for privacy since we launched it in 2016 (the whitepaper we wrote on which it's based is from 2014). - @StarkWareLtd has settled over $1.4T on STARK technology since 2020, scaling Ethereum and Bitcoin, and saving users over $1B in transaction fees. Why am I mentioning this? Because no other technology surveyed here is as battle-tested and used as ZK. ZK has two super-powers: Privacy and Scalability. How does it work? There are two types of entities: A ZK prover and a ZK verifier. There is a separation of powers between them. 1. The prover does the heavy lifting -- it collects the data about all relevant txs, processes them, updates the state of the system based on these txs, and spits out a statement, and a proof. - A typical statement says "I, the prover, have started with state A, processed 1,000,000 transactions, and based on those, reached state B". - The proof is a short sequence of numbers and hashes that *proves* the integrity of the whole statement. 2. The verifier checks the proof to see if it's valid for that particular statement. The verifier typically sits onchain. The way a verifier works is by using math and cryptography, and I won’t explain it here. But suffice to say that the theorems we’ve proved about ZK over the years say that the verifier always accepts true statements and never accepts false statements (more precisely -- a malicious prover who wants to convince a verifier to accept a false statement has to do a similar amount of work to finding a collision in a cryptographic hash function, which cannot be done before our Sun cools down). Once the verifier checked the proof, the statement can be accepted. ZK is really good for allowing a single user to shield their data, and for scaling blockchains. Privacy is what we used it for on Zcash, and Scalabilty is what we (and, following us, others) use it at StarkWare. Note: ZK also has a safe, ergonomic and efficient smart contract language (Cairo). Developers can write and execute any smart contract offchain and guarantee its integrity onchain. You can write programs in Cairo (and in other languages) that you can prove in ZK. Challenges: - When it comes to UX and composability of smart contracts, it gets messy. - When there’s a computation that involves confidential data from more than one user, ZK isn’t good at solving it. For that you have to use a generalization of ZK called secure Multi Party Computation (MPC, I'll explain that too). Not impossible, but requires work. Next time: MPC. The END.
Eli Ben-Sasson | Starknet.io@EliBenSasson

Privacy matters – Difference between TEE, ZK, MPC and FHE Everyone is talking about Privacy on-chain these days, and a lot of cryptographic terms are discussed. As co-inventor of ZK STARKs (post-quantum secure ZK systems) I’ll explain these technologies, what they’re good for, and their limitations. This is a long explanation, so today we'll start with TEE: TEE stands for Trusted Execution Environment. I think of TEE as an attempt to solve the problems of Privacy and Integrity, but they have a serious Trust problem. Let's dive in 🤿 TEE - what is it exactly? - A TEE is like a computer that’s hidden inside an enclave (a place that no one can look into). - You send it information using a public key system, meaning everyone can send it encrypted data - Then, it can decrypt that data, process it with integrity, encrypt it back, sign it for integrity, and send it back to you (in encrypted form). In theory, it’s a bit like having a direct encrypted line to God, or to some trustworthy machine, and you ask it what to compute, and it does that without leaking any information, hence, you get privacy. The problem: This holds only in theory. Why? The mentioned enclave is a physical chip that sits inside a computer. Whoever is in possession of that computer and running it can mess around with the TEE and get it to leak information it's not supposed to. So the privacy you’re guaranteed by the brochures isn’t as tight as you’d think. The bigger problem: (aka the problem that implies you should never trust a TEE for running a truly decentralized blockchain) For a certain amount of $ someone (think Lazarus group) can extract the keys that a TEE uses to (a) decrypt your messages and (b) sign on the integrity of the computation it performs. Once the bad guys have this key, they can sign on *any* payload and also read your messages. It’s unlikely they’ll do this from afar to the TEE on your smartphone or laptop, which is why you can use it for your own wallet and for small sums. But, and this is the important part, you cannot have a consensus system relying on TEE for trust. So: TEEs can be used on end-user devices for securing small amounts of money, and they are OK as security theater, when there’s a central operator that you rely on (but in this case the system is better off acknowledging there’s a central party running it, and that it's not decentralized). TEEs cannot serve truly decentralized blockchains. Next time: ZK The END

English
64
78
474
162.8K
alexweb3dev retweetledi
Abhishek Singh
Abhishek Singh@0xlelouch_·
There’s only one path to greatness - the grind. At some point, you’ll find yourself standing between two versions of you your old self, full of comfort and familiarity, and your new self, chasing something extraordinary. It’s tempting to go back. Back to the simple joys, the easy wins, the comfort of being 'good enough.' But once you’ve seen the other side once you’ve glimpsed what greatness looks like, you can’t unsee it. The only way is forward. It’s the same in engineering. Once you understand how Arc and Mutex really work in Rust, or how Kubernetes orchestrates systems with surgical precision you can’t go back to 'just writing scripts' or 'running apps locally.' You’ve seen the deeper layers. You’ve seen how things really work. It’s not an easy path. But that’s the price of mastery once you’ve tasted depth, comfort becomes the enemy. Keep moving forward. The grind isn’t punishment, it’s transformation. Once you have seen the top, you can't help moving forward. And that's where the crazy fun is, to conquer something that's out of your reach right now.
Abhishek Singh tweet media
English
1
5
14
638
alexweb3dev retweetledi
Abhishek Singh
Abhishek Singh@0xlelouch_·
Legacy isn’t built from ambition, it’s built from mastery. Been reading a lot of @justinskycak posts lately, and it completely changed how I think about memory and recall. If you want to create something truly new, you have to become dangerously good at the fundamentals. We chase complex stuff so fast that we forget to revisit and recall the basics. But spaced repetition and active recall are what build the deep layers of understanding that unlock higher levels of abstraction where true creativity actually lives. Mastery is about remembering better. Not necessarily learning more. When I started learning Rust, I kept rushing to advanced concepts - async, lifetimes, ownership but it was when I slowed down, practiced spaced recall, and revisited the fundamentals that it all clicked. The deeper I went, the more creative my code became.
Abhishek Singh tweet media
English
3
3
85
5.6K
alexweb3dev retweetledi
shafu
shafu@shafu0x·
Code, test, deploy, refactor, and verify. Read, audit, fork, innovate, document, and teach. Study systems, protocols and incentives. Say no to hype and noise. Avoid exploits, debt, complacency and shortcuts. Relax. Victory is assured.
English
7
4
48
2.8K
alexweb3dev retweetledi
Justin Skycak
Justin Skycak@justinskycak·
Whatever skills are fundamental in your domain, you need to develop as strong a command over them as a musician’s command over their instrument, or a gymnast’s command over their body. That takes a massive amount of consistent practice over a long period of time – which is hard, which is why most people don’t do it, which is why you get such an outsized competitive advantage if you do.
English
4
30
295
8.5K
alexweb3dev retweetledi
pashov
pashov@pashov·
Study math. Study philology. Study physics. Study psychology. Study behavioural sciences. Study human relationships. Just study everyday. It's not something you only do in high school or in university - it must be your way of life, it's the formula you've been looking for🫡
English
13
18
221
6.8K