Skip to content

Commit

Permalink
fix: remove unused ffi types and methods (#4948)
Browse files Browse the repository at this point in the history
Description
---
Remove unused FFI methods
  • Loading branch information
SWvheerden authored Nov 23, 2022
1 parent 00e98f9 commit 5703d02
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 134 deletions.
18 changes: 0 additions & 18 deletions base_layer/wallet_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ pub type TariNodeId = tari_comms::peer_manager::NodeId;
pub type TariPrivateKey = tari_common_types::types::PrivateKey;
pub type TariOutputFeatures = tari_core::transactions::transaction_components::OutputFeatures;
pub type TariCommsConfig = tari_p2p::P2pConfig;
pub type TariCommitmentSignature = tari_common_types::types::ComAndPubSignature;
pub type TariTransactionKernel = tari_core::transactions::transaction_components::TransactionKernel;
pub type TariCovenant = tari_core::covenants::Covenant;
pub type TariEncryptedValue = tari_core::transactions::transaction_components::EncryptedValue;
Expand Down Expand Up @@ -1401,23 +1400,6 @@ pub unsafe extern "C" fn private_key_from_hex(key: *const c_char, error_out: *mu
}
}

/// Frees memory for a TariCommitmentSignature
///
/// ## Arguments
/// `com_sig` - The pointer to a TariCommitmentSignature
///
/// ## Returns
/// `()` - Does not return a value, equivalent to void in C
///
/// # Safety
/// None
#[no_mangle]
pub unsafe extern "C" fn commitment_signature_destroy(com_sig: *mut TariCommitmentSignature) {
if !com_sig.is_null() {
Box::from_raw(com_sig);
}
}

/// -------------------------------------------------------------------------------------------- ///
/// --------------------------------------- Covenant --------------------------------------------///

Expand Down
116 changes: 0 additions & 116 deletions base_layer/wallet_ffi/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,6 @@ struct Balance;

struct ByteVector;

/**
* # Commitment and public key (CAPK) signatures
*
* Given a commitment `commitment = a*H + x*G` and group element `pubkey = y*G`, a CAPK signature is based on
* a representation proof of both openings: `(a, x)` and `y`. It additionally binds to arbitrary message data `m`
* via the challenge to produce a signature construction.
*
* It is used in Tari protocols as part of transaction authorization.
*
* The construction works as follows:
* - Sample scalar nonces `r_a, r_x, r_y` uniformly at random.
* - Compute ephemeral values `ephemeral_commitment = r_a*H + r_x*G` and `ephemeral_pubkey = r_y*G`.
* - Use strong Fiat-Shamir to produce a challenge `e`. If `e == 0` (this is unlikely), abort and start over.
* - Compute the responses `u_a = r_a + e*a` and `u_x = r_x + e*x` and `u_y = r_y + e*y`.
*
* The signature is the tuple `(ephemeral_commitment, ephemeral_pubkey, u_a, u_x, u_y)`.
*
* To verify:
* - The verifier computes the challenge `e` and rejects the signature if `e == 0` (this is unlikely).
* - Verification succeeds if and only if the following equations hold: `u_a*H + u*x*G == ephemeral_commitment +
* e*commitment` `u_y*G == ephemeral_pubkey + e*pubkey`
*
* We note that it is possible to make verification slightly more efficient. To do so, the verifier selects a nonzero
* scalar weight `w` uniformly at random (not through Fiat-Shamir!) and accepts the signature if and only if the
* following equation holds:
* `u_a*H + (u_x + w*u_y)*G - ephemeral_commitment - w*ephemeral_pubkey - e*commitment - (w*e)*pubkey == 0`
* The use of efficient multiscalar multiplication algorithms may also be useful for efficiency.
* The use of precomputation tables for `G` and `H` may also be useful for efficiency.
*/
struct CommitmentAndPublicKeySignature_RistrettoPublicKey__RistrettoSecretKey;

struct CompletedTransaction;

struct Contact;
Expand Down Expand Up @@ -215,77 +184,6 @@ typedef PrivateKey TariPrivateKey;

typedef struct TariAddress TariWalletAddress;

/**
* # A commitment and public key (CAPK) signature implementation on Ristretto
*
* `RistrettoComAndPubSig` utilises the [curve25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek1)
* implementation of `ristretto255` to provide CAPK signature functionality.
*
* ## Examples
*
* You can create a `RistrettoComAndPubSig` from its component parts:
*
* ```edition2018
* # use tari_crypto::ristretto::*;
* # use tari_crypto::keys::*;
* # use tari_crypto::commitment::HomomorphicCommitment;
* # use tari_utilities::ByteArray;
* # use tari_utilities::hex::Hex;
*
* let ephemeral_commitment = HomomorphicCommitment::from_hex(
* "8063d85e151abee630e643e2b3dc47bfaeb8aa859c9d10d60847985f286aad19",
* )
* .unwrap();
* let ephemeral_pubkey = RistrettoPublicKey::from_hex(
* "8063d85e151abee630e643e2b3dc47bfaeb8aa859c9d10d60847985f286aad19",
* )
* .unwrap();
* let u_a = RistrettoSecretKey::from_bytes(b"10000000000000000000000010000000").unwrap();
* let u_x = RistrettoSecretKey::from_bytes(b"a00000000000000000000000a0000000").unwrap();
* let u_y = RistrettoSecretKey::from_bytes(b"a00000000000000000000000a0000000").unwrap();
* let sig = RistrettoComAndPubSig::new(ephemeral_commitment, ephemeral_pubkey, u_a, u_x, u_y);
* ```
*
* or you can create a signature for a commitment by signing a message with knowledge of the commitment and then
* verify it by calling the `verify_challenge` method:
*
* ```rust
* # use tari_crypto::ristretto::*;
* # use tari_crypto::keys::*;
* # use tari_crypto::hash::blake2::Blake256;
* # use digest::Digest;
* # use tari_crypto::commitment::HomomorphicCommitmentFactory;
* # use tari_crypto::ristretto::pedersen::*;
* use tari_crypto::ristretto::pedersen::commitment_factory::PedersenCommitmentFactory;
* use tari_utilities::hex::Hex;
*
* let mut rng = rand::thread_rng();
* let a_val = RistrettoSecretKey::random(&mut rng);
* let x_val = RistrettoSecretKey::random(&mut rng);
* let y_val = RistrettoSecretKey::random(&mut rng);
* let a_nonce = RistrettoSecretKey::random(&mut rng);
* let x_nonce = RistrettoSecretKey::random(&mut rng);
* let y_nonce = RistrettoSecretKey::random(&mut rng);
* let e = Blake256::digest(b"Maskerade"); // In real life, this should be strong Fiat-Shamir!
* let factory = PedersenCommitmentFactory::default();
* let commitment = factory.commit(&x_val, &a_val);
* let pubkey = RistrettoPublicKey::from_secret_key(&y_val);
* let sig = RistrettoComAndPubSig::sign(
* &a_val, &x_val, &y_val, &a_nonce, &x_nonce, &y_nonce, &e, &factory,
* )
* .unwrap();
* assert!(sig.verify_challenge(&commitment, &pubkey, &e, &factory, &mut rng));
* ```
*/
typedef struct CommitmentAndPublicKeySignature_RistrettoPublicKey__RistrettoSecretKey RistrettoComAndPubSig;

/**
* Define the explicit Commitment Signature implementation for the Tari base layer.
*/
typedef RistrettoComAndPubSig ComAndPubSignature;

typedef ComAndPubSignature TariCommitmentSignature;

typedef struct Covenant TariCovenant;

typedef struct EncryptedValue TariEncryptedValue;
Expand Down Expand Up @@ -843,20 +741,6 @@ TariPrivateKey *private_key_generate(void);
TariPrivateKey *private_key_from_hex(const char *key,
int *error_out);

/**
* Frees memory for a TariCommitmentSignature
*
* ## Arguments
* `com_sig` - The pointer to a TariCommitmentSignature
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void commitment_signature_destroy(TariCommitmentSignature *com_sig);

/**
* -------------------------------------------------------------------------------------------- ///
* --------------------------------------- Covenant --------------------------------------------///
Expand Down

0 comments on commit 5703d02

Please sign in to comment.