let alpha_challenge_pointer_write = library.kmalloc(EXTENSION_DEGREE as u32);
let alpha_challenge_pointer_read =
alpha_challenge_pointer_write + bfe!(EXTENSION_DEGREEas u64 - 1);
let beta_challenge_pointer_write = library.kmalloc(EXTENSION_DEGREE as u32);
let beta_challenge_pointer_read =
beta_challenge_pointer_write + bfe!(EXTENSION_DEGREE as u64 - 1);
let gamma_challenge_pointer_write = library.kmalloc(EXTENSION_DEGREE as u32);
let gamma_challenge_pointer_read =
gamma_challenge_pointer_write + bfe!(EXTENSION_DEGREE as u64 - 1);
This is necessary because [kmalloc] only returns one BFieldElement, the address of the 1st word of the allocated section, which in the above example are called "write" addresses since this is the pointer you need if you are writing to this section of memory. If the type signature of kmalloc was changed to return two BFieldElements, then both the "write" and the "read" address (the last word of the allocated section) could be returned.
This is a common pattern:
This is necessary because [
kmalloc
] only returns oneBFieldElement
, the address of the 1st word of the allocated section, which in the above example are called "write" addresses since this is the pointer you need if you are writing to this section of memory. If the type signature ofkmalloc
was changed to return twoBFieldElement
s, then both the "write" and the "read" address (the last word of the allocated section) could be returned.