Comments (5)
Perhaps the depth of the single tier TSMT could be parameterised.
Setting the depth much smaller than 64 could become a significant attack vector (at least if we keep colliding keys in a sorted list). The main factor is the cost of generating key collisions. I estimate that with RPO, finding a 64-bit pre-image probably costs many million dollars (probably north of $100M) and so the cost of generating more than a few hundred keys with the same 64-bits prefix as some existing key is prohibitively expensive - even in the medium term.
16-bit (and even 32-bit) pre-images are pretty easy to find though. So, this opens up various attack vectors (e.g., someone could make accessing a specific key in account storage prohibitively expensive). I'm sure these can be worked around, but it does require users to be aware of these edge-case behaviors and is probably undesirable.
from miden-vm.
Do you think it makes sense to wait for that until we have a first testnet?
from miden-vm.
My 2 cents re: complexity. I will not touch on whether applying these suggestions would make using TSMT still useful.
I don't think the data structure is fundamentally too complex; i.e. it is relatively simple to explain, and understand how it works at a high level. I believe there are 2 low-hanging fruits to reduce the accidental complexity of the current implementations:
- Refactor the Rust code
- There are certain patterns that are unintuitive and could lead to bugs, that could simply be refactor out. For example, the
ValueStore::get_first(prefix)
method is typically used in conjunction with theleaf_exists
output ofNodeStore::get_proof()
, such as here.get_first(prefix)
in theory could return an entry from another node, but if we get information from elsewhere that a leaf exists atindex
, then both methods in conjunction end up giving the key/value stored at some leaf. I would vote for a refactor where there's a single method along the lines ofget_key_value_at_leaf(leaf_index)
to get that information. - Define more newtypes (across the codebase) instead of using
RpoDigest
forkey
, account hash, and many more that I currently can't think of off the top of my head. - Better naming, as captured in 0xPolygonMiden/crypto#208
- Properly document the behavior and non-deterministic inputs of the MASM stdlib functions
- Specifically, it would be good to not only know how the advice map and Merkle store need to be loaded, but provide an explanation of how these are used internally.
from miden-vm.
The simplest alternative
Perhaps the simplest alternative is to reduce the number of tiers in TSMT to just one (at depth 64). This would make it almost equivalent to the [SimpleSmt]
Perhaps the depth of the single tier TSMT could be parameterised. The depth of the TSMT would be use case specific i.e. for account vaults we would use a single tier TSMT of depth 16 (or maybe even less), for account and nullifier db's we would have a TSMT of depth 64. For account storage it would be the responsibility of the user to specify the depth of the TSMT as part of the type information.
Alternative with 2 tiers
We could also reduce the number of tiers to 2 - at depth 32 and 64 (or 16 and 64). This would not be as simple as the previous approach, but also, would be much more efficient for trees containing a small number of values.
Similarly we could paramaterise the depth of the upper tier in the 2 tier construction.
I'm in favour of a single tier TSMT with parameterisable depth as through the depth configurability it gives a good balance between performance and simplicity for many use cases.
from miden-vm.
Related Issues (20)
- Semantics of `ext2mul`
- Faster modular reduction for Falcon signature verification HOT 1
- Implement `procref` instruction HOT 1
- Consider refactoring the semantics of `DYN` operation
- Consider imposing restrictions on `DYN` operation
- Documentation link in the README is broken HOT 3
- Add `get_module(path)` method to the `Library` trait. HOT 1
- Testing Falcon signature HOT 10
- Modifying miden-lib/asm/sat/internal/asset.masm results in compilation failures HOT 1
- Serialize `ProgramAst` into files to allow compiling Note Scripts HOT 2
- Refactor `Process` struct
- Add `emit` assembly instruction HOT 2
- Add logging to the assembler HOT 3
- Decorator bug report HOT 1
- Update `std::math::u64` according to the new u32 refactoring. HOT 1
- Add leading/trailing ones and zero count instructions HOT 2
- Make `u32sh*` and `u32rot*` instructions always checked HOT 1
- Create `assert_lt` instruction HOT 1
- Add examples for hashing with `sha256` and `blake3` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miden-vm.