Skip to content

Commit

Permalink
refactor!: rename Input to BlindedInput
Browse files Browse the repository at this point in the history
- This is stringent with the naming of the other types in the crate.
  • Loading branch information
oetyng committed Mar 27, 2023
1 parent 4fc3c9f commit 3c9ff69
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub use crate::{
},
token::Token,
transaction::{
Amount, BlindedOutput, DbcTransaction, Input, Output, RevealedAmount, RevealedInput,
Amount, BlindedInput, BlindedOutput, DbcTransaction, Output, RevealedAmount, RevealedInput,
RevealedTransaction,
},
verification::{get_blinded_amounts_from_transaction, TransactionVerifier},
Expand Down
8 changes: 4 additions & 4 deletions src/transaction/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ impl RevealedInput {
self.revealed_amount.blinded_amount(pc_gens)
}

pub fn sign(&self, msg: &[u8], pc_gens: &PedersenGens) -> Input {
pub fn sign(&self, msg: &[u8], pc_gens: &PedersenGens) -> BlindedInput {
let public_key = self.public_key();
let blinded_amount = self.blinded_amount(pc_gens);
let signature = self.secret_key.sign(msg);

Input {
BlindedInput {
public_key,
blinded_amount,
signature,
Expand All @@ -56,13 +56,13 @@ impl RevealedInput {

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Eq, PartialEq, Debug, Clone)]
pub struct Input {
pub struct BlindedInput {
pub public_key: PublicKey,
pub blinded_amount: BlindedAmount,
pub signature: Signature,
}

impl Input {
impl BlindedInput {
pub fn to_bytes(&self) -> Vec<u8> {
let mut v: Vec<u8> = Default::default();
v.extend(self.public_key.to_bytes().as_ref());
Expand Down
2 changes: 1 addition & 1 deletion src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod output;
mod revealed_amount;

pub(crate) use error::Error;
pub use input::{Input, RevealedInput};
pub use input::{BlindedInput, RevealedInput};
pub use output::{Amount, BlindedOutput, DbcTransaction, Output, RevealedTransaction};
pub use revealed_amount::RevealedAmount;

Expand Down
8 changes: 4 additions & 4 deletions src/transaction/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tiny_keccak::{Hasher, Sha3};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use super::{Error, Input, Result, RevealedAmount, RevealedInput};
use super::{BlindedInput, Error, Result, RevealedAmount, RevealedInput};
pub(super) const RANGE_PROOF_BITS: usize = 64; // note: Range Proof max-bits is 64. allowed are: 8, 16, 32, 64 (only)
// This limits our amount field to 64 bits also.
pub(super) const RANGE_PROOF_PARTIES: usize = 1; // The maximum number of parties that can produce an aggregated proof
Expand Down Expand Up @@ -101,7 +101,7 @@ impl RevealedTransaction {
let msg = gen_message_for_signing(&self.public_keys(), &input_amounts, &blinded_outputs);

// We create a signature for each input
let signed_inputs: Vec<Input> = self
let blinded_inputs: Vec<BlindedInput> = self
.inputs
.iter()
.map(|input| input.sign(&msg, &Self::pc_gens()))
Expand All @@ -114,7 +114,7 @@ impl RevealedTransaction {

Ok((
DbcTransaction {
inputs: signed_inputs,
inputs: blinded_inputs,
outputs: blinded_outputs,
},
revealed_output_amounts,
Expand Down Expand Up @@ -295,7 +295,7 @@ impl BlindedOutput {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct DbcTransaction {
pub inputs: Vec<Input>,
pub inputs: Vec<BlindedInput>,
pub outputs: Vec<BlindedOutput>,
}

Expand Down

0 comments on commit 3c9ff69

Please sign in to comment.