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

Host-optimized pairing cryptography with the Barreto-Naehrig curve #4852

Closed
wants to merge 7 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
45 changes: 42 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions execution_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license = "Apache-2.0"

[dependencies]
anyhow = "1.0.33"
bn = { version = "0.5", package = "zeropool-bn", default-features = false }
base16 = "0.2.1"
bincode = "1.3.1"
casper-storage = { version = "2.0.0", path = "../storage" }
Expand Down
3 changes: 3 additions & 0 deletions execution_engine/src/resolvers/v1_function_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub(crate) enum FunctionIndex {
ManageMessageTopic,
EmitMessage,
LoadCallerInformation,
AltBn128Add,
AltBn128Mul,
AltBn128Pairing,
}

impl From<FunctionIndex> for usize {
Expand Down
12 changes: 12 additions & 0 deletions execution_engine/src/resolvers/v1_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ impl ModuleImportResolver for RuntimeModuleImportResolver {
Signature::new(&[ValueType::I32; 4][..], Some(ValueType::I32)),
FunctionIndex::EmitMessage.into(),
),
"casper_alt_bn128_add" => FuncInstance::alloc_host(
Signature::new(&[ValueType::I32; 6][..], Some(ValueType::I32)),
FunctionIndex::AltBn128Add.into(),
),
"casper_alt_bn128_mul" => FuncInstance::alloc_host(
Signature::new(&[ValueType::I32; 5][..], Some(ValueType::I32)),
FunctionIndex::AltBn128Mul.into(),
),
"casper_alt_bn128_pairing" => FuncInstance::alloc_host(
Signature::new(&[ValueType::I32; 3][..], Some(ValueType::I32)),
FunctionIndex::AltBn128Pairing.into(),
),
_ => {
return Err(InterpreterError::Function(format!(
"host module doesn't export function with name {}",
Expand Down
4 changes: 4 additions & 0 deletions execution_engine/src/runtime/builtins.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Builtin functions for the execution engine.
//!
//! Functions here are lifted to the host and are implemented in the host's native code.
pub mod altbn128;
Loading
Loading