Skip to content

Commit 0defc11

Browse files
authored
Merge pull request #5293 from stacks-network/sync_wasm_host_functions
chore: sync host functions with clarity-wasm implementation
2 parents 167f70f + 2d287f0 commit 0defc11

File tree

2 files changed

+2
-36
lines changed

2 files changed

+2
-36
lines changed

clarity/src/vm/clarity_wasm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5582,12 +5582,12 @@ fn link_print_fn(linker: &mut Linker<ClarityWasmContext>) -> Result<(), Error> {
55825582
.and_then(|export| export.into_memory())
55835583
.ok_or(Error::Wasm(WasmError::MemoryNotFound))?;
55845584

5585-
let serialized_ty = String::from_utf8(read_bytes_from_wasm(
5585+
let serialized_ty = read_identifier_from_wasm(
55865586
memory,
55875587
&mut caller,
55885588
serialized_ty_offset,
55895589
serialized_ty_length,
5590-
)?)?;
5590+
)?;
55915591

55925592
let epoch = caller.data().global_context.epoch_id;
55935593
let version = caller.data().contract_context().get_clarity_version();
Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
#[cfg(not(feature = "wasm"))]
22
mod secp256k1;
33

4-
#[cfg(not(feature = "wasm"))]
5-
use wsts::common::Signature as WSTSSignature;
6-
#[cfg(not(feature = "wasm"))]
7-
use wsts::curve::point::{Compressed, Point};
8-
#[cfg(not(feature = "wasm"))]
9-
use wsts::curve::scalar::Scalar;
10-
114
#[cfg(not(feature = "wasm"))]
125
pub use self::secp256k1::*;
136

@@ -38,30 +31,3 @@ impl Default for SchnorrSignature {
3831
Self([0u8; 65])
3932
}
4033
}
41-
42-
#[cfg(not(feature = "wasm"))]
43-
impl SchnorrSignature {
44-
/// Attempt to convert a Schnorr signature to a WSTS Signature
45-
pub fn to_wsts_signature(&self) -> Option<WSTSSignature> {
46-
// TODO: update wsts to add a TryFrom for a [u8; 65] and a slice to a Signature
47-
let point_bytes: [u8; 33] = self.0[..33].try_into().ok()?;
48-
let scalar_bytes: [u8; 32] = self.0[33..].try_into().ok()?;
49-
let point = Point::try_from(&Compressed::from(point_bytes)).ok()?;
50-
let scalar = Scalar::from(scalar_bytes);
51-
Some(WSTSSignature {
52-
R: point,
53-
z: scalar,
54-
})
55-
}
56-
}
57-
58-
#[cfg(not(feature = "wasm"))]
59-
/// Convert a WSTS Signature to a SchnorrSignature
60-
impl From<&WSTSSignature> for SchnorrSignature {
61-
fn from(signature: &WSTSSignature) -> Self {
62-
let mut buf = [0u8; 65];
63-
buf[..33].copy_from_slice(&signature.R.compress().data);
64-
buf[33..].copy_from_slice(&signature.z.to_bytes());
65-
SchnorrSignature(buf)
66-
}
67-
}

0 commit comments

Comments
 (0)