Skip to content

Commit b9533fe

Browse files
pablodeymojrchatruc
authored andcommitted
chore(levm): lambdaworks update version 0.13 (#5206)
**Motivation** <!-- Why does this pull request exist? What are its goals? --> **Description** <!-- A clear and concise general description of the changes this PR introduces --> <!-- Link to issues: Resolves #111, Resolves #222 --> Closes #issue_number --------- Co-authored-by: Javier Rodríguez Chatruc <49622509+jrchatruc@users.noreply.github.com> Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
1 parent a31eeee commit b9533fe

File tree

8 files changed

+83
-48
lines changed

8 files changed

+83
-48
lines changed

Cargo.lock

Lines changed: 21 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ futures = "0.3.31"
109109
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer", rev = "c60d7eb147edbdf12bb7a7c6e92ec178d9f8da23" }
110110
spawned-concurrency = "0.4.2"
111111
spawned-rt = "0.4.2"
112-
lambdaworks-crypto = "0.11.0"
112+
lambdaworks-crypto = "0.13.0"
113113
tui-logger = { version = "0.17.3", features = ["tracing-support"] }
114114
crossbeam = "0.8.4"
115115
rayon = "1.10.0"

crates/l2/prover/src/guest_program/src/risc0/Cargo.lock

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/l2/prover/src/guest_program/src/sp1/Cargo.lock

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/l2/tee/quote-gen/Cargo.lock

Lines changed: 21 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/vm/levm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ p256 = { version = "0.13.2", features = [
2929
sha2 = "0.10.8"
3030
ripemd = "0.1.3"
3131
malachite = "0.6.1"
32-
lambdaworks-math = "0.11.0"
32+
lambdaworks-math = "0.13.0"
3333
bls12_381 = { git = "https://github.com/lambdaclass/bls12_381", branch = "expose-fp-struct", features = [
3434
"groups",
3535
"bits",

crates/vm/levm/src/precompiles.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,10 @@ pub fn pairing_check(batch: &[(G1, G2)]) -> Result<bool, VMError> {
10571057
valid_batch.push((g1, g2));
10581058
}
10591059
let valid_batch_refs: Vec<_> = valid_batch.iter().map(|(p1, p2)| (p1, p2)).collect();
1060-
let result = BN254AtePairing::compute_batch(&valid_batch_refs)
1061-
.map_err(|PairingError::PointNotInSubgroup| PrecompileError::PointNotInSubgroup)?;
1060+
let result = BN254AtePairing::compute_batch(&valid_batch_refs).map_err(|e| match e {
1061+
PairingError::PointNotInSubgroup => PrecompileError::PointNotInSubgroup,
1062+
PairingError::DivisionByZero => PrecompileError::InvalidPoint,
1063+
})?;
10621064

10631065
Ok(result == QuadraticExtensionFieldElement::one())
10641066
}
@@ -1336,7 +1338,9 @@ pub fn bls12_g1add(
13361338
// equation holds since it has no solutions for an `x` coordinate where `y` is
13371339
// zero within the prime field space.
13381340
let x_squared = p0.0.square();
1339-
let s = (x_squared.double() + &x_squared + BLS12381Curve::a()) / p0.1.double();
1341+
let s = ((x_squared.double() + &x_squared + BLS12381Curve::a())
1342+
/ p0.1.double())
1343+
.map_err(|_e| VMError::Internal(InternalError::DivisionByZero))?;
13401344

13411345
let x = s.square() - p0.0.double();
13421346
let y = s * (p0.0 - &x) - p0.1;
@@ -1349,7 +1353,8 @@ pub fn bls12_g1add(
13491353
// The division may panic only when `t` has no inverse. This can only happen if
13501354
// `p0.0 == p1.0`, for which the defining equation gives us two possible values for
13511355
// `p0.1` and `p1.1`, which are 2 and -2. Both cases have already been handled before.
1352-
let l = (&p0.1 - p1.1) / (&p0.0 - &p1.0);
1356+
let l = ((&p0.1 - p1.1) / (&p0.0 - &p1.0))
1357+
.map_err(|_e| VMError::Internal(InternalError::DivisionByZero))?;
13531358

13541359
let x = l.square() - &p0.0 - p1.0;
13551360
let y = l * (p0.0 - &x) - p0.1;
@@ -1500,8 +1505,9 @@ pub fn bls12_g2add(
15001505
// equation holds since it has no solutions for an `x` coordinate where `y` is
15011506
// zero within the prime field space.
15021507
let x_squared = p0.0.square();
1503-
let s =
1504-
(x_squared.double() + &x_squared + BLS12381TwistCurve::a()) / p0.1.double();
1508+
let s = ((x_squared.double() + &x_squared + BLS12381TwistCurve::a())
1509+
/ p0.1.double())
1510+
.map_err(|_e| VMError::Internal(InternalError::DivisionByZero))?;
15051511

15061512
let x = s.square() - p0.0.double();
15071513
let y = s * (p0.0 - &x) - p0.1;
@@ -1514,7 +1520,8 @@ pub fn bls12_g2add(
15141520
// The division may panic only when `t` has no inverse. This can only happen if
15151521
// `p0.0 == p1.0`, for which the defining equation gives us two possible values for
15161522
// `p0.1` and `p1.1`, which are 2 and -2. Both cases have already been handled before.
1517-
let l = (&p0.1 - p1.1) / (&p0.0 - &p1.0);
1523+
let l = ((&p0.1 - p1.1) / (&p0.0 - &p1.0))
1524+
.map_err(|_e| VMError::Internal(InternalError::DivisionByZero))?;
15181525

15191526
let x = l.square() - &p0.0 - p1.0;
15201527
let y = l * (p0.0 - &x) - p0.1;

tooling/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ libsql = "0.9.10"
7878
futures = "0.3.31"
7979
spawned-concurrency = "0.4.2"
8080
spawned-rt = "0.4.2"
81-
lambdaworks-crypto = "0.11.0"
81+
lambdaworks-crypto = "0.13.0"
8282
tui-logger = { version = "0.17.3", features = ["tracing-support"] }
8383
crossbeam = "0.8.4"
8484
rayon = "1.10.0"

0 commit comments

Comments
 (0)