-
Notifications
You must be signed in to change notification settings - Fork 18
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
[feat] modular add v2 #510
Conversation
INT-2260 Runtime for modular arithmetic and elliptic curve operations
Relies on being able to figure out moduli handling. |
let x_biguint = limbs_to_biguint(&x, LIMB_SIZE); | ||
let y_biguint = limbs_to_biguint(&y, LIMB_SIZE); | ||
|
||
let z_biguint = (x_biguint + y_biguint) % &self.modulus; |
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.
are you doing it this way for convenience for now? shouldn't this be owned by ExprBuilder? also you don't handle Sub
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.
- ExprBuilder currently doesn't do the "execute" part explicitly. It kinda does it as part of trace gen, but need some work to get it done more cleanly.
- doing sub here requires
ExprBuilder
to supportselect
Since this PR was intended for register-heap adapter, going to add the above in a followup PR
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 this execute
thing about ExprBuilder will need to be resolved right, as that is how we will plan to use it throughout.
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.
Adapter: shouldn't be using old MemoryHeap stuff because the pointer needs to come from RV32 register, not single field element cell.
Integration: only handles Add and not Sub (maybe that was a todo), but also doesn't use ExprBuilder so I'm confused.
e9a5dbb
to
243e09d
Compare
pub struct Rv32HeapAdapterCols<T, const READ_SIZE: usize, const WRITE_SIZE: usize> { | ||
pub read_aux: [Rv32RegisterHeapReadAuxCols<T, READ_SIZE>; 2], | ||
pub write_aux: Rv32RegisterHeapWriteAuxCols<T, WRITE_SIZE>, | ||
pub read_addresses: [HeapAddress<T, T>; 2], |
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 should be addressed when you finish the AIR, but I don't think HeapAddress
is optimal: the address space for register is fixed to 1 so it shouldn't be a column. The address space for memory is the same address read/writes so it should be at most a single column for e
. Also at present for intrinsics I decided we can just fix that address space to 2
. So HeapAddress
can save some columns.
|
||
#[repr(C)] | ||
#[derive(Clone, Debug, AlignedBorrow)] | ||
pub struct Rv32RegisterHeapReadAuxCols<T, const N: usize> { |
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.
In general, adapter specific columns and methods should be put in the adapter file and not in memory/
since that should be kept for core memory functionality. I have moved everything for registerheap out. The old MemoryHeap__
structs and methods should eventually be moved out too.
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.
Additionally, since we aren't separating by module, any naming involving register should specify RV32 register (since RV64 would be different if we ever chose to support it).
b16146e
to
af2b1bd
Compare
* modular add v2 * use register * dont put range checker bits as config * add todo * fix test * fix test * refactor: move structs out of memory into adapter mod * add todo * fix --------- Co-authored-by: Jonathan Wang <[email protected]>
part of INT-2260
moved some utils functions so touched many files, but only
modular_v2
andrv32_heap.rs
are relevantTODO for follow up PRs
select
to field expression framework to support add or sub in the same chip