Skip to content

Commit 5b3cd75

Browse files
committed
Fix compile-error on WASM
1 parent 04fa77e commit 5b3cd75

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/crypto/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ ark-bls12-381 = { version = "0.4.0", optional = true }
2929
ark-ec = { version = "0.4.2", features = ["parallel"], optional = true }
3030
ark-ff = { version = "0.4.2", features = ["asm", "parallel"], optional = true }
3131
ark-serialize = { version = "0.4.2", optional = true }
32+
cfg-if = "1.0.0"
3233
derive_more = { version = "1.0.0-beta.6", default-features = false, features = ["display", "from"] }
3334
digest = "0.10"
3435
ecdsa = "0.16.2" # Not used directly, but needed to bump transitive dependency, see: https://github.com/CosmWasm/cosmwasm/pull/1899 for details.

packages/crypto/src/bls12_318/hash.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
//!
22
//! Note about the usage of `.unwrap()` here:
3-
//!
3+
//!
44
//! Since the underlying curve implementation, when implemented sanely, should never request 255 curve elements at the same time,
55
//! the expansion will always finish without exiting with an error (since that is the only "ABORT" condition).
66
//!
77
//! Therefore we can conclude, if the implementation is done as defined in the IETF publication, won't ever error out.
8-
//!
8+
//!
99
//! IETF doc in question: <https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-12#section-5.4.1>
10-
//!
10+
//!
1111
//! In addition to that I (@aumetra) skimmed through the tree of traits making up our hash-to-curve configuration,
1212
//! and I have not found a condition where an error is returned.
13-
//!
13+
//!
1414
//! ark crate versions that I looked at:
15-
//!
15+
//!
1616
//! - ark-bls12-381 v0.4.0
1717
//! - ark-ec v0.4.2
1818
//! - ark-ff v0.4.2
19-
//!
19+
//!
2020
2121
use ark_bls12_381::{g1, g2};
2222
use ark_ec::{

packages/crypto/src/bls12_318/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
mod aggregate;
2-
mod constants;
3-
mod hash;
4-
mod pairing;
5-
mod points;
1+
cfg_if::cfg_if! {
2+
if #[cfg(feature = "std")] {
3+
mod aggregate;
4+
mod constants;
5+
mod hash;
6+
mod pairing;
7+
mod points;
68

7-
pub use aggregate::{bls12_381_aggregate_g1, bls12_381_aggregate_g2};
8-
pub use hash::{bls12_381_hash_to_g1, bls12_381_hash_to_g2, HashFunction};
9-
pub use pairing::bls12_381_pairing_equality;
10-
pub use points::{bls12_381_g1_is_identity, bls12_381_g2_is_identity};
9+
pub use self::aggregate::{bls12_381_aggregate_g1, bls12_381_aggregate_g2};
10+
pub use self::hash::{bls12_381_hash_to_g1, bls12_381_hash_to_g2, HashFunction};
11+
pub use self::pairing::bls12_381_pairing_equality;
12+
pub use self::points::{bls12_381_g1_is_identity, bls12_381_g2_is_identity};
13+
}
14+
}
1115

1216
pub const BLS12_381_G1_POINT_LEN: usize = 48;
1317
pub const BLS12_381_G2_POINT_LEN: usize = 96;

packages/crypto/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ extern crate alloc;
1111
extern crate std; // allow for file I/O during tests
1212

1313
mod backtrace;
14-
#[cfg(feature = "std")]
1514
mod bls12_318;
1615
mod ecdsa;
1716
mod ed25519;
@@ -25,8 +24,13 @@ mod secp256r1;
2524
pub use crate::bls12_318::{
2625
bls12_381_aggregate_g1, bls12_381_aggregate_g2, bls12_381_g1_is_identity,
2726
bls12_381_g2_is_identity, bls12_381_hash_to_g1, bls12_381_hash_to_g2,
28-
bls12_381_pairing_equality, HashFunction, BLS12_381_G1_GENERATOR_COMPRESSED,
29-
BLS12_381_G1_POINT_LEN, BLS12_381_G2_GENERATOR_COMPRESSED, BLS12_381_G2_POINT_LEN,
27+
bls12_381_pairing_equality, HashFunction,
28+
};
29+
30+
#[doc(hidden)]
31+
pub use crate::bls12_318::{
32+
BLS12_381_G1_GENERATOR_COMPRESSED, BLS12_381_G1_POINT_LEN, BLS12_381_G2_GENERATOR_COMPRESSED,
33+
BLS12_381_G2_POINT_LEN,
3034
};
3135
#[doc(hidden)]
3236
pub use crate::ecdsa::{ECDSA_PUBKEY_MAX_LEN, ECDSA_SIGNATURE_LEN, MESSAGE_HASH_MAX_LEN};

0 commit comments

Comments
 (0)