"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some("crate::c_types::RecoverableSignature"),
"bitcoin::secp256k1::SecretKey" if is_ref => Some("*const [u8; 32]"),
"bitcoin::secp256k1::SecretKey" if !is_ref => Some("crate::c_types::SecretKey"),
+ "bitcoin::secp256k1::Scalar" if is_ref => Some("*const crate::c_types::BigEndianScalar"),
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some("crate::c_types::BigEndianScalar"),
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some("crate::c_types::ThirtyTwoBytes"),
+
"bitcoin::blockdata::script::Script" if is_ref => Some("crate::c_types::u8slice"),
"bitcoin::blockdata::script::Script" if !is_ref => Some("crate::c_types::derived::CVec_u8Z"),
"bitcoin::blockdata::transaction::OutPoint" => Some("crate::lightning::chain::transaction::OutPoint"),
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some(""),
"bitcoin::secp256k1::SecretKey" if is_ref => Some("&::bitcoin::secp256k1::SecretKey::from_slice(&unsafe { *"),
"bitcoin::secp256k1::SecretKey" if !is_ref => Some(""),
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some(""),
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some("::bitcoin::secp256k1::ecdh::SharedSecret::from_bytes("),
+
"bitcoin::blockdata::script::Script" if is_ref => Some("&::bitcoin::blockdata::script::Script::from(Vec::from("),
"bitcoin::blockdata::script::Script" if !is_ref => Some("::bitcoin::blockdata::script::Script::from("),
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("&"),
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some(".into_rust()"),
"bitcoin::secp256k1::SecretKey" if !is_ref => Some(".into_rust()"),
"bitcoin::secp256k1::SecretKey" if is_ref => Some("}[..]).unwrap()"),
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some(".into_rust()"),
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some(".data)"),
+
"bitcoin::blockdata::script::Script" if is_ref => Some(".to_slice()))"),
"bitcoin::blockdata::script::Script" if !is_ref => Some(".into_rust())"),
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(".into_bitcoin()"),
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some("crate::c_types::RecoverableSignature::from_rust(&"),
"bitcoin::secp256k1::SecretKey" if is_ref => Some(""),
"bitcoin::secp256k1::SecretKey" if !is_ref => Some("crate::c_types::SecretKey::from_rust("),
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some("crate::c_types::BigEndianScalar::from_rust("),
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some("crate::c_types::ThirtyTwoBytes { data: "),
+
"bitcoin::blockdata::script::Script" if is_ref => Some("crate::c_types::u8slice::from_slice(&"),
"bitcoin::blockdata::script::Script" if !is_ref => Some(""),
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("crate::c_types::Transaction::from_bitcoin("),
"bitcoin::secp256k1::ecdsa::RecoverableSignature" => Some(")"),
"bitcoin::secp256k1::SecretKey" if !is_ref => Some(")"),
"bitcoin::secp256k1::SecretKey" if is_ref => Some(".as_ref()"),
+ "bitcoin::secp256k1::Scalar" if !is_ref => Some(")"),
+ "bitcoin::secp256k1::ecdh::SharedSecret" if !is_ref => Some(".secret_bytes() }"),
+
"bitcoin::blockdata::script::Script" if is_ref => Some("[..])"),
"bitcoin::blockdata::script::Script" if !is_ref => Some(".into_bytes().into()"),
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(")"),
use bitcoin::secp256k1::Error as SecpError;
use bitcoin::secp256k1::ecdsa::RecoveryId;
use bitcoin::secp256k1::ecdsa::RecoverableSignature as SecpRecoverableSignature;
+use bitcoin::secp256k1::Scalar as SecpScalar;
use bitcoin::bech32;
use bitcoin::util::address;
}
}
+#[repr(C)]
+#[derive(Clone)]
+/// Represents a scalar value between zero and the secp256k1 curve order, in big endian.
+pub struct BigEndianScalar {
+ /// The bytes of the scalar value.
+ pub big_endian_bytes: [u8; 32],
+}
+impl BigEndianScalar {
+ pub(crate) fn from_rust(scalar: &SecpScalar) -> Self {
+ Self { big_endian_bytes: scalar.to_be_bytes() }
+ }
+ pub(crate) fn into_rust(&self) -> SecpScalar {
+ SecpScalar::from_be_bytes(self.big_endian_bytes).expect("Scalar greater than the curve order")
+ }
+}
+
#[repr(C)]
#[derive(Copy, Clone)]
/// Represents an error returned from libsecp256k1 during validation of some secp256k1 data