Skip to content

Featurize middleware types that are actually defined by the backend#94

Merged
arnaucube merged 1 commit intomainfrom
middleware-types-methods-backend
Feb 27, 2025
Merged

Featurize middleware types that are actually defined by the backend#94
arnaucube merged 1 commit intomainfrom
middleware-types-methods-backend

Conversation

@arnaucube
Copy link
Collaborator

At the middleware we were defining some types that actually are dependant on the backend no matter how we define them in the middleware.

For example, we were hardcoding the Hash and Value types and their related behaviour (eg. .to_fields()) to be based on the length of 4 field elements, but that's not a choice of the middleware, and in fact this is determined by the backend itself. On the same time, those types and related methods do not belong to the backend, since conceptually they are part of the middleware reasoning.

The intention of this PR is not to prematurely abstract the library, but to avoid inconsistencies where a type or parameter is defined in the middleware to have certain carachteristic and later in the backend it gets used differently. The idea is that those types and parameters (eg. lengths) have a single source of truth in the code; and in the case of the "base types" (hash, value, etc) this is determined by the backend being used under the hood, not by a choice of the middleware parameters.

The idea with this approach, is that the frontend & middleware should not need to import the proving library used by the backend (eg. plonky2, plonky3, etc).

As mentioned earlier, the Hash and Value types are types belonging at the middleware, and is the middleware who reasons about them, but depending on the backend being used, the Hash and Value types will have different sizes. So it's the backend being used who actually defines their nature under the hood. For example with a plonky2 backend, these types will have a length of 4 field elements, whereas with a plonky3 backend they will have a length of 8 field eleements.

Note that his approach does not introduce new traits or abstract code, just makes use of rust features to define 'base types' that are being used in the middleware.

@arnaucube arnaucube added the impl code to implement label Feb 27, 2025
@arnaucube arnaucube added this to the Milestone 2 milestone Feb 27, 2025
@arnaucube arnaucube requested a review from ax0 February 27, 2025 07:54
Copy link
Collaborator

@ax0 ax0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@arnaucube arnaucube force-pushed the middleware-types-methods-backend branch from 2254157 to 67898d4 Compare February 27, 2025 13:01
At the middleware we were defining some types that actually are dependant on the
backend no matter how we define them in the middleware.

For example, we were hardcoding the `Hash` and `Value` types and their related
behaviour (eg. `.to_fields()`) to be based on the length of 4 field elements,
but that's not a choice of the middleware, and in fact this is determined by the
backend itself. On the same time, those types and related methods do not belong
to the backend, since conceptually they are part of the middleware reasoning.

The intention of this PR is not to prematurely abstract the library, but to
avoid inconsistencies where a type or parameter is defined in the middleware to
have certain carachteristic and later in the backend it gets used differently.
The idea is that those types and parameters (eg. lengths) have a single source
of truth in the code; and in the case of the "base types" (hash, value, etc)
this is determined by the backend being used under the hood, not by a choice of
the middleware parameters.

The idea with this approach, is that the frontend & middleware should not need
to import the proving library used by the backend (eg. plonky2, plonky3, etc).

As mentioned earlier, the `Hash` and `Value` types are types belonging at the
middleware, and is the middleware who reasons about them, but depending on the
backend being used, the `Hash` and `Value` types will have different sizes. So
it's the backend being used who actually defines their nature under the hood.
For example with a plonky2 backend, these types will have a length of 4 field
elements, whereas with a plonky3 backend they will have a length of 8 field
eleements.

Note that his approach does not introduce new traits or abstract code, just
makes use of rust features to define 'base types' that are being used in the
middleware.
@arnaucube arnaucube force-pushed the middleware-types-methods-backend branch from 67898d4 to 945f5e0 Compare February 27, 2025 13:05
@arnaucube
Copy link
Collaborator Author

(rebased to latest main branch changes)

@arnaucube arnaucube merged commit 423605f into main Feb 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impl code to implement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants