-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor provable core #1507
Refactor provable core #1507
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was moved here from bindings/lib/provable-bigint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was moved here from bindings/lib/provable-snarky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is the CircuitValue
part of what used to be src/lib/circuit-value.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole code used to be in field.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these interfaces used to be in snarky.d.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is the Unconstrained
part of what used to be src/lib/circuit-value.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grouping things into the provable-types
folder and creating the unconstrained
file makes things easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apart from existsAsync()
, this now also has the exists()
function we use internally a lot and that Provable.witness
uses
import { Field } from './core.js'; | ||
import { Field as Fp } from '../provable/field-bigint.js'; | ||
import { Fp } from '../bindings/crypto/finite-field.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why you decided to move this to the bindings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! The Field
module from field-bigint.ts
is a wrapper around the Fp
module which was always in bindings/crypto
. field-bigint.ts
adds other stuff to it like toBytes
and toJSON
methods which have nothing to do with the core finite field arithmetic. It's basically the version of Field
used by mina-signer
.
It's hard to track dependencies when logic is wrapped and reexported multiple times. I wanted to make it more explicit where this Fp
(bigint field arithmetic) logic actually comes from, and remove the dependency on the mina-signer middle-man code where not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok great. That logic makes a lot of sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grouping things into the provable-types
folder and creating the unconstrained
file makes things easier to understand.
The general goal here is to make the structure of core provable code more logical.
closes #1504
Field
, by introducing a low-level stub modulefield-constructor.ts
FieldVar
into its own lower level moduleexists()
Field.isEven()
Provable<T>
to its own fileProvable<T>
48b897cProvable<T>
a type instead of interace, because we don't use interfaces in general and they behave slightly different than types in subtle ways 82fe43bcircuit-value.ts
into separate files forCircuitValue
,Struct
andUnconstrained
bindings: o1-labs/o1js-bindings#258