From 5703d02d419b1a5f49f4523707f7f689c01eb1b5 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Wed, 23 Nov 2022 13:53:27 +0200 Subject: [PATCH] fix: remove unused ffi types and methods (#4948) Description --- Remove unused FFI methods --- base_layer/wallet_ffi/src/lib.rs | 18 ----- base_layer/wallet_ffi/wallet.h | 116 ------------------------------- 2 files changed, 134 deletions(-) diff --git a/base_layer/wallet_ffi/src/lib.rs b/base_layer/wallet_ffi/src/lib.rs index 91d7f0860a..7da321a601 100644 --- a/base_layer/wallet_ffi/src/lib.rs +++ b/base_layer/wallet_ffi/src/lib.rs @@ -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; @@ -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 --------------------------------------------/// diff --git a/base_layer/wallet_ffi/wallet.h b/base_layer/wallet_ffi/wallet.h index 5b13d75924..b65e8993b0 100644 --- a/base_layer/wallet_ffi/wallet.h +++ b/base_layer/wallet_ffi/wallet.h @@ -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; @@ -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; @@ -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 --------------------------------------------///