mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-04 14:53:08 +00:00
addressed final comments
This commit is contained in:
parent
cdaabfe9f2
commit
90f7ba9a23
@ -128,10 +128,6 @@ modexp_iszero_return:
|
||||
// stack: e != 0, len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
|
||||
%jumpi(modexp_loop)
|
||||
// end of modexp_loop
|
||||
// stack: len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
|
||||
%pop10
|
||||
// stack: retdest
|
||||
JUMP
|
||||
len_zero:
|
||||
// stack: len, b_loc, e_loc, m_loc, out_loc, s1, s2, s3, s4, s5, retdest
|
||||
%pop10
|
||||
|
||||
@ -164,4 +164,4 @@ len_zero:
|
||||
// stack: len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest
|
||||
%pop8
|
||||
// stack: retdest
|
||||
JUMP
|
||||
JUMP
|
||||
|
||||
@ -404,18 +404,17 @@ impl<'a> Interpreter<'a> {
|
||||
.debug_offsets
|
||||
.contains(&self.generation_state.registers.program_counter)
|
||||
{
|
||||
// TODO: uncomment
|
||||
// println!("At {}, stack={:?}", self.offset_name(), self.stack());
|
||||
println!("At {}, stack={:?}", self.offset_name(), self.stack());
|
||||
} else if let Some(_label) = self.offset_label() {
|
||||
// println!("At {label}");
|
||||
println!("At {label}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// fn offset_name(&self) -> String {
|
||||
// KERNEL.offset_name(self.generation_state.registers.program_counter)
|
||||
// }
|
||||
fn offset_name(&self) -> String {
|
||||
KERNEL.offset_name(self.generation_state.registers.program_counter)
|
||||
}
|
||||
|
||||
fn offset_label(&self) -> Option<String> {
|
||||
KERNEL.offset_label(self.generation_state.registers.program_counter)
|
||||
|
||||
@ -475,7 +475,7 @@ fn test_modmul_bignum_all() -> Result<()> {
|
||||
let b = gen_bignum(bit_size);
|
||||
let m = gen_bignum(bit_size);
|
||||
if !m.is_zero() {
|
||||
let output = a.clone() * b.clone() % m.clone();
|
||||
let output = &a * &b % &m;
|
||||
test_modmul_bignum(a, b, m, output)?;
|
||||
}
|
||||
|
||||
@ -483,20 +483,20 @@ fn test_modmul_bignum_all() -> Result<()> {
|
||||
let b = max_bignum(bit_size);
|
||||
let m = max_bignum(bit_size);
|
||||
if !m.is_zero() {
|
||||
let output = a.clone() * b.clone() % m.clone();
|
||||
let output = &a * &b % &m;
|
||||
test_modmul_bignum(a, b, m, output)?;
|
||||
}
|
||||
}
|
||||
|
||||
let inputs = test_data_biguint(TEST_DATA_BIGNUM_INPUTS);
|
||||
let modmul_outputs = test_data_biguint(TEST_DATA_MODMUL_OUTPUTS);
|
||||
let mut modmul_outputs_iter = modmul_outputs.iter();
|
||||
let mut modmul_outputs_iter = modmul_outputs.into_iter();
|
||||
for a in &inputs {
|
||||
for b in &inputs {
|
||||
// For m, skip the first input, which is zero.
|
||||
for m in &inputs[1..] {
|
||||
let output = modmul_outputs_iter.next().unwrap();
|
||||
test_modmul_bignum(a.clone(), b.clone(), m.clone(), output.clone())?;
|
||||
test_modmul_bignum(a.clone(), b.clone(), m.clone(), output)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -523,7 +523,7 @@ fn test_modexp_bignum_all() -> Result<()> {
|
||||
let e = max_bignum(*exp_bit_size);
|
||||
let m = max_bignum(*bit_size);
|
||||
if !m.is_zero() {
|
||||
let output = b.clone().modpow(&e, &m);
|
||||
let output = b.modpow(&e, &m);
|
||||
test_modexp_bignum(b, e, m, output)?;
|
||||
}
|
||||
}
|
||||
@ -531,14 +531,14 @@ fn test_modexp_bignum_all() -> Result<()> {
|
||||
|
||||
let inputs = test_data_biguint(TEST_DATA_BIGNUM_INPUTS);
|
||||
let modexp_outputs = test_data_biguint(TEST_DATA_MODEXP_OUTPUTS);
|
||||
let mut modexp_outputs_iter = modexp_outputs.iter();
|
||||
let mut modexp_outputs_iter = modexp_outputs.into_iter();
|
||||
for b in &inputs {
|
||||
// Include only smaller exponents, to keep tests from becoming too slow.
|
||||
for e in &inputs[..7] {
|
||||
// For m, skip the first input, which is zero.
|
||||
for m in &inputs[1..] {
|
||||
let output = modexp_outputs_iter.next().unwrap();
|
||||
test_modexp_bignum(b.clone(), e.clone(), m.clone(), output.clone())?;
|
||||
test_modexp_bignum(b.clone(), e.clone(), m.clone(), output)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,8 +202,8 @@ impl<F: Field> GenerationState<F> {
|
||||
let m_biguint = mem_vec_to_biguint(m);
|
||||
|
||||
let prod = a_biguint * b_biguint;
|
||||
let quo = prod.clone() / m_biguint.clone();
|
||||
let rem = prod - quo.clone() * m_biguint;
|
||||
let quo = &prod / &m_biguint;
|
||||
let rem = prod - m_biguint * &quo;
|
||||
|
||||
(biguint_to_mem_vec(rem), biguint_to_mem_vec(quo))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user