-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!(aztec-nr): move nullifier testing inside contexts
- Loading branch information
Showing
18 changed files
with
210 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 27 additions & 38 deletions
65
noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,53 @@ | ||
use dep::protocol_types::{ | ||
address::{AztecAddress, EthAddress}, | ||
contract_class_id::ContractClassId, | ||
grumpkin_point::GrumpkinPoint, | ||
hash::silo_nullifier, | ||
constants::DEPLOYER_CONTRACT_ADDRESS | ||
address::{AztecAddress, EthAddress}, contract_class_id::ContractClassId, | ||
grumpkin_point::GrumpkinPoint, hash::silo_nullifier, constants::DEPLOYER_CONTRACT_ADDRESS | ||
}; | ||
use dep::std::merkle::compute_merkle_root; | ||
|
||
use crate::{ | ||
context::PrivateContext, | ||
history::{ | ||
nullifier_inclusion::prove_nullifier_inclusion_at, | ||
nullifier_non_inclusion::prove_nullifier_not_included_at, | ||
} | ||
}; | ||
use crate::context::PrivateContext; | ||
|
||
pub fn prove_contract_deployment_at( | ||
contract_address: AztecAddress, | ||
block_number: u32, | ||
context: PrivateContext | ||
) { | ||
pub fn prove_contract_deployment_at(contract_address: AztecAddress, block_number: u32, context: PrivateContext) { | ||
// Compute deployment nullifier | ||
let nullifier = silo_nullifier(AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), contract_address.to_field()); | ||
let nullifier = silo_nullifier( | ||
AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), | ||
contract_address.to_field() | ||
); | ||
|
||
// Prove its inclusion | ||
prove_nullifier_inclusion_at(nullifier, block_number, context); | ||
assert( | ||
context.nullifier_valid_inclusion_at(nullifier, block_number), "Cannot prove contract deployment nullifier inclusion" | ||
); | ||
} | ||
|
||
pub fn prove_contract_non_deployment_at( | ||
contract_address: AztecAddress, | ||
block_number: u32, | ||
context: PrivateContext | ||
) { | ||
pub fn prove_contract_non_deployment_at(contract_address: AztecAddress, block_number: u32, context: PrivateContext) { | ||
// Compute deployment nullifier | ||
let nullifier = silo_nullifier(AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), contract_address.to_field()); | ||
let nullifier = silo_nullifier( | ||
AztecAddress::from_field(DEPLOYER_CONTRACT_ADDRESS), | ||
contract_address.to_field() | ||
); | ||
|
||
// Prove its non-inclusion | ||
prove_nullifier_not_included_at(nullifier, block_number, context); | ||
assert( | ||
context.nullifier_valid_non_inclusion_at(nullifier, block_number), "Cannot prove contract deployment nullifier non-inclusion" | ||
); | ||
} | ||
|
||
pub fn prove_contract_initialization_at( | ||
contract_address: AztecAddress, | ||
block_number: u32, | ||
context: PrivateContext | ||
) { | ||
pub fn prove_contract_initialization_at(contract_address: AztecAddress, block_number: u32, context: PrivateContext) { | ||
// Compute initialization nullifier | ||
let nullifier = silo_nullifier(contract_address, contract_address.to_field()); | ||
|
||
// Prove its inclusion | ||
prove_nullifier_inclusion_at(nullifier, block_number, context); | ||
assert( | ||
context.nullifier_valid_inclusion_at(nullifier, block_number), "Cannot prove contract initialization nullifier inclusion" | ||
); | ||
} | ||
|
||
pub fn prove_contract_non_initialization_at( | ||
contract_address: AztecAddress, | ||
block_number: u32, | ||
context: PrivateContext | ||
) { | ||
pub fn prove_contract_non_initialization_at(contract_address: AztecAddress, block_number: u32, context: PrivateContext) { | ||
// Compute initialization nullifier | ||
let nullifier = silo_nullifier(contract_address, contract_address.to_field()); | ||
|
||
// Prove its non-inclusion | ||
prove_nullifier_not_included_at(nullifier, block_number, context); | ||
assert( | ||
context.nullifier_valid_non_inclusion_at(nullifier, block_number), "Cannot prove contract initialization nullifier non-inclusion" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.