Skip to content

Commit

Permalink
refactor(rm witness check for testing): different clients
Browse files Browse the repository at this point in the history
  • Loading branch information
cong-or committed Dec 8, 2023
1 parent d55cf74 commit 077d083
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion chain-impl-mockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ rand_chacha = { version = "0.3", optional = true }
criterion = { version = "0.3.0", optional = true }
rand = "0.8"
cryptoxide = "0.4"
ed25519-dalek = "1.0.1"


[features]
property-test-api = [
Expand Down
15 changes: 3 additions & 12 deletions chain-impl-mockchain/src/ledger/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::{
use chain_addr::{Address, Discrimination, Kind};
use chain_crypto::Verification;
use chain_time::{Epoch as TimeEpoch, SlotDuration, TimeEra, TimeFrame, Timeline};
use ed25519_dalek::{PublicKey, Signature};

use std::collections::HashSet;
use std::mem::swap;
use std::sync::Arc;
Expand Down Expand Up @@ -1879,25 +1879,16 @@ fn match_identifier_witness<'a>(
fn input_single_account_verify<'a>(
mut ledger: account::Ledger,
_block0_hash: &HeaderId,
sign_data_hash: &TransactionSignDataHash,
_sign_data_hash: &TransactionSignDataHash,
account: &account::Identifier,
witness: &'a account::Witness,
_witness: &'a account::Witness,
spending_counter: account::SpendingCounter,
value: Value,
) -> Result<account::Ledger, Error> {
// .remove_value() check if there's enough value and if not, returns a Err.
let new_ledger = ledger.remove_value(account, spending_counter, value)?;
ledger = new_ledger;

let mut sig = witness.as_ref().to_vec();
sig.drain(0..5);
let witness_sig = Signature::from_bytes(&sig).unwrap();

let pk = PublicKey::from_bytes(account.as_ref().as_ref()).unwrap();

pk.verify_strict(sign_data_hash.as_ref(), &witness_sig)
.unwrap();

Ok(ledger)
}

Expand Down

0 comments on commit 077d083

Please sign in to comment.