Skip to content

Commit

Permalink
use twenty-first v0.10 in Triton VM
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Dec 22, 2022
1 parent 3a891e4 commit 79189cb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion constraint-evaluation-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ version = "1"
default-features = false

[dependencies]
twenty-first = "0.9"
twenty-first = "0.10"
triton-vm = { path = "../triton-vm" }
itertools = "0.10"
2 changes: 1 addition & 1 deletion triton-opcodes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ version = "1"
default-features = false

[dependencies]
twenty-first = "0.9"
twenty-first = "0.10"
anyhow = "1.0"
itertools = "0.10.5"
num-traits = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion triton-profiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["triton-vm", "stark", "profiler"]
categories = ["cryptography", "mathematics"]

[dependencies]
twenty-first = { version = "0.9.0" }
twenty-first = "0.10"
anyhow = "1.0"
bincode = "1.3"
blake3 = "1.2"
Expand Down
2 changes: 1 addition & 1 deletion triton-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ version = "1"
default-features = false

[dependencies]
twenty-first = "0.9"
twenty-first = "0.10"
triton-opcodes = { version = "0.1", path = "../triton-opcodes" }
triton-profiler = "0.9"
anyhow = "1.0"
Expand Down
13 changes: 9 additions & 4 deletions triton-vm/src/table/hash_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ impl ExtHashTable {
.map(|i| {
let round_constant_idx =
NUM_ROUND_CONSTANTS * (i - 1) + round_constant_col_index;
let round_constant_needed = constant(ROUND_CONSTANTS[round_constant_idx]);
round_number_deselector(i)
* (round_constant_input.clone() - round_constant_needed)
* (round_constant_input.clone()
- circuit_builder.b_constant(ROUND_CONSTANTS[round_constant_idx]))
})
.sum();
consistency_constraint_circuits.push(round_constant_constraint_circuit);
Expand Down Expand Up @@ -303,7 +303,9 @@ impl ExtHashTable {
let after_mds = (0..STATE_SIZE)
.map(|i| {
(0..STATE_SIZE)
.map(|j| constant(MDS[i * STATE_SIZE + j]) * after_sbox[j].clone())
.map(|j| {
circuit_builder.b_constant(MDS[i * STATE_SIZE + j]) * after_sbox[j].clone()
})
.sum::<ConstraintCircuitMonad<_, _>>()
})
.collect_vec();
Expand All @@ -324,7 +326,10 @@ impl ExtHashTable {
let before_mds = (0..STATE_SIZE)
.map(|i| {
(0..STATE_SIZE)
.map(|j| constant(MDS_INV[i * STATE_SIZE + j]) * before_constants[j].clone())
.map(|j| {
circuit_builder.b_constant(MDS_INV[i * STATE_SIZE + j])
* before_constants[j].clone()
})
.sum::<ConstraintCircuitMonad<_, _>>()
})
.collect_vec();
Expand Down
4 changes: 2 additions & 2 deletions triton-vm/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use ndarray::Axis;

use triton_opcodes::program::Program;
use twenty_first::shared_math::b_field_element::BFieldElement;
use twenty_first::shared_math::b_field_element::BFIELD_ZERO;
use twenty_first::shared_math::rescue_prime_regular::NUM_ROUNDS;
use twenty_first::shared_math::rescue_prime_regular::ROUND_CONSTANTS;
use twenty_first::shared_math::rescue_prime_regular::STATE_SIZE;
Expand Down Expand Up @@ -147,14 +148,13 @@ impl AlgebraicExecutionTrace {
round_number: usize,
) -> [BFieldElement; NUM_ROUND_CONSTANTS] {
match round_number {
i if i == 0 || i == NUM_ROUNDS + 1 => [0_u64; NUM_ROUND_CONSTANTS],
i if i == 0 || i == NUM_ROUNDS + 1 => [BFIELD_ZERO; NUM_ROUND_CONSTANTS],
i if i <= NUM_ROUNDS => ROUND_CONSTANTS
[NUM_ROUND_CONSTANTS * (i - 1)..NUM_ROUND_CONSTANTS * i]
.try_into()
.unwrap(),
_ => panic!("Round with number {round_number} does not have round constants."),
}
.map(BFieldElement::new)
}
}

Expand Down

0 comments on commit 79189cb

Please sign in to comment.