fix: better conditional comp for wasm
This commit is contained in:
@@ -16,7 +16,6 @@ cryptoxide = "0.4.4"
|
||||
hex = "0.4.3"
|
||||
indexmap = "1.9.2"
|
||||
itertools = "0.10.5"
|
||||
k256 = { version = "0.13.0", optional = true }
|
||||
miette = "5.5.0"
|
||||
num-bigint = "0.4.3"
|
||||
num-integer = "0.1.45"
|
||||
@@ -29,20 +28,18 @@ pallas-traverse = "0.18.0"
|
||||
peg = "0.8.1"
|
||||
pretty = "0.11.3"
|
||||
pretty_assertions = "1.3.0"
|
||||
secp256k1 = { version = "0.26.0", optional = true }
|
||||
serde = { version = "1.0.152", features = ["derive"] }
|
||||
serde_json = "1.0.94"
|
||||
strum = "0.24.1"
|
||||
strum_macros = "0.24.3"
|
||||
thiserror = "1.0.39"
|
||||
|
||||
flat-rs = { path = "../flat-rs", version = "1.0.4-alpha" }
|
||||
|
||||
[target.'cfg(not(target_family="wasm"))'.dependencies]
|
||||
secp256k1 = { version = "0.26.0" }
|
||||
[target.'cfg(target_family="wasm")'.dependencies]
|
||||
k256 = { version = "0.13.0" }
|
||||
|
||||
[dev-dependencies]
|
||||
hex = "0.4.3"
|
||||
indoc = "2.0.1"
|
||||
|
||||
[features]
|
||||
default = ["dep:secp256k1"]
|
||||
native-secp256k1 = ["dep:k256"]
|
||||
unstable = []
|
||||
|
||||
@@ -50,10 +50,10 @@ pub enum Error {
|
||||
DeserialisationError(String, Value),
|
||||
#[error("Integer overflow")]
|
||||
OverflowError,
|
||||
#[cfg(not(feature = "native-secp256k1"))]
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
#[error(transparent)]
|
||||
Secp256k1(#[from] secp256k1::Error),
|
||||
#[cfg(feature = "native-secp256k1")]
|
||||
#[cfg(target_family = "wasm")]
|
||||
#[error(transparent)]
|
||||
Secp256k1(#[from] k256::ecdsa::Error),
|
||||
}
|
||||
|
||||
@@ -1041,7 +1041,7 @@ pub fn convert_constr_to_tag(constr: u64) -> Option<u64> {
|
||||
|
||||
pub static ANY_TAG: u64 = 102;
|
||||
|
||||
#[cfg(not(feature = "native-secp256k1"))]
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
fn verify_ecdsa(public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<Value, Error> {
|
||||
use secp256k1::{ecdsa::Signature, Message, PublicKey, Secp256k1};
|
||||
|
||||
@@ -1060,7 +1060,7 @@ fn verify_ecdsa(public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<V
|
||||
|
||||
/// Unlike the Haskell implementation the schnorr verification function in Aiken doesn't allow for arbitrary message sizes (at the moment).
|
||||
/// The message needs to be 32 bytes (ideally prehashed, but not a requirement).
|
||||
#[cfg(not(feature = "native-secp256k1"))]
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
fn verify_schnorr(public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<Value, Error> {
|
||||
use secp256k1::{schnorr::Signature, Message, Secp256k1, XOnlyPublicKey};
|
||||
|
||||
@@ -1077,7 +1077,7 @@ fn verify_schnorr(public_key: &[u8], message: &[u8], signature: &[u8]) -> Result
|
||||
Ok(Value::Con(Constant::Bool(valid.is_ok()).into()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "native-secp256k1")]
|
||||
#[cfg(target_family = "wasm")]
|
||||
fn verify_ecdsa(public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<Value, Error> {
|
||||
use k256::ecdsa::{self, signature::hazmat::PrehashVerifier};
|
||||
|
||||
@@ -1090,7 +1090,7 @@ fn verify_ecdsa(public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<V
|
||||
Ok(Value::Con(Constant::Bool(valid.is_ok()).into()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "native-secp256k1")]
|
||||
#[cfg(target_family = "wasm")]
|
||||
fn verify_schnorr(public_key: &[u8], message: &[u8], signature: &[u8]) -> Result<Value, Error> {
|
||||
use k256::schnorr::{self, signature::hazmat::PrehashVerifier};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user