Skip to content

Commit

Permalink
Add is_infinity field to secp256 point struct (#828)
Browse files Browse the repository at this point in the history
* add is_infinity to secp point

* clean

* fix

* use same deps as blockifier

* fix

* fix layout

* fix test

* remove some brittle asserts due to random initial data when adding and muling points at infinity

* fix

* remove unused dep

* fixes, missed the value entry/output
  • Loading branch information
edg-l authored Oct 8, 2024
1 parent cff7a11 commit 951a76b
Show file tree
Hide file tree
Showing 15 changed files with 610 additions and 924 deletions.
177 changes: 5 additions & 172 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,19 @@ cairo-lang-runner = { version = "2.8.4", optional = true }
colored = { version = "2.1.0", optional = true }
# needed to interface with cairo-lang-*
keccak = "0.1.5"
k256 = "0.13.4"
p256 = "0.13.2"
sha2 = "0.10.8" # needed for the syscall handler stub
scarb-metadata = { version = "1.12.0", optional = true }
scarb-ui = { version = "0.1.5", optional = true }
sec1 = "0.7.3"
serde_json = { version = "1.0.128" }
stats_alloc = "0.1.10"

# for the syscallhandler stub to match blockifier
ark-secp256k1 = "0.4.0"
ark-secp256r1 = "0.4.0"
ark-ec = "0.4.2"
ark-ff = "0.4.2"
num-integer = "0.1.46"

[dev-dependencies]
cairo-vm = { version = "1.0.1", features = ["cairo-1-hints"] }
cairo-lang-runner = "2.8.4"
Expand Down
10 changes: 4 additions & 6 deletions src/arch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
error,
starknet::{ArrayAbi, U256},
starknet::{ArrayAbi, Secp256k1Point, Secp256r1Point},
types::TypeBuilder,
values::Value,
};
Expand Down Expand Up @@ -150,22 +150,20 @@ impl<'a> AbiArgument for JitValueWithInfoWrapper<'a> {
.to_bytes(buffer)?
}
(
Value::Secp256K1Point { x, y },
Value::Secp256K1Point(Secp256k1Point { x, y, is_infinity }),
CoreTypeConcrete::StarkNet(StarkNetTypeConcrete::Secp256Point(
Secp256PointTypeConcrete::K1(_),
)),
)
| (
Value::Secp256R1Point { x, y },
Value::Secp256R1Point(Secp256r1Point { x, y, is_infinity }),
CoreTypeConcrete::StarkNet(StarkNetTypeConcrete::Secp256Point(
Secp256PointTypeConcrete::R1(_),
)),
) => {
let x = U256 { lo: x.0, hi: x.1 };
let y = U256 { lo: y.0, hi: y.1 };

x.to_bytes(buffer)?;
y.to_bytes(buffer)?;
is_infinity.to_bytes(buffer)?;
}
(Value::Sint128(value), CoreTypeConcrete::Sint128(_)) => value.to_bytes(buffer)?,
(Value::Sint16(value), CoreTypeConcrete::Sint16(_)) => value.to_bytes(buffer)?,
Expand Down
Loading

0 comments on commit 951a76b

Please sign in to comment.