-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: derive address and class id in avm (#8897)
this PR adds tracing of the class id and contract instance when `getBytecode` (indicating a new context execution is happening in the simulator) is executed. We now derive the class id and the contract address in witgen, plus build the (unconstrained) circuit for: 1. the raw bytecode bytes, 2. the field encoded version 3. the bytecode hash derivation The circuit elements of the contract class id and address will be done in a follow up based on how we tackle nullifier request
- Loading branch information
1 parent
ca3abaa
commit 2ebe361
Showing
28 changed files
with
1,393 additions
and
881 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,13 +1,61 @@ | ||
namespace bytecode(256); | ||
|
||
pol commit packed; | ||
// Raw bytes | ||
pol commit bytes; | ||
pol commit bytes_pc; | ||
|
||
// =============== BYTECODE DECOMPOSITION ================================================= | ||
// Decomposed into 35 byte chunks to parse into instructions | ||
pol commit decomposed; | ||
|
||
// =============== BYTECODE ENCODING ================================================= | ||
// Bytes packed into 31 byte chunks | ||
pol commit as_fields; | ||
|
||
// =============== BYTECODE HASHING + ADDRESS DERIVATION ================================================= | ||
pol commit length_remaining; | ||
|
||
// Bytecode public commitment hash | ||
pol commit running_hash; | ||
|
||
// When this is 1, it represents when reached the end of a contract bytecode | ||
pol commit end_latch; | ||
end_latch * (1 - end_latch) = 0; | ||
|
||
/* Derive Class Id */ | ||
pol CONTRACT_LEAF = 16; | ||
pol commit arifact_hash; | ||
pol commit private_fn_root; | ||
// class_id = H(CONTRACT_LEAF, artifact_hash, private_fn_root, running_hash) | ||
pol commit class_id; | ||
|
||
// TODO: Come back to this; | ||
// pol commit class_id; | ||
// pol commit contract_address; | ||
/* Derive Contract Addr*/ | ||
pol CONTRACT_ADDRESS_V1 = 15; | ||
pol PARTIAL_ADDRESS = 27; | ||
// pol SALTED_INIT_HASH = H(PARTIAL_ADDR, salt, init_hash, deployer_addr); | ||
// pol PARTIAL_ADDR = H(PARTIAL_ADDR, class_id, SALTED_INIT_HASH); | ||
pol commit salt; | ||
pol commit initialization_hash; | ||
pol commit deployer_addr; | ||
// These are points in grumpkin | ||
// Nullifier Key | ||
pol commit nullifier_key_x; | ||
pol commit nullifier_key_y; | ||
// Incoming viewing public key | ||
pol commit incoming_viewing_key_x; | ||
pol commit incoming_viewing_key_y; | ||
// Outgoing viewing public key | ||
pol commit outgoing_viewing_key_x; | ||
pol commit outgoing_viewing_key_y; | ||
// Tagging viewing public key | ||
pol commit tagging_key_x; | ||
pol commit tagging_key_y; | ||
|
||
// When we flat hash these points, we need to include 0 to indicate non-inf | ||
// public_key_hash = H(nullifier_key_x,nullifier_key_y,0, incoming_viewing_key_x, incoming_viewing_key_y, 0, | ||
// outgoing_viewing_key_x, outgoing_viewing_key_y, 0, tagging_key_x, tagging_key_y,0) | ||
pol commit public_key_hash; | ||
// h = H(CONTRACT_ADDRESS_V1, public_key_hash, partial_address) | ||
// contract_address = h * G + incoming_viewing_key | ||
pol commit contract_address; | ||
|
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.