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

chore: update to 1.1.0 #132

Merged
merged 1 commit into from
Jun 5, 2023
Merged
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
chore: update to 1.1.0
  • Loading branch information
enitrat committed Jun 5, 2023
commit c9fcafcc34feef136349ebcffa2302b49875ab77
481 changes: 189 additions & 292 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ home = "0.5.3"
glob = "0.3.0"

# Cairo runner dependencies
cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-sierra-ap-change = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-sierra-gas = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-plugins = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo",rev = "a08bedbf26b711e81cec8b7660698a3788e67d46"}
cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-sierra-ap-change = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-sierra-gas = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-plugins = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}
cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo",rev = "1003d5d14c09191bbfb64ee318d1975584b3c819"}


anyhow = "1.0.66"
Expand Down
2 changes: 1 addition & 1 deletion corelib/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "core"
version = "1.0.0-alpha.7"
version = "1.1.0"

# NOTE: This is non-public, unstable Scarb's field, which instructs resolver that this package does not
# depend on `core`, which is only true for this particular package. Nobody else should use it.
Expand Down
3 changes: 0 additions & 3 deletions corelib/src/array.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ impl ArrayImpl<T> of ArrayTrait<T> {
fn is_empty(self: @Array<T>) -> bool {
self.len() == 0_usize
}

#[inline(always)]
fn span(self: @Array<T>) -> Span<T> {
Span { snapshot: self }
Expand Down Expand Up @@ -104,7 +103,6 @@ impl SpanImpl<T> of SpanTrait<T> {
Option::None(_) => Option::None(()),
}
}

#[inline(always)]
fn pop_back(ref self: Span<T>) -> Option<@T> {
let mut snapshot = self.snapshot;
Expand All @@ -115,7 +113,6 @@ impl SpanImpl<T> of SpanTrait<T> {
Option::None(_) => Option::None(()),
}
}

#[inline(always)]
fn get(self: Span<T>, index: usize) -> Option<Box<@T>> {
array_get(self.snapshot, index)
Expand Down
17 changes: 17 additions & 0 deletions corelib/src/cmp.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fn min<T, impl TPartialOrd: PartialOrd<T>, impl DropT: Drop<T>, impl CopyT: Copy<T>>(
a: T, b: T
) -> T {
if a > b {
return b;
}
a
}

fn max<T, impl TPartialOrd: PartialOrd<T>, impl DropT: Drop<T>, impl CopyT: Copy<T>>(
a: T, b: T
) -> T {
if a > b {
return a;
}
b
}
4 changes: 2 additions & 2 deletions corelib/src/debug.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ impl U128PrintImpl of PrintTrait<u128> {

impl U256PrintImpl of PrintTrait<u256> {
fn print(self: u256) {
self.low.into().print();
self.high.into().print();
Into::<u128, felt252>::into(self.low).print();
Into::<u128, felt252>::into(self.high).print();
}
}

Expand Down
67 changes: 49 additions & 18 deletions corelib/src/dict.cairo
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
use traits::Index;
use traits::Default;
use traits::{Index, Default};

extern type Felt252Dict<T>;
extern type SquashedFelt252Dict<T>;
extern type Felt252DictEntry<T>;
impl SquashedFelt252DictDrop<T, impl TDrop: Drop<T>> of Drop<SquashedFelt252Dict<T>>;

extern fn felt252_dict_new<T>() -> Felt252Dict<T> implicits(SegmentArena) nopanic;
extern fn felt252_dict_write<T>(ref dict: Felt252Dict<T>, key: felt252, value: T) nopanic;
extern fn felt252_dict_read<T>(ref dict: Felt252Dict<T>, key: felt252) -> T nopanic;

extern fn felt252_dict_entry_get<T>(
dict: Felt252Dict<T>, key: felt252
Expand All @@ -29,51 +26,85 @@ extern fn felt252_dict_squash<T>(

trait Felt252DictTrait<T> {
fn new() -> Felt252Dict<T>;
fn insert(ref self: Felt252Dict<T>, key: felt252, value: T);
fn get(ref self: Felt252Dict<T>, key: felt252) -> T;
/// Inserts the given value for the given key.
///
/// Requires the `Destruct` trait, as the previous value is dropped.
fn insert<impl TDestruct: Destruct<T>>(ref self: Felt252Dict<T>, key: felt252, value: T);
/// Returns a copy of the value at the given key.
///
/// Requires the `Copy` trait.
fn get<impl TCopy: Copy<T>>(ref self: Felt252Dict<T>, key: felt252) -> T;
fn squash(self: Felt252Dict<T>) -> SquashedFelt252Dict<T> nopanic;
fn entry(self: Felt252Dict<T>, key: felt252) -> (Felt252DictEntry<T>, T) nopanic;
}
impl Felt252DictImpl<T, impl TDefault: Felt252DictValue<T>> of Felt252DictTrait<T> {
#[inline(always)]
fn new() -> Felt252Dict<T> {
felt252_dict_new()
}
fn insert(ref self: Felt252Dict<T>, key: felt252, value: T) {
felt252_dict_write(ref self, key, value)

#[inline]
fn insert<impl TDestruct: Destruct<T>>(ref self: Felt252Dict<T>, key: felt252, value: T) {
let (entry, _prev_value) = felt252_dict_entry_get(self, key);
self = felt252_dict_entry_finalize(entry, value);
}
fn get(ref self: Felt252Dict<T>, key: felt252) -> T {
felt252_dict_read(ref self, key)

#[inline]
fn get<impl TCopy: Copy<T>>(ref self: Felt252Dict<T>, key: felt252) -> T {
let (entry, prev_value) = felt252_dict_entry_get(self, key);
let return_value = prev_value;
self = felt252_dict_entry_finalize(entry, prev_value);
return_value
}

#[inline(never)]
fn squash(self: Felt252Dict<T>) -> SquashedFelt252Dict<T> nopanic {
felt252_dict_squash(self)
}

#[inline(always)]
fn entry(self: Felt252Dict<T>, key: felt252) -> (Felt252DictEntry<T>, T) nopanic {
felt252_dict_entry_get(self, key)
}
}

impl Felt252DictDestruct<T,
impl TDrop: Drop<T>,
impl TDefault: Felt252DictValue<T>> of Destruct<Felt252Dict<T>> {
trait Felt252DictEntryTrait<T> {
fn finalize(self: Felt252DictEntry<T>, new_value: T) -> Felt252Dict<T>;
}

impl Felt252DictEntryImpl<T, impl TDefault: Felt252DictValue<T>> of Felt252DictEntryTrait<T> {
#[inline(always)]
fn finalize(self: Felt252DictEntry<T>, new_value: T) -> Felt252Dict<T> {
felt252_dict_entry_finalize(self, new_value)
}
}

impl Felt252DictDestruct<
T, impl TDrop: Drop<T>, impl TDefault: Felt252DictValue<T>
> of Destruct<Felt252Dict<T>> {
#[inline(always)]
fn destruct(self: Felt252Dict<T>) nopanic {
self.squash();
}
}

impl Felt252DictEntryDestruct<T,
impl TDrop: Drop<T>,
impl TDefault: Felt252DictValue<T>> of Destruct<Felt252DictEntry<T>> {
impl Felt252DictEntryDestruct<
T, impl TDrop: Drop<T>, impl TDefault: Felt252DictValue<T>
> of Destruct<Felt252DictEntry<T>> {
#[inline(always)]
fn destruct(self: Felt252DictEntry::<T>) nopanic {
felt252_dict_entry_finalize(self, TDefault::zero_default());
}
}

impl Felt252DictIndex<T> of Index<Felt252Dict<T>, felt252, T> {
impl Felt252DictIndex<
T,
impl TDictImpl: Felt252DictTrait<T>,
impl TCopy: Copy<T>,
impl EntryDestruct: Destruct<Felt252DictEntry<T>>
> of Index<Felt252Dict<T>, felt252, T> {
#[inline(always)]
fn index(ref self: Felt252Dict<T>, index: felt252) -> T {
felt252_dict_read(ref self, index)
self.get(index)
}
}
23 changes: 6 additions & 17 deletions corelib/src/ecdsa.cairo
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
use zeroable::IsZeroResult;
use ec::ec_mul;
use ec::ec_neg;
use ec::ec_point_from_x;
use ec::ec_point_from_x_nz;
use ec::ec_point_is_zero;
use ec::ec_point_new;
use ec::ec_point_new_nz;
use ec::ec_point_non_zero;
use ec::ec_point_try_new;
use ec::ec_point_try_new_nz;
use ec::ec_point_unwrap;
use ec::ec_point_zero;
use ec::ec_state_add_mul;
use ec::ec_state_add;
use ec::ec_state_finalize;
use ec::ec_state_init;
use ec::ec_state_try_finalize_nz;
use ec::{
ec_mul, ec_neg, ec_point_from_x, ec_point_from_x_nz, ec_point_is_zero, ec_point_new,
ec_point_new_nz, ec_point_non_zero, ec_point_try_new, ec_point_try_new_nz, ec_point_unwrap,
ec_point_zero, ec_state_add_mul, ec_state_add, ec_state_finalize, ec_state_init,
ec_state_try_finalize_nz
};

// Checks if (`signature_r`, `signature_s`) is a valid ECDSA signature for the given `public_key`
// on the given `message`.
Expand Down
58 changes: 31 additions & 27 deletions corelib/src/hash.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,31 @@ impl TupleSize1LegacyHash<E0, impl E0LegacyHash: LegacyHash<E0>> of LegacyHash<(
}
}

impl TupleSize2LegacyHash<E0,
E1,
impl E0LegacyHash: LegacyHash<E0>,
impl E1LegacyHash: LegacyHash<E1>,
impl E0Drop: Drop<E0>,
impl E1Drop: Drop<E1>> of LegacyHash<(E0, E1)> {
impl TupleSize2LegacyHash<
E0,
E1,
impl E0LegacyHash: LegacyHash<E0>,
impl E1LegacyHash: LegacyHash<E1>,
impl E0Drop: Drop<E0>,
impl E1Drop: Drop<E1>
> of LegacyHash<(E0, E1)> {
fn hash(state: felt252, value: (E0, E1, )) -> felt252 {
let (e0, e1) = value;
let state = E0LegacyHash::hash(state, e0);
E1LegacyHash::hash(state, e1)
}
}

impl TupleSize3LegacyHash<E0,
E1,
E2,
impl E0LegacyHash: LegacyHash<E0>,
impl E1LegacyHash: LegacyHash<E1>,
impl E2LegacyHash: LegacyHash<E2>,
impl E0Drop: Drop<E0>,
impl E1Drop: Drop<E1>,
impl E2Drop: Drop<E2>,
impl TupleSize3LegacyHash<
E0,
E1,
E2,
impl E0LegacyHash: LegacyHash<E0>,
impl E1LegacyHash: LegacyHash<E1>,
impl E2LegacyHash: LegacyHash<E2>,
impl E0Drop: Drop<E0>,
impl E1Drop: Drop<E1>,
impl E2Drop: Drop<E2>,
> of LegacyHash<(E0, E1, E2)> {
fn hash(state: felt252, value: (E0, E1, E2)) -> felt252 {
let (e0, e1, e2) = value;
Expand All @@ -112,18 +115,19 @@ impl E2Drop: Drop<E2>,
}
}

impl TupleSize4LegacyHash<E0,
E1,
E2,
E3,
impl E0LegacyHash: LegacyHash<E0>,
impl E1LegacyHash: LegacyHash<E1>,
impl E2LegacyHash: LegacyHash<E2>,
impl E3LegacyHash: LegacyHash<E3>,
impl E0Drop: Drop<E0>,
impl E1Drop: Drop<E1>,
impl E2Drop: Drop<E2>,
impl E3Drop: Drop<E3>,
impl TupleSize4LegacyHash<
E0,
E1,
E2,
E3,
impl E0LegacyHash: LegacyHash<E0>,
impl E1LegacyHash: LegacyHash<E1>,
impl E2LegacyHash: LegacyHash<E2>,
impl E3LegacyHash: LegacyHash<E3>,
impl E0Drop: Drop<E0>,
impl E1Drop: Drop<E1>,
impl E2Drop: Drop<E2>,
impl E3Drop: Drop<E3>,
> of LegacyHash<(E0, E1, E2, E3)> {
fn hash(state: felt252, value: (E0, E1, E2, E3)) -> felt252 {
let (e0, e1, e2, e3) = value;
Expand Down
Loading