Skip to content

Commit 146ae0b

Browse files
Update cairo in corelib and test-utils package (#1548)
* Update cairo in corelib and test-utils package * Remove corelib.patch * Revert "Remove corelib.patch" This reverts commit 81d632e. * Compile scarb project * Rename revision to ref in pull_external_projects.py The --branch flag accepts a branch or tag, not a revision (commit SHA). --------- Co-authored-by: Gabriel Bosio <38794644+gabrielbosio@users.noreply.github.com> Co-authored-by: gabrielbosio <gabrielbosio95@gmail.com>
1 parent af63e02 commit 146ae0b

File tree

21 files changed

+101
-93
lines changed

21 files changed

+101
-93
lines changed

corelib/Scarb.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ version = 1
33

44
[[package]]
55
name = "core"
6-
version = "2.14.1-dev.1"
6+
version = "2.15.0"

corelib/Scarb.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "core"
3-
version = "2.14.1-dev.1"
3+
version = "2.15.0"
44
edition = "2025_12"
55
experimental-features = ["associated_item_constraints", "coupons", "negative_impls"]
66

@@ -9,4 +9,4 @@ experimental-features = ["associated_item_constraints", "coupons", "negative_imp
99
no-core = true
1010

1111
[dev-dependencies]
12-
cairo_test = "2.14.1-dev.1"
12+
cairo_test = "2.15.0"

corelib/cairo_project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ core = "src"
33

44
[config.global]
55
edition = "2025_12"
6-
version = "2.14.1-dev.1"
6+
version = "2.15.0"
77

88
[config.global.experimental_features]
99
associated_item_constraints = true

corelib/src/ec.cairo

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,7 @@ pub impl EcStateImpl of EcStateTrait {
204204
///
205205
/// # Returns
206206
///
207-
/// * `Option<NonZeroEcPoint>` - The resulting point, or None if the result is the zero point
208-
///
209-
/// # Panics
210-
///
211-
/// Panics if the result is the point at infinity.
207+
/// * `Option<NonZeroEcPoint>` - The resulting point, or None if the result is the zero point.
212208
#[inline]
213209
fn finalize_nz(self: EcState) -> Option<NonZeroEcPoint> nopanic {
214210
ec_state_try_finalize_nz(self)
@@ -268,10 +264,6 @@ pub impl EcPointImpl of EcPointTrait {
268264
///
269265
/// Returns `None` if no point with the given x-coordinate exists on the curve.
270266
///
271-
/// # Panics
272-
///
273-
/// Panics if `x` is 0, as this would be the point at infinity.
274-
///
275267
/// # Examples
276268
///
277269
/// ```
@@ -298,10 +290,6 @@ pub impl EcPointImpl of EcPointTrait {
298290
///
299291
/// A tuple containing the (x, y) coordinates of the point.
300292
///
301-
/// # Panics
302-
///
303-
/// Panics if the point is the point at infinity.
304-
///
305293
/// # Examples
306294
///
307295
/// ```

corelib/src/ecdsa.cairo

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ use crate::zeroable::IsZeroResult;
5555
pub fn check_ecdsa_signature(
5656
message_hash: felt252, public_key: felt252, signature_r: felt252, signature_s: felt252,
5757
) -> bool {
58-
// Check that s != 0 (mod stark_curve::ORDER).
59-
if signature_s == 0
60-
|| signature_s == ec::stark_curve::ORDER
61-
|| signature_r == ec::stark_curve::ORDER {
58+
if is_equivalent_to_zero(signature_s) || signature_r == ec::stark_curve::ORDER {
6259
return false;
6360
}
6461

@@ -158,6 +155,10 @@ pub fn check_ecdsa_signature(
158155
pub fn recover_public_key(
159156
message_hash: felt252, signature_r: felt252, signature_s: felt252, y_parity: bool,
160157
) -> Option<felt252> {
158+
if is_equivalent_to_zero(signature_s) {
159+
return None;
160+
}
161+
161162
let r_point = EcPointTrait::new_nz_from_x(signature_r)?;
162163
let gen_point = generator_point()?;
163164

@@ -196,6 +197,12 @@ pub fn recover_public_key(
196197
Some(state.finalize_nz()?.x())
197198
}
198199

200+
/// Checks if `value != 0` (mod stark_curve::ORDER).
201+
fn is_equivalent_to_zero(value: felt252) -> bool {
202+
// Note that `2 * ec::stark_curve::ORDER` is larger than the felt252 PRIME.
203+
value == 0 || value == ec::stark_curve::ORDER
204+
}
205+
199206
// TODO(orizi): Remove this function on next Sierra release.
200207
/// Returns the generator point of the elliptic curve.
201208
///

corelib/src/internal/bounded_int.cairo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ extern fn bounded_int_constrain<T, const BOUNDARY: felt252, impl H: ConstrainHel
200200
value: T,
201201
) -> Result<H::LowT, H::HighT> implicits(RangeCheck) nopanic;
202202

203-
/// A helper trait for trimming a `BoundedInt` instance min value.
203+
/// A helper trait for trimming a `BoundedInt` instance's min value.
204204
pub trait TrimMinHelper<T> {
205205
type Target;
206206
}
207-
/// A helper trait for trimming a `BoundedInt` instance max value.
207+
/// A helper trait for trimming a `BoundedInt` instance's max value.
208208
pub trait TrimMaxHelper<T> {
209209
type Target;
210210
}

corelib/src/iter/traits/collect.cairo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::metaprogramming::TypeEqual;
33
/// Conversion from an [`Iterator`].
44
///
55
/// By implementing `FromIterator` for a type, you define how it will be
6-
/// created from an iterator. This is common for types which describe a
6+
/// created from an iterator. This is common for types that describe a
77
/// collection of some kind.
88
///
99
/// If you want to create a collection from the contents of an iterator, the
@@ -105,7 +105,7 @@ pub trait FromIterator<T, A> {
105105
/// Conversion into an [`Iterator`].
106106
///
107107
/// By implementing `IntoIterator` for a type, you define how it will be
108-
/// converted to an iterator. This is common for types which describe a
108+
/// converted to an iterator. This is common for types that describe a
109109
/// collection of some kind.
110110
///
111111
/// One benefit of implementing `IntoIterator` is that your type will work

corelib/src/iter/traits/iterator.cairo

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub trait Iterator<T> {
118118
/// times until [`None`] is encountered.
119119
///
120120
/// `advance_by(n)` will return `Ok(())` if the iterator successfully advances by
121-
/// `n` elements, or a `Err(NonZero<usize>)` with value `k` if [`None`] is encountered,
121+
/// `n` elements, or an `Err(NonZero<usize>)` with value `k` if [`None`] is encountered,
122122
/// where `k` is remaining number of steps that could not be advanced because the iterator ran
123123
/// out.
124124
/// If `self` is empty and `n` is non-zero, then this returns `Err(n)`.
@@ -202,11 +202,11 @@ pub trait Iterator<T> {
202202
}
203203
}
204204

205-
/// Takes a closure and creates an iterator which calls that closure on each
205+
/// Takes a closure and creates an iterator that calls that closure on each
206206
/// element.
207207
///
208208
/// `map()` transforms one iterator into another, by means of its argument:
209-
/// something that implements [`FnOnce`]. It produces a new iterator which
209+
/// something that implements [`FnOnce`]. It produces a new iterator that
210210
/// calls this closure on each element of the original iterator.
211211
///
212212
/// If you are good at thinking in types, you can think of `map()` like this:
@@ -253,7 +253,7 @@ pub trait Iterator<T> {
253253
mapped_iterator(self, f)
254254
}
255255

256-
/// Creates an iterator which gives the current iteration count as well as
256+
/// Creates an iterator that gives the current iteration count as well as
257257
/// the next value.
258258
///
259259
/// The iterator returned yields pairs `(i, val)`, where `i` is the
@@ -508,7 +508,7 @@ pub trait Iterator<T> {
508508
}
509509
}
510510

511-
/// Creates an iterator which uses a closure to determine if an element
511+
/// Creates an iterator that uses a closure to determine if an element
512512
/// should be yielded. The closure takes each element as a snapshot.
513513
///
514514
/// Given an element the closure must return `true` or `false`. The returned
@@ -554,7 +554,7 @@ pub trait Iterator<T> {
554554
/// If either iterator returns [`None`], [`next`] from the zipped iterator
555555
/// will return [`None`].
556556
/// If the zipped iterator has no more elements to return then each further attempt to advance
557-
/// it will first try to advance the first iterator at most one time and if it still yielded an
557+
/// it will first try to advance the first iterator at most one time and if it still yields an
558558
/// item try to advance the second iterator at most one time.
559559
///
560560
/// # Examples
@@ -654,7 +654,7 @@ pub trait Iterator<T> {
654654
FromIterator::<B, Self::Item>::from_iter::<T, IntoIter, ItemEqual>(self)
655655
}
656656

657-
/// Creates an iterator which can use the [`peek`] method to look at the next element of the
657+
/// Creates an iterator that can use the [`peek`] method to look at the next element of the
658658
/// iterator. See its documentation for more information.
659659
///
660660
/// Note that the underlying iterator is still advanced when [`peek`] is called for the first
@@ -712,7 +712,7 @@ pub trait Iterator<T> {
712712
/// assert_eq!(iter.next(), None);
713713
/// ```
714714
///
715-
/// If less than `n` elements are available,
715+
/// If fewer than `n` elements are available,
716716
/// `take` will limit itself to the size of the underlying iterator:
717717
///
718718
/// ```

corelib/src/keyword_docs.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ mod keyword_continue {}
283283
mod keyword_return {}
284284

285285
/// ### The `break` keyword.
286-
/// Exits a loop early. Can only be used inside a `loop` expression.
286+
/// Exits a loop early. Can only be used inside `loop`, `while` or `for` loop blocks.
287287
///
288288
/// ### Example
289289
/// ```cairo

corelib/src/ops/range.cairo

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
//!
66
//! # Range Operator Forms
77
//!
8-
//! There is currently only a single range operator form: `start..end`, representing a range from
9-
//! `start` (inclusive) to `end` (exclusive).
8+
//! There are currently two range operator forms:
9+
//! `start..end`, representing a range from `start` (inclusive) to `end` (exclusive).
10+
//! `start..=end`, representing a range from `start` (inclusive) to `end` (inclusive).
1011

1112
use core::iter::{IntoIterator, Iterator};
1213
use core::num::traits::One;

0 commit comments

Comments
 (0)