mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 08:43:06 +00:00
s/sha3/keccak256
This commit is contained in:
parent
ea0d081fa8
commit
e7dbba8d7b
@ -52,7 +52,7 @@ pub struct CpuColumnsView<T> {
|
||||
pub is_shl: T,
|
||||
pub is_shr: T,
|
||||
pub is_sar: T,
|
||||
pub is_sha3: T,
|
||||
pub is_keccak256: T,
|
||||
pub is_address: T,
|
||||
pub is_balance: T,
|
||||
pub is_origin: T,
|
||||
|
||||
@ -45,7 +45,7 @@ const OPCODES: [(u64, usize, usize); 102] = [
|
||||
(0x1c, 0, COL_MAP.is_shr),
|
||||
(0x1d, 0, COL_MAP.is_sar),
|
||||
(0x1e, 1, COL_MAP.is_invalid_1), // 0x1e-0x1f
|
||||
(0x20, 0, COL_MAP.is_sha3),
|
||||
(0x20, 0, COL_MAP.is_keccak256),
|
||||
(0x21, 0, COL_MAP.is_invalid_2),
|
||||
(0x22, 1, COL_MAP.is_invalid_3), // 0x22-0x23
|
||||
(0x24, 2, COL_MAP.is_invalid_4), // 0x24-0x27
|
||||
|
||||
@ -107,7 +107,7 @@ ecrecover_with_first_point:
|
||||
// stack: u2, Y, X, retdest
|
||||
|
||||
// Compute u2 * GENERATOR and chain the call to `ec_mul` with a call to `ec_add` to compute PUBKEY = (X,Y) + u2 * GENERATOR,
|
||||
// and a call to `pubkey_to_addr` to get the final result `SHA3(PUBKEY)[-20:]`.
|
||||
// and a call to `pubkey_to_addr` to get the final result `KECCAK256(PUBKEY)[-20:]`.
|
||||
PUSH pubkey_to_addr
|
||||
// stack: pubkey_to_addr, u2, Y, X, retdest
|
||||
SWAP3
|
||||
@ -130,13 +130,13 @@ ecrecover_with_first_point:
|
||||
// stack: Gx, Gy, u2, ec_add_valid_points_secp, X, Y, pubkey_to_addr, retdest
|
||||
%jump(ec_mul_valid_point_secp)
|
||||
|
||||
// Take a public key (PKx, PKy) and return the associated address SHA3(PKx || PKy)[-20:].
|
||||
// Take a public key (PKx, PKy) and return the associated address KECCAK256(PKx || PKy)[-20:].
|
||||
pubkey_to_addr:
|
||||
JUMPDEST
|
||||
// stack: PKx, PKy, retdest
|
||||
PUSH 0
|
||||
// stack: 0, PKx, PKy, retdest
|
||||
MSTORE
|
||||
MSTORE // TODO: switch to kernel memory (like `%mstore_current(@SEGMENT_KERNEL_GENERAL)`).
|
||||
// stack: PKy, retdest
|
||||
PUSH 0x20
|
||||
// stack: 0x20, PKy, retdest
|
||||
@ -146,7 +146,7 @@ pubkey_to_addr:
|
||||
// stack: 0x40, retdest
|
||||
PUSH 0
|
||||
// stack: 0, 0x40, retdest
|
||||
SHA3
|
||||
KECCAK256
|
||||
// stack: hash, retdest
|
||||
PUSH 0xffffffffffffffffffffffffffffffffffffffff
|
||||
// stack: 2^160-1, hash, retdest
|
||||
|
||||
@ -125,7 +125,7 @@ impl<'a> Interpreter<'a> {
|
||||
0x1b => todo!(), // "SHL",
|
||||
0x1c => todo!(), // "SHR",
|
||||
0x1d => todo!(), // "SAR",
|
||||
0x20 => self.run_sha3(), // "SHA3",
|
||||
0x20 => self.run_keccak256(), // "KECCAK256",
|
||||
0x30 => todo!(), // "ADDRESS",
|
||||
0x31 => todo!(), // "BALANCE",
|
||||
0x32 => todo!(), // "ORIGIN",
|
||||
@ -292,7 +292,7 @@ impl<'a> Interpreter<'a> {
|
||||
self.push(!x);
|
||||
}
|
||||
|
||||
fn run_sha3(&mut self) {
|
||||
fn run_keccak256(&mut self) {
|
||||
let offset = self.pop().as_usize();
|
||||
let size = self.pop().as_usize();
|
||||
let bytes = (offset..offset + size)
|
||||
|
||||
@ -35,7 +35,6 @@ pub(crate) fn get_opcode(mnemonic: &str) -> u8 {
|
||||
"SHR" => 0x1c,
|
||||
"SAR" => 0x1d,
|
||||
"KECCAK256" => 0x20,
|
||||
"SHA3" => 0x20,
|
||||
"ADDRESS" => 0x30,
|
||||
"BALANCE" => 0x31,
|
||||
"ORIGIN" => 0x32,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user