Fix for upstream API changes
This commit is contained in:
parent
cc68cf8b9e
commit
4012281a2d
12
src/ffi.rs
12
src/ffi.rs
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
//! FFI bindings
|
//! FFI bindings
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use libc::{c_int, c_uchar, c_uint, c_void};
|
use libc::{c_int, c_uchar, c_uint, c_void, size_t};
|
||||||
|
|
||||||
/// Flag for context to enable verification precomputation
|
/// Flag for context to enable verification precomputation
|
||||||
pub const SECP256K1_START_VERIFY: c_uint = 0x1;
|
pub const SECP256K1_START_VERIFY: c_uint = 0x1;
|
||||||
|
@ -134,21 +134,21 @@ extern "C" {
|
||||||
|
|
||||||
// Pubkeys
|
// Pubkeys
|
||||||
pub fn secp256k1_ec_pubkey_parse(cx: Context, pk: *mut PublicKey,
|
pub fn secp256k1_ec_pubkey_parse(cx: Context, pk: *mut PublicKey,
|
||||||
input: *const c_uchar, in_len: c_int)
|
input: *const c_uchar, in_len: size_t)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
|
|
||||||
pub fn secp256k1_ec_pubkey_serialize(cx: Context, output: *const c_uchar,
|
pub fn secp256k1_ec_pubkey_serialize(cx: Context, output: *const c_uchar,
|
||||||
out_len: *mut c_int, pk: *const PublicKey
|
out_len: *mut size_t, pk: *const PublicKey
|
||||||
, compressed: c_int)
|
, compressed: c_uint)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
|
|
||||||
// Signatures
|
// Signatures
|
||||||
pub fn secp256k1_ecdsa_signature_parse_der(cx: Context, sig: *mut Signature,
|
pub fn secp256k1_ecdsa_signature_parse_der(cx: Context, sig: *mut Signature,
|
||||||
input: *const c_uchar, in_len: c_int)
|
input: *const c_uchar, in_len: size_t)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
|
|
||||||
pub fn secp256k1_ecdsa_signature_serialize_der(cx: Context, output: *const c_uchar,
|
pub fn secp256k1_ecdsa_signature_serialize_der(cx: Context, output: *const c_uchar,
|
||||||
out_len: c_int, sig: *const Signature)
|
out_len: *const size_t, sig: *const Signature)
|
||||||
-> c_int;
|
-> c_int;
|
||||||
|
|
||||||
pub fn secp256k1_ecdsa_recoverable_signature_parse_compact(cx: Context, sig: *mut RecoverableSignature,
|
pub fn secp256k1_ecdsa_recoverable_signature_parse_compact(cx: Context, sig: *mut RecoverableSignature,
|
||||||
|
|
|
@ -146,7 +146,7 @@ impl PublicKey {
|
||||||
let mut pk = unsafe { ffi::PublicKey::blank() };
|
let mut pk = unsafe { ffi::PublicKey::blank() };
|
||||||
unsafe {
|
unsafe {
|
||||||
if ffi::secp256k1_ec_pubkey_parse(secp.ctx, &mut pk, data.as_ptr(),
|
if ffi::secp256k1_ec_pubkey_parse(secp.ctx, &mut pk, data.as_ptr(),
|
||||||
data.len() as ::libc::c_int) == 1 {
|
data.len() as ::libc::size_t) == 1 {
|
||||||
Ok(PublicKey(pk))
|
Ok(PublicKey(pk))
|
||||||
} else {
|
} else {
|
||||||
Err(InvalidPublicKey)
|
Err(InvalidPublicKey)
|
||||||
|
@ -162,7 +162,7 @@ impl PublicKey {
|
||||||
let mut ret = ArrayVec::new();
|
let mut ret = ArrayVec::new();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut ret_len = ret.len() as ::libc::c_int;
|
let mut ret_len = ret.len() as ::libc::size_t;
|
||||||
debug_assert!(ffi::secp256k1_ec_pubkey_serialize(secp.ctx, ret.as_ptr(),
|
debug_assert!(ffi::secp256k1_ec_pubkey_serialize(secp.ctx, ret.as_ptr(),
|
||||||
&mut ret_len, self.as_ptr(),
|
&mut ret_len, self.as_ptr(),
|
||||||
if compressed {1} else {0}) == 1);
|
if compressed {1} else {0}) == 1);
|
||||||
|
|
|
@ -45,7 +45,6 @@ extern crate rand;
|
||||||
|
|
||||||
use std::intrinsics::copy_nonoverlapping;
|
use std::intrinsics::copy_nonoverlapping;
|
||||||
use std::{fmt, ops, ptr};
|
use std::{fmt, ops, ptr};
|
||||||
use libc::c_int;
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -75,7 +74,7 @@ impl Signature {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
if ffi::secp256k1_ecdsa_signature_parse_der(secp.ctx, &mut ret,
|
if ffi::secp256k1_ecdsa_signature_parse_der(secp.ctx, &mut ret,
|
||||||
data.as_ptr(), data.len() as libc::c_int) == 1 {
|
data.as_ptr(), data.len() as libc::size_t) == 1 {
|
||||||
Ok(Signature(ret))
|
Ok(Signature(ret))
|
||||||
} else {
|
} else {
|
||||||
Err(Error::InvalidSignature)
|
Err(Error::InvalidSignature)
|
||||||
|
|
Loading…
Reference in New Issue