Skip to content

Commit

Permalink
refactor: replace mpc-sigs with meesign-crypto submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
dufkan committed Jul 12, 2023
1 parent ebcfdde commit 422c7a7
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 1,147 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "meesign_native/native/meesign-crypto"]
path = meesign_native/native/meesign-crypto
url = https://github.com/crocs-muni/meesign-crypto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'MpcSigsLib'
description: 'Bindings to mpc-sigs C API'
output: 'lib/src/generated/mpc_sigs_lib.dart'
name: 'MeeSignCryptoLib'
description: 'Bindings to meesign-crypto C API'
output: 'lib/src/generated/meesign_crypto_lib.dart'
headers:
entry-points:
- 'native/mpc-sigs/include/bindings.h'
- 'native/meesign-crypto/include/bindings.h'
# by default, code is generated recursively for all included headers,
# so specify only the headers we need (most notably avoid system headers)
include-directives:
Expand Down
4 changes: 2 additions & 2 deletions meesign_native/lib/meesign_native.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
library meesign_native;

export 'src/generated/mpc_sigs_lib.dart' show ProtocolId;
export 'src/mpc_sigs_wrapper.dart'
export 'src/generated/meesign_crypto_lib.dart' show ProtocolId;
export 'src/meesign_crypto_wrapper.dart'
show ProtocolWrapper, AuthWrapper, ElGamalWrapper;
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
// Generated by `package:ffigen`.
import 'dart:ffi' as ffi;

/// Bindings to mpc-sigs C API
class MpcSigsLib {
/// Bindings to meesign-crypto C API
class MeeSignCryptoLib {
/// Holds the symbol lookup function.
final ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
_lookup;

/// The symbols are looked up in [dynamicLibrary].
MpcSigsLib(ffi.DynamicLibrary dynamicLibrary)
MeeSignCryptoLib(ffi.DynamicLibrary dynamicLibrary)
: _lookup = dynamicLibrary.lookup;

/// The symbols are looked up with [lookup].
MpcSigsLib.fromLookup(
MeeSignCryptoLib.fromLookup(
ffi.Pointer<T> Function<T extends ffi.NativeType>(String symbolName)
lookup)
: _lookup = lookup;
Expand Down Expand Up @@ -233,6 +233,7 @@ class MpcSigsLib {
abstract class ProtocolId {
static const int Gg18 = 0;
static const int Elgamal = 1;
static const int Frost = 2;
}

class Buffer extends ffi.Struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'dart:typed_data';
import 'package:ffi/ffi.dart';

import 'dl_util.dart';
import 'generated/mpc_sigs_lib.dart';
import 'generated/meesign_crypto_lib.dart';

// TODO: profile the functions in this file
// many chunks of data are copied, can it be avoided?
Expand Down Expand Up @@ -38,7 +38,7 @@ class ProtocolData {
ProtocolData(this.context, this.data);
}

final MpcSigsLib _lib = MpcSigsLib(dlOpen('mpc_sigs'));
final MeeSignCryptoLib _lib = MeeSignCryptoLib(dlOpen('meesign_crypto'));

class Error {
Pointer<Pointer<Char>> ptr;
Expand Down
30 changes: 15 additions & 15 deletions meesign_native/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ else()
set(CARGO_BUILD_TYPE_OPT "$<$<NOT:$<CONFIG:Debug>>:--release>")
endif()

set(MPC_SIGS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mpc-sigs")
set(MPC_SIGS_BUILD_DIR "${MPC_SIGS_DIR}/target/${RUST_TARGET}/${RUST_BUILD_TYPE}")
set(MPC_SIGS_LIB "${MPC_SIGS_BUILD_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}mpc_sigs${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(MEESIGN_CRYPTO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/meesign-crypto")
set(MEESIGN_CRYPTO_BUILD_DIR "${MEESIGN_CRYPTO_DIR}/target/${RUST_TARGET}/${RUST_BUILD_TYPE}")
set(MEESIGN_CRYPTO_LIB "${MEESIGN_CRYPTO_BUILD_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}meesign_crypto${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(WIN32)
set(MPC_SIGS_IMPLIB "${MPC_SIGS_LIB}.lib")
set(MEESIGN_CRYPTO_IMPLIB "${MEESIGN_CRYPTO_LIB}.lib")
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
Expand All @@ -46,9 +46,9 @@ elseif(ANDROID)
get_filename_component(SSL_LIB_DIR ${SSL_LIB_LOCATION} DIRECTORY)
get_target_property(CRYPTO_INCLUDE_DIR OpenSSL::Crypto INTERFACE_INCLUDE_DIRECTORIES)

list(APPEND MPC_SIGS_DEPS ${CRYPTO_LIB_LOCATION})
list(APPEND MPC_SIGS_DEPS ${SSL_LIB_LOCATION})
set(MPC_SIGS_DEPS ${MPC_SIGS_DEPS} PARENT_SCOPE)
list(APPEND MEESIGN_CRYPTO_DEPS ${CRYPTO_LIB_LOCATION})
list(APPEND MEESIGN_CRYPTO_DEPS ${SSL_LIB_LOCATION})
set(MEESIGN_CRYPTO_DEPS ${MEESIGN_CRYPTO_DEPS} PARENT_SCOPE)

# invoke cargo so that openssl-sys
# correctly finds our Android OpenSSL distribution
Expand All @@ -75,18 +75,18 @@ elseif(ANDROID)
endif()

add_custom_target(
cargo_mpc_sigs
cargo_meesign_crypto
COMMAND ${CARGO_CMD}
WORKING_DIRECTORY ${MPC_SIGS_DIR}
BYPRODUCTS ${MPC_SIGS_LIB} ${MPC_SIGS_IMPLIB}
WORKING_DIRECTORY ${MEESIGN_CRYPTO_DIR}
BYPRODUCTS ${MEESIGN_CRYPTO_LIB} ${MEESIGN_CRYPTO_IMPLIB}
)

add_library(mpc_sigs INTERFACE)
add_dependencies(mpc_sigs cargo_mpc_sigs)
add_library(meesign_crypto INTERFACE)
add_dependencies(meesign_crypto cargo_meesign_crypto)
if(WIN32)
target_link_libraries(mpc_sigs INTERFACE "${MPC_SIGS_IMPLIB}")
target_link_libraries(meesign_crypto INTERFACE "${MEESIGN_CRYPTO_IMPLIB}")
else()
target_link_libraries(mpc_sigs INTERFACE "${MPC_SIGS_LIB}")
target_link_libraries(meesign_crypto INTERFACE "${MEESIGN_CRYPTO_LIB}")
endif()

set(MPC_SIGS_LIB "${MPC_SIGS_LIB}" PARENT_SCOPE)
set(MEESIGN_CRYPTO_LIB "${MEESIGN_CRYPTO_LIB}" PARENT_SCOPE)
1 change: 1 addition & 0 deletions meesign_native/native/meesign-crypto
Submodule meesign-crypto added at 08ca33
5 changes: 0 additions & 5 deletions meesign_native/native/mpc-sigs/.gitignore

This file was deleted.

24 changes: 0 additions & 24 deletions meesign_native/native/mpc-sigs/Cargo.toml

This file was deleted.

17 changes: 0 additions & 17 deletions meesign_native/native/mpc-sigs/build.rs

This file was deleted.

26 changes: 0 additions & 26 deletions meesign_native/native/mpc-sigs/proto/meesign.proto

This file was deleted.

39 changes: 0 additions & 39 deletions meesign_native/native/mpc-sigs/src/auth.rs

This file was deleted.

Loading

0 comments on commit 422c7a7

Please sign in to comment.