-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ff9fe0
commit 942b496
Showing
3 changed files
with
51 additions
and
20 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 |
---|---|---|
@@ -1,23 +1,22 @@ | ||
use dep::protocol_types::hash::silo_nullifier; | ||
use crate::context::PrivateContext; | ||
use crate::context::{PrivateContext, ContextInterface}; | ||
use crate::history::nullifier_inclusion::prove_nullifier_inclusion; | ||
|
||
pub fn mark_as_initialized(context: &mut PrivateContext) { | ||
let init_nullifier = compute_unsiloed_contract_initialization_nullifier(*context); | ||
context.push_new_nullifier(init_nullifier, 0); | ||
} | ||
|
||
// 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) { | ||
pub fn assert_is_initialized<TContext>(context: &mut TContext) where TContext: ContextInterface { | ||
let init_nullifier = compute_contract_initialization_nullifier(*context); | ||
prove_nullifier_inclusion(init_nullifier, *context); | ||
} | ||
|
||
pub fn compute_contract_initialization_nullifier(context: PrivateContext) -> Field { | ||
pub fn compute_contract_initialization_nullifier<TContext>(context: TContext) -> Field where TContext: ContextInterface { | ||
let address = context.this_address(); | ||
silo_nullifier(address, compute_unsiloed_contract_initialization_nullifier(context)) | ||
} | ||
|
||
pub fn compute_unsiloed_contract_initialization_nullifier(context: PrivateContext) -> Field { | ||
pub fn compute_unsiloed_contract_initialization_nullifier<TContext>(context: TContext) -> Field where TContext: ContextInterface{ | ||
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
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