Skip to content
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

Update Cairo and Scarb version to the latest 2.7.0 version #139

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.6.3
starknet-foundry 0.24.0
scarb 2.7.0
starknet-foundry 0.27.0
4 changes: 2 additions & 2 deletions examples/starknet/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "starknet"
version = "0.1.0"
edition = "2023_10"
edition = "2024_07"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
cairo_verifier = { path = ".." }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.20.1" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.27.0" }

[[target.starknet-contract]]
casm = true
4 changes: 2 additions & 2 deletions fact_registry/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "fact_registry"
version = "0.1.0"
edition = "2023_10"
edition = "2024_07"

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
cairo_verifier = { path = ".." }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.24.0" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.27.0" }

[[target.starknet-contract]]
casm = true
2 changes: 1 addition & 1 deletion src/air/layouts/dex/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl DexPublicInputImpl of PublicInputTrait {
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
2 changes: 1 addition & 1 deletion src/air/layouts/recursive/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl RecursivePublicInputImpl of PublicInputTrait {
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
2 changes: 1 addition & 1 deletion src/air/layouts/recursive_with_poseidon/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl RecursiveWithPoseidonPublicInputImpl of PublicInputTrait {
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
2 changes: 1 addition & 1 deletion src/air/layouts/small/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl SmallPublicInputImpl of PublicInputTrait {
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
2 changes: 1 addition & 1 deletion src/air/layouts/starknet/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl StarknetPublicInputImpl of PublicInputTrait {
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
2 changes: 1 addition & 1 deletion src/air/layouts/starknet_with_keccak/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl StarknetWithKeccakPublicInputImpl of PublicInputTrait {
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
5 changes: 3 additions & 2 deletions src/air/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ trait PublicInputTrait {
fn validate(self: @PublicInput, stark_domains: @StarkDomains);
}

// Computes the hash of the public input, which is used as the initial seed for the Fiat-Shamir heuristic.
// Computes the hash of the public input, which is used as the initial seed for the Fiat-Shamir
// heuristic.
fn get_public_input_hash(public_input: @PublicInput) -> felt252 {
// Main page hash.
let mut main_page_hash_state = PedersenTrait::new(0);
Expand Down Expand Up @@ -178,7 +179,7 @@ fn verify_cairo1_public_input(public_input: @PublicInput) -> (felt252, felt252)
.extract_range_unchecked(initial_pc.try_into().unwrap(), memory.len() - output_len);
let program_hash = poseidon_hash_span(program);

// 2. Output segment
// 2. Output segment
let output = memory.extract_range_unchecked(memory.len() - output_len, output_len);
let output_hash = poseidon_hash_span(output);
(program_hash, output_hash)
Expand Down
2 changes: 1 addition & 1 deletion src/air/public_memory.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl PageImpl of PageTrait {

let current = *self.at(offset);

// TODO is this needed? If not we can just use slice directly
// TODO is this needed? If not we can just use slice directly
assert(current.address == (addr + i).into(), 'Invalid address');
arr.append(current.value);
i += 1;
Expand Down
80 changes: 40 additions & 40 deletions src/common/blake2s.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cairo_verifier::common::flip_endianness::FlipEndiannessTrait;
use core::integer::u32_wrapping_add;
use core::num::traits::WrappingAdd;

fn blake2s(data: Array<u32>) -> u256 {
let mut state = blake2s_init();
Expand Down Expand Up @@ -125,83 +125,83 @@ fn blake2s_compress(mut s: blake2s_state, m: Array<u32>) -> blake2s_state {
// ROUND function begin

// 0 - 0,4,8,12
v0 = u32_wrapping_add(u32_wrapping_add(v0, v4), *m_span.at(*sigma[0]));
v0 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v0, v4), *m_span.at(*sigma[0]));
v12 = rotr16(v12 ^ v0);
v8 = u32_wrapping_add(v8, v12);
v8 = WrappingAdd::wrapping_add(v8, v12);
v4 = rotr12(v4 ^ v8);
v0 = u32_wrapping_add(u32_wrapping_add(v0, v4), *m_span.at(*sigma[1]));
v0 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v0, v4), *m_span.at(*sigma[1]));
v12 = rotr8(v12 ^ v0);
v8 = u32_wrapping_add(v8, v12);
v8 = WrappingAdd::wrapping_add(v8, v12);
v4 = rotr7(v4 ^ v8);

// 1 - 1,5,9,13
v1 = u32_wrapping_add(u32_wrapping_add(v1, v5), *m_span.at(*sigma[2]));
v1 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v1, v5), *m_span.at(*sigma[2]));
v13 = rotr16(v13 ^ v1);
v9 = u32_wrapping_add(v9, v13);
v9 = WrappingAdd::wrapping_add(v9, v13);
v5 = rotr12(v5 ^ v9);
v1 = u32_wrapping_add(u32_wrapping_add(v1, v5), *m_span.at(*sigma[3]));
v1 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v1, v5), *m_span.at(*sigma[3]));
v13 = rotr8(v13 ^ v1);
v9 = u32_wrapping_add(v9, v13);
v9 = WrappingAdd::wrapping_add(v9, v13);
v5 = rotr7(v5 ^ v9);

// 2 - 2,6,10,14
v2 = u32_wrapping_add(u32_wrapping_add(v2, v6), *m_span.at(*sigma[4]));
v2 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v2, v6), *m_span.at(*sigma[4]));
v14 = rotr16(v14 ^ v2);
v10 = u32_wrapping_add(v10, v14);
v10 = WrappingAdd::wrapping_add(v10, v14);
v6 = rotr12(v6 ^ v10);
v2 = u32_wrapping_add(u32_wrapping_add(v2, v6), *m_span.at(*sigma[5]));
v2 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v2, v6), *m_span.at(*sigma[5]));
v14 = rotr8(v14 ^ v2);
v10 = u32_wrapping_add(v10, v14);
v10 = WrappingAdd::wrapping_add(v10, v14);
v6 = rotr7(v6 ^ v10);

// 3 - 3,7,11,15
v3 = u32_wrapping_add(u32_wrapping_add(v3, v7), *m_span.at(*sigma[6]));
v3 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v3, v7), *m_span.at(*sigma[6]));
v15 = rotr16(v15 ^ v3);
v11 = u32_wrapping_add(v11, v15);
v11 = WrappingAdd::wrapping_add(v11, v15);
v7 = rotr12(v7 ^ v11);
v3 = u32_wrapping_add(u32_wrapping_add(v3, v7), *m_span.at(*sigma[7]));
v3 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v3, v7), *m_span.at(*sigma[7]));
v15 = rotr8(v15 ^ v3);
v11 = u32_wrapping_add(v11, v15);
v11 = WrappingAdd::wrapping_add(v11, v15);
v7 = rotr7(v7 ^ v11);

// 4 - 0,5,10,15
v0 = u32_wrapping_add(u32_wrapping_add(v0, v5), *m_span.at(*sigma[8]));
v0 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v0, v5), *m_span.at(*sigma[8]));
v15 = rotr16(v15 ^ v0);
v10 = u32_wrapping_add(v10, v15);
v10 = WrappingAdd::wrapping_add(v10, v15);
v5 = rotr12(v5 ^ v10);
v0 = u32_wrapping_add(u32_wrapping_add(v0, v5), *m_span.at(*sigma[9]));
v0 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v0, v5), *m_span.at(*sigma[9]));
v15 = rotr8(v15 ^ v0);
v10 = u32_wrapping_add(v10, v15);
v10 = WrappingAdd::wrapping_add(v10, v15);
v5 = rotr7(v5 ^ v10);

// 5 - 1,6,11,12
v1 = u32_wrapping_add(u32_wrapping_add(v1, v6), *m_span.at(*sigma[10]));
v1 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v1, v6), *m_span.at(*sigma[10]));
v12 = rotr16(v12 ^ v1);
v11 = u32_wrapping_add(v11, v12);
v11 = WrappingAdd::wrapping_add(v11, v12);
v6 = rotr12(v6 ^ v11);
v1 = u32_wrapping_add(u32_wrapping_add(v1, v6), *m_span.at(*sigma[11]));
v1 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v1, v6), *m_span.at(*sigma[11]));
v12 = rotr8(v12 ^ v1);
v11 = u32_wrapping_add(v11, v12);
v11 = WrappingAdd::wrapping_add(v11, v12);
v6 = rotr7(v6 ^ v11);

// 6 - 2,7,8,13
v2 = u32_wrapping_add(u32_wrapping_add(v2, v7), *m_span.at(*sigma[12]));
v2 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v2, v7), *m_span.at(*sigma[12]));
v13 = rotr16(v13 ^ v2);
v8 = u32_wrapping_add(v8, v13);
v8 = WrappingAdd::wrapping_add(v8, v13);
v7 = rotr12(v7 ^ v8);
v2 = u32_wrapping_add(u32_wrapping_add(v2, v7), *m_span.at(*sigma[13]));
v2 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v2, v7), *m_span.at(*sigma[13]));
v13 = rotr8(v13 ^ v2);
v8 = u32_wrapping_add(v8, v13);
v8 = WrappingAdd::wrapping_add(v8, v13);
v7 = rotr7(v7 ^ v8);

// 7 - 3,4,9,14
v3 = u32_wrapping_add(u32_wrapping_add(v3, v4), *m_span.at(*sigma[14]));
v3 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v3, v4), *m_span.at(*sigma[14]));
v14 = rotr16(v14 ^ v3);
v9 = u32_wrapping_add(v9, v14);
v9 = WrappingAdd::wrapping_add(v9, v14);
v4 = rotr12(v4 ^ v9);
v3 = u32_wrapping_add(u32_wrapping_add(v3, v4), *m_span.at(*sigma[15]));
v3 = WrappingAdd::wrapping_add(WrappingAdd::wrapping_add(v3, v4), *m_span.at(*sigma[15]));
v14 = rotr8(v14 ^ v3);
v9 = u32_wrapping_add(v9, v14);
v9 = WrappingAdd::wrapping_add(v9, v14);
v4 = rotr7(v4 ^ v9);

r += 1;
Expand Down Expand Up @@ -252,9 +252,9 @@ fn blake2s_update(mut s: blake2s_state, in: Array<u32>) -> blake2s_state {
};

// blake2s_increment_counter
s.t0 = u32_wrapping_add(s.t0, 64_u32);
s.t0 = WrappingAdd::wrapping_add(s.t0, 64_u32);
if s.t0 < 64_u32 {
s.t1 = u32_wrapping_add(s.t1, 1);
s.t1 = WrappingAdd::wrapping_add(s.t1, 1);
}

s = blake2s_compress(s, new_buf);
Expand All @@ -268,9 +268,9 @@ fn blake2s_update(mut s: blake2s_state, in: Array<u32>) -> blake2s_state {
}

// blake2s_increment_counter
s.t0 = u32_wrapping_add(s.t0, 64_u32);
s.t0 = WrappingAdd::wrapping_add(s.t0, 64_u32);
if s.t0 < 64_u32 {
s.t1 = u32_wrapping_add(s.t1, 1);
s.t1 = WrappingAdd::wrapping_add(s.t1, 1);
}

let mut compress_in = ArrayTrait::new();
Expand Down Expand Up @@ -324,10 +324,10 @@ fn blake2s_update(mut s: blake2s_state, in: Array<u32>) -> blake2s_state {
fn blake2s_final(mut s: blake2s_state) -> u256 {
assert(s.f0 == 0, 'blake2s_is_lastblock');

// blake2s_increment_counter
s.t0 = u32_wrapping_add(s.t0, s.buflen * 4);
// blake2s_increment_counter
s.t0 = WrappingAdd::wrapping_add(s.t0, s.buflen * 4);
if s.t0 < s.buflen {
s.t1 = u32_wrapping_add(s.t1, 1);
s.t1 = WrappingAdd::wrapping_add(s.t1, 1);
}

s.f0 = 0xffffffff;
Expand Down
Loading
Loading