Skip to content

Commit

Permalink
remove signal_hash from PbhPayload
Browse files Browse the repository at this point in the history
  • Loading branch information
0xForerunner committed Oct 10, 2024
1 parent dee37f9 commit 4309b97
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 34 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ The PBH payload contains the following fields:

`nullifier_hash` - A nullifier hash used to keep track of previously used pbh transactions

`signal_hash` - This is the transaction hash which associates this proof with a specific transaction

`root` - The root of the merkle tree for which this proof was generated

`proof` - The actual semaphore proof verifying that the sender is included in the set of orb verified users
1 change: 0 additions & 1 deletion world-chain-builder/crates/toolkit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ async fn main() -> eyre::Result<()> {
external_nullifier: external_nullifier.to_string(),
external_nullifier_hash,
nullifier_hash,
signal_hash,
root: inclusion_proof.root,
proof: world_chain_builder::pbh::semaphore::Proof(semaphore_proof),
};
Expand Down
1 change: 0 additions & 1 deletion world-chain-builder/src/e2e_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ impl WorldChainBuilderTestContext {
PbhPayload {
root: self.tree.root(),
nullifier_hash,
signal_hash,
external_nullifier,
proof,
external_nullifier_hash,
Expand Down
4 changes: 0 additions & 4 deletions world-chain-builder/src/pbh/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ pub struct PbhPayload {
/// A nullifier hash used to keep track of
/// previously used pbh transactions
pub nullifier_hash: Field,
/// This is the transaction hash
/// which associates this proof with a specific transaction
pub signal_hash: Field,
/// The root of the merkle tree for which this proof
/// was generated
pub root: Field,
Expand Down Expand Up @@ -86,7 +83,6 @@ mod test {
external_nullifier: "0-012025-11".to_string(),
external_nullifier_hash: Field::from(9u64),
nullifier_hash: Field::from(10u64),
signal_hash: Field::from(11u64),
root: Field::from(12u64),
proof,
};
Expand Down
28 changes: 2 additions & 26 deletions world-chain-builder/src/pool/validator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! World Chain transaction pool types
use std::sync::Arc;

use alloy_primitives::TxHash;
use reth::transaction_pool::{
Pool, TransactionOrigin, TransactionValidationOutcome, TransactionValidationTaskExecutor,
TransactionValidator,
Expand Down Expand Up @@ -156,19 +155,6 @@ where
}
}

pub fn validate_signal_hash(
&self,
tx_hash: &TxHash,
semaphore_proof: &PbhPayload,
) -> Result<(), TransactionValidationError> {
// TODO: we probably don't need to hash the hash.
let expected = hash_to_field(tx_hash.as_slice());
if semaphore_proof.signal_hash != expected {
return Err(WorldChainTransactionPoolInvalid::InvalidSignalHash.into());
}
Ok(())
}

pub fn validate_semaphore_proof(
&self,
transaction: &Tx,
Expand All @@ -190,12 +176,11 @@ where
self.validate_root(semaphore_proof)?;
self.validate_external_nullifier(date, semaphore_proof)?;
self.validate_nullifier(semaphore_proof)?;
self.validate_signal_hash(transaction.hash(), semaphore_proof)?;

let res = verify_proof(
semaphore_proof.root,
semaphore_proof.nullifier_hash,
semaphore_proof.signal_hash,
hash_to_field(transaction.hash().as_ref()),
semaphore_proof.external_nullifier_hash,
&semaphore_proof.proof.0,
TREE_DEPTH,
Expand Down Expand Up @@ -388,7 +373,6 @@ pub mod tests {
PbhPayload {
root: tree.root(),
nullifier_hash,
signal_hash,
external_nullifier,
proof,
external_nullifier_hash,
Expand Down Expand Up @@ -506,8 +490,7 @@ pub mod tests {
#[tokio::test]
async fn invalid_signal_hash() {
let validator = world_chain_validator();
let mut transaction = get_pbh_transaction();
transaction.semaphore_proof.as_mut().unwrap().signal_hash = Field::from(0);
let transaction = get_pbh_transaction();

validator.inner.client().add_account(
transaction.sender(),
Expand Down Expand Up @@ -543,7 +526,6 @@ pub mod tests {
external_nullifier: "0-012025-11".to_string(),
external_nullifier_hash: Field::from(9u64),
nullifier_hash: Field::from(10u64),
signal_hash: Field::from(11u64),
root,
proof,
};
Expand Down Expand Up @@ -579,7 +561,6 @@ pub mod tests {
external_nullifier: "0-012025-11".to_string(),
external_nullifier_hash: Field::from(9u64),
nullifier_hash: Field::from(10u64),
signal_hash: Field::from(11u64),
root,
proof,
};
Expand Down Expand Up @@ -610,7 +591,6 @@ pub mod tests {
external_nullifier: external_nullifier.to_string(),
external_nullifier_hash: Field::ZERO,
nullifier_hash: Field::ZERO,
signal_hash: Field::ZERO,
root: Field::ZERO,
proof: Default::default(),
};
Expand All @@ -630,7 +610,6 @@ pub mod tests {
external_nullifier: external_nullifier.to_string(),
external_nullifier_hash: hash_to_field(external_nullifier.as_bytes()),
nullifier_hash: Field::ZERO,
signal_hash: Field::ZERO,
root: Field::ZERO,
proof: Default::default(),
};
Expand All @@ -650,7 +629,6 @@ pub mod tests {
external_nullifier: external_nullifier.to_string(),
external_nullifier_hash: hash_to_field(external_nullifier.as_bytes()),
nullifier_hash: Field::ZERO,
signal_hash: Field::ZERO,
root: Field::ZERO,
proof: Default::default(),
};
Expand All @@ -676,7 +654,6 @@ pub mod tests {
external_nullifier: external_nullifier.to_string(),
external_nullifier_hash: hash_to_field(external_nullifier.as_bytes()),
nullifier_hash: Field::ZERO,
signal_hash: Field::ZERO,
root: Field::ZERO,
proof: Default::default(),
};
Expand All @@ -701,7 +678,6 @@ pub mod tests {
external_nullifier: "0-012025-11".to_string(),
external_nullifier_hash: Field::from(9u64),
nullifier_hash: Field::from(10u64),
signal_hash: Field::from(11u64),
root: Field::from(12u64),
proof,
};
Expand Down

0 comments on commit 4309b97

Please sign in to comment.