Comments (3)
I wouldn't suffice but it would make things simpler. Let's create an issue to migrate to core.
from lambdaworks.
leveraging Add
and its friends was our approach too at first. We hit a snag when we implemented complex formulas for field extensions and elliptic curves. We noticed that unless the operations are defined for all combinations of (&F, &F), (F, &F), (&F, F), (F, F), the formulas end up being very unreadable because of explosions of parenthesis and & symbols. The syntax to add all those trait bounds seemed very convoluted, specially for the (&T, &T) case where we need to ask for a type T to have implemented Add for &T. Also, for fields, all the operations only make sense when OutputType equal to F, which made the syntax also way more verbose.
We came up with this solution that in our opinion made things simple for the trait code and for the users of the trait to implement it. And formulas can be read easily.
All of the std::ops are implemented off the operations in the trait now. I wonder if changing those to core::ops
would suffice to have support for no_std
easier. But I'm not familiar with that.
from lambdaworks.
Regarding the complexity around Add
for the different combinations, it can be complex, but rust
has tools to make it easier.
We could leverage macro_rules
like most libraries, including how rust
implements the trait for its core types(u8
, u16
, etc.). Or, if we are particularly inspired, we could write a proc macro for something like #[derive(Add)]
at the expense of compile time.
Despite the extra work, it's better in the long term if we ever decide to layer traits. For example, let's say we want to define a Hash2Curve
trait which requires some mathematical operations on Field
types. Without it having the operations on the Field
trait itself, we'd have to define Hash2Curve
in a way like:
pub trait Hash2Curve {
type Field: Field + Add<Rhs = Self::Field> + ...;
...
}
We could not define those trait bounds on the trait, but then type inference within the compiler or specific use cases would deny the usage of those traits. This means we could leverage the .add
method defined on the Field
trait, but ergonomically this leaves much to be desired.
from lambdaworks.
Related Issues (20)
- Chore: rayon feature -> parallel in math module
- Parallelize Stark Prover round2: transitions and accumulated results HOT 1
- Stark Prover Round1: RAP. Instrument + Parallelization + Optimization
- Feat (perf): Investigate pre-allocating the vector in extend() and merge() from Multilinear Polynomials
- Unsigned Integer limb.to_hex() returns string of size 14, ignoring 2 characters
- Feat(perf): Benchmark Plonky2 bit reversal vs current implementation HOT 1
- Feat(perf): Benchmark alternative algorithm for computation of eq poly evaluations within DenseMultilinearPoly::evaluate()
- Update Winterfell adapter to the new AIR
- Unify all the transcripts under one API
- MerkleTree: Add parallelization of inner nodes HOT 1
- Add Merkle Mountain Range HOT 1
- Make curves and their fields easier to find
- Unable to verify a Cairo 1 proof HOT 4
- Add delayed-reduction loops for Mersenne 31
- Optimization (Montgomery): Add fast from_u64 conversion using pre-computed lookup Table
- Optimization (Montgomery): Add mul for small values
- Add Jacobian Coordinates for Short Weierstrass HOT 2
- CUDA - Icicle
- Extract new AIR design from AIR Workshop
- Does the stark prover support (perfect)zero knowledge? 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 lambdaworks.