Skip to content

Commit

Permalink
Add more boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienFT committed Nov 14, 2024
1 parent 9705f6d commit d53e060
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 6 deletions.
75 changes: 75 additions & 0 deletions fuel-vm/src/interpreter/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,45 @@ where
c,
)
}

pub(crate) fn ec_add(&mut self, a: Word, b: Word, c: Word, d: Word) -> SimpleResult<()> {
let owner = self.ownership_registers();
ec_add(
self.memory.as_mut(),
owner,
self.registers.pc_mut(),
a,
b,
c,
d,
)
}

pub(crate) fn ec_mul(&mut self, a: Word, b: Word, c: Word, d: Word) -> SimpleResult<()> {
let owner = self.ownership_registers();
ec_mul(
self.memory.as_mut(),
owner,
self.registers.pc_mut(),
a,
b,
c,
d,
)
}

pub(crate) fn ec_pairing(&mut self, a: Word, b: Word, c: Word, d: Word) -> SimpleResult<()> {
let owner = self.ownership_registers();
ec_pairing(
self.memory.as_mut(),
owner,
self.registers.pc_mut(),
a,
b,
c,
d,
)
}
}

pub(crate) fn secp256k1_recover(
Expand Down Expand Up @@ -202,3 +241,39 @@ pub(crate) fn sha256(
memory.write_bytes(owner, a, *Hasher::hash(memory.read(b, c)?))?;
Ok(inc_pc(pc)?)
}

pub(crate) fn ec_add(
_memory: &mut MemoryInstance,
_owner: OwnershipRegisters,
_pc: RegMut<PC>,
_a: Word,
_b: Word,
_c: Word,
_d: Word,
) -> SimpleResult<()> {
todo!()
}

pub(crate) fn ec_mul(
_memory: &mut MemoryInstance,
_owner: OwnershipRegisters,
_pc: RegMut<PC>,
_a: Word,
_b: Word,
_c: Word,
_d: Word,
) -> SimpleResult<()> {
todo!()
}

pub(crate) fn ec_pairing(
_memory: &mut MemoryInstance,
_owner: OwnershipRegisters,
_pc: RegMut<PC>,
_a: Word,
_b: Word,
_c: Word,
_d: Word,
) -> SimpleResult<()> {
todo!()
}
15 changes: 9 additions & 6 deletions fuel-vm/src/interpreter/executors/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,16 +918,19 @@ where
self.blob_load_data(r!(a), r!(b), r!(c), r!(d))?;
}

Instruction::EADD(_edd) => {
unimplemented!("EADD is not yet implemented")
Instruction::EADD(eadd) => {
let (a, b, c, d) = eadd.unpack();
self.ec_add(r!(a), r!(b), r!(c), r!(d))?;
}

Instruction::EMUL(_emul) => {
unimplemented!("EMUL is not yet implemented")
Instruction::EMUL(emul) => {
let (a, b, c, d) = emul.unpack();
self.ec_mul(r!(a), r!(b), r!(c), r!(d))?;
}

Instruction::EPAR(_epar) => {
unimplemented!("EPAR is not yet implemented")
Instruction::EPAR(epar) => {
let (a, b, c, d) = epar.unpack();
self.ec_pairing(r!(a), r!(b), r!(c), r!(d))?;
}
}

Expand Down

0 comments on commit d53e060

Please sign in to comment.