Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove unencrypted logs from private functions (except private_token_contract) #1758

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions yarn-project/aztec.js/src/abis/ecdsa_account_contract.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions yarn-project/aztec.js/src/abis/schnorr_account_contract.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ contract EasyPrivateToken {
abi,
abi::PrivateContextInputs,
context::PrivateContext,
log::emit_unencrypted_log,
note::{
note_header::NoteHeader,
utils as note_utils,
Expand All @@ -39,8 +38,6 @@ contract EasyPrivateToken {

balances.at(owner).add(&mut context, initial_supply, owner);

emit_unencrypted_log(&mut context, "Balance set in constructor");

// Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel.
context.finish()
}
Expand All @@ -60,8 +57,6 @@ contract EasyPrivateToken {

balances.at(owner).add(&mut context, amount, owner);

emit_unencrypted_log(&mut context, "Coins minted");

// Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel..
context.finish()
}
Expand All @@ -83,8 +78,6 @@ contract EasyPrivateToken {
balances.at(sender).sub(&mut context, amount, sender);

balances.at(recipient).add(&mut context, amount, recipient);

emit_unencrypted_log(&mut context, "Coins transferred");

// Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel..
context.finish()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ contract ExamplePublicStateIncrement {
PrivateContext,
PublicContext,
};
use dep::aztec::oracle::logs::emit_unencrypted_log;
use dep::aztec::types::point::Point;
use crate::storage::Storage;
use dep::aztec::state_vars::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ contract Lending {
PrivateContext,
PublicContext
};
use dep::aztec::oracle::{logs::emit_unencrypted_log};
use dep::aztec::public_call_stack_item::PublicCallStackItem;
use crate::storage::{Storage, Asset};
use crate::safe_math::SafeU120;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ contract PrivateTokenAirdrop {
note_header::NoteHeader,
utils as note_utils,
};
use dep::aztec::log::emit_unencrypted_log;

use crate::storage::Storage;
use crate::claim_note::{ClaimNote, ClaimNoteMethods};
Expand All @@ -38,7 +37,6 @@ contract PrivateTokenAirdrop {
let owner_balance = storage.balances.at(owner);
if (initial_supply != 0) {
send_note(&mut context, owner_balance, initial_supply, owner);
emit_unencrypted_log(&mut context, "Balance set in constructor");
}

// Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel.
Expand All @@ -60,7 +58,6 @@ contract PrivateTokenAirdrop {
// Insert new note to a set of user notes and emit the newly created encrypted note preimage via oracle call.
let owner_balance = storage.balances.at(owner);
send_note(&mut context, owner_balance, amount, owner);
emit_unencrypted_log(&mut context, "Coins minted");

// Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel..
context.finish()
Expand All @@ -86,8 +83,6 @@ contract PrivateTokenAirdrop {
// Creates new note for the recipient.
let recipient_balance = storage.balances.at(recipient);
send_note(&mut context, recipient_balance, amount, recipient);

emit_unencrypted_log(&mut context, "Coins transferred");

// Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel..
context.finish()
Expand Down Expand Up @@ -185,12 +180,6 @@ contract PrivateTokenAirdrop {

send_notes(&mut context, [recipient1_balance, recipient2_balance, recipient3_balance], amounts, recipients);

// Also emit an unencrypted log, eg. "Coins transferred"
// In this example, we emit the first output note's commitment to ensure that the unencrypted log
// for each call to this function is distinct. This is done to detect any issues while collecting
// logs when building a transaction. See: https://github.com/AztecProtocol/aztec-packages/issues/987
emit_unencrypted_log(&mut context, context.new_commitments.storage[0]);

// Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel..
context.finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ contract PrivateToken {
let owner_balance = storage.balances.at(owner);
if (initial_supply != 0) {
send_note(&mut context, owner_balance, initial_supply, owner);

// TODO(1757) Remove this for public release.
// Private functions must not emit unencrypted logs to avoid leaking any information.
emit_unencrypted_log(&mut context, "Balance set in constructor");
}

Expand Down Expand Up @@ -70,6 +73,8 @@ contract PrivateToken {

// docs:start:unencrypted

// TODO(1757) Remove this for public release.
// Private functions must not emit unencrypted logs to avoid leaking any information.
emit_unencrypted_log(&mut context, "Coins minted");

// docs:end:unencrypted
Expand Down Expand Up @@ -101,6 +106,8 @@ contract PrivateToken {
let recipient_balance = storage.balances.at(recipient);
send_note(&mut context, recipient_balance, amount, recipient);

// TODO(1757) Remove this for public release.
// Private functions must not emit unencrypted logs to avoid leaking any information.
emit_unencrypted_log(&mut context, "Coins transferred");

// Return private circuit public inputs. All private functions need to return this as it is part of the input of the private kernel..
Expand Down
1 change: 1 addition & 0 deletions yarn-project/noir-libs/noir-aztec/src/oracle/logs.nr
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ unconstrained fn emit_encrypted_log<N>(
#[oracle(emitUnencryptedLog)]
fn emit_unencrypted_log_oracle<T>(_message: T) -> Field {}

// SECURITY WARNING: Do not use emit_unencrypted_log in private functions to avoid leaking any information.
unconstrained fn emit_unencrypted_log<T>(message: T) -> [Field; NUM_FIELDS_PER_SHA256] {
// https://github.com/AztecProtocol/aztec-packages/issues/885
[emit_unencrypted_log_oracle(message), 0]
Expand Down