mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 12:17:35 +03:00
Remove CoreInstruction; leaving leo_core as a placeholder
This commit is contained in:
parent
0bc04791b6
commit
d4230705e0
@ -3,3 +3,5 @@
|
||||
[![Crates.io](https://img.shields.io/crates/v/leo-ast.svg?color=neon)](https://crates.io/crates/leo-core)
|
||||
[![Authors](https://img.shields.io/badge/authors-Aleo-orange.svg)](../AUTHORS)
|
||||
[![License](https://img.shields.io/badge/License-GPLv3-blue.svg)](./LICENSE.md)
|
||||
|
||||
This directory acts as a placeholder for Leo core libraries.
|
@ -16,89 +16,3 @@
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
mod algorithms;
|
||||
pub use algorithms::*;
|
||||
|
||||
mod utilities;
|
||||
pub use utilities::*;
|
||||
|
||||
use leo_ast::Type;
|
||||
use leo_span::{sym, Symbol};
|
||||
|
||||
/// A core instruction that maps directly to an AVM bytecode instruction.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub enum CoreInstruction {
|
||||
BHP256Commit,
|
||||
BHP256Hash,
|
||||
BHP512Commit,
|
||||
BHP512Hash,
|
||||
BHP768Commit,
|
||||
BHP768Hash,
|
||||
BHP1024Commit,
|
||||
BHP1024Hash,
|
||||
|
||||
Pedersen64Commit,
|
||||
Pedersen64Hash,
|
||||
Pedersen128Commit,
|
||||
Pedersen128Hash,
|
||||
|
||||
Poseidon2Hash,
|
||||
Poseidon4Hash,
|
||||
Poseidon8Hash,
|
||||
}
|
||||
|
||||
impl CoreInstruction {
|
||||
/// Returns a `CoreInstruction` from the given module and method symbols.
|
||||
pub fn from_symbols(module: Symbol, function: Symbol) -> Option<Self> {
|
||||
Some(match (module, function) {
|
||||
(sym::BHP256, sym::commit) => Self::BHP256Commit,
|
||||
(sym::BHP256, sym::hash) => Self::BHP256Hash,
|
||||
(sym::BHP512, sym::commit) => Self::BHP512Commit,
|
||||
(sym::BHP512, sym::hash) => Self::BHP512Hash,
|
||||
(sym::BHP768, sym::commit) => Self::BHP768Commit,
|
||||
(sym::BHP768, sym::hash) => Self::BHP768Hash,
|
||||
(sym::BHP1024, sym::commit) => Self::BHP1024Commit,
|
||||
(sym::BHP1024, sym::hash) => Self::BHP1024Hash,
|
||||
|
||||
(sym::Pedersen64, sym::commit) => Self::Pedersen64Commit,
|
||||
(sym::Pedersen64, sym::hash) => Self::Pedersen64Hash,
|
||||
(sym::Pedersen128, sym::commit) => Self::Pedersen128Commit,
|
||||
(sym::Pedersen128, sym::hash) => Self::Pedersen128Hash,
|
||||
|
||||
(sym::Poseidon2, sym::hash) => Self::Poseidon2Hash,
|
||||
(sym::Poseidon4, sym::hash) => Self::Poseidon4Hash,
|
||||
(sym::Poseidon8, sym::hash) => Self::Poseidon8Hash,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the number of arguments required by the instruction.
|
||||
pub fn num_args(&self) -> usize {
|
||||
match self {
|
||||
Self::BHP256Commit => BHP256Commit::NUM_ARGS,
|
||||
Self::BHP256Hash => BHP256Hash::NUM_ARGS,
|
||||
Self::BHP512Commit => BHP512Commit::NUM_ARGS,
|
||||
Self::BHP512Hash => BHP512Hash::NUM_ARGS,
|
||||
Self::BHP768Commit => BHP768Commit::NUM_ARGS,
|
||||
Self::BHP768Hash => BHP768Hash::NUM_ARGS,
|
||||
Self::BHP1024Commit => BHP1024Commit::NUM_ARGS,
|
||||
Self::BHP1024Hash => BHP1024Hash::NUM_ARGS,
|
||||
|
||||
Self::Pedersen64Commit => Pedersen64Commit::NUM_ARGS,
|
||||
Self::Pedersen64Hash => Pedersen64Hash::NUM_ARGS,
|
||||
Self::Pedersen128Commit => Pedersen128Commit::NUM_ARGS,
|
||||
Self::Pedersen128Hash => Pedersen128Hash::NUM_ARGS,
|
||||
|
||||
Self::Poseidon2Hash => Poseidon2Hash::NUM_ARGS,
|
||||
Self::Poseidon4Hash => Poseidon4Hash::NUM_ARGS,
|
||||
Self::Poseidon8Hash => Poseidon8Hash::NUM_ARGS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A core function of a core struct, e.g. `hash` or `commit`
|
||||
/// Provides required type information to the type checker.
|
||||
trait CoreFunction {
|
||||
const NUM_INPUTS: usize;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user