-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add aztec-nr private functions for initialization nullifier (#4807
- Loading branch information
1 parent
d367cc4
commit 4feaea5
Showing
7 changed files
with
85 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use dep::protocol_types::hash::silo_nullifier; | ||
use crate::context::PrivateContext; | ||
|
||
pub fn mark_as_initialized(context: &mut PrivateContext) { | ||
let init_nullifier = compute_unsiloed_contract_initialization_nullifier(context); | ||
context.push_new_nullifier(init_nullifier, 0); | ||
|
||
// We push a commitment as well and use this value to check initialization, | ||
// since we cannot yet read a nullifier from the same tx in which it was emitted. | ||
// Eventually, when that's supported, we should delete this note_hash and | ||
// have all checks rely on reading the nullifier directly. | ||
// TODO(@spalladino) Remove when possible. | ||
context.push_new_note_hash(init_nullifier); | ||
} | ||
|
||
// TODO(@spalladino): Add a variant using PublicContext once we can read nullifiers or note hashes from public-land. | ||
pub fn assert_is_initialized(context: &mut PrivateContext) { | ||
let init_nullifier = compute_contract_initialization_nullifier(context); | ||
context.push_read_request(init_nullifier); | ||
} | ||
|
||
pub fn compute_contract_initialization_nullifier(context: &mut PrivateContext) -> Field { | ||
let address = context.this_address(); | ||
silo_nullifier(address, compute_unsiloed_contract_initialization_nullifier(context)) | ||
} | ||
|
||
pub fn compute_unsiloed_contract_initialization_nullifier(context: &mut PrivateContext) -> Field { | ||
context.this_address().to_field() | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ mod deploy; | |
mod hash; | ||
mod hasher; | ||
mod history; | ||
mod initializer; | ||
mod key; | ||
mod log; | ||
mod messaging; | ||
|
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
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