Skip to content
Open
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
14 changes: 3 additions & 11 deletions pairing-crypto.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,12 @@ Pod::Spec.new do |s|
s.license = "Apache-2.0"
s.authors = "MATTR Team"

s.platforms = { :ios => "9.0" }
s.platforms = { :ios => "12.0" }
s.source = { :git => "https://github.com/mattrglobal/pairing_crypto.git", :tag => "#{s.version}" }

# TODO: The external libraries must be commited to the repo when we decided to publish this pod.
s.vendored_libraries = 'wrappers/obj-c/libraries/libpairing_crypto_c.a'
s.source_files = 'wrappers/obj-c/pairing_crypto/*.{h,m,mm}'
s.requires_arc = true

s.pod_target_xcconfig = {
'VALID_ARCHS' => 'arm64 x86_64',
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => "arm64",
"HEADER_SEARCH_PATHS" => "$(CONFIGURATION_BUILD_DIR)",
"ENABLE_BITCODE" => "YES"
}
s.vendored_frameworks = 'libpairing_crypto_c.xcframework'
s.source_files = 'wrappers/obj-c/pairing_crypto/*.{h,m,mm}', 'libpairing_crypto_c.xcframework'

s.test_spec 'Tests' do |test_spec|
test_spec.source_files = 'wrappers/obj-c/tests/**/*.{h,m}'
Expand Down
4 changes: 2 additions & 2 deletions src/common/key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ macro_rules! bbs_bls_key_pair_impl {

/// Convert a vector of bytes of big-endian representation of the
/// secret key.
pub fn from_vec(bytes: &Vec<u8>) -> Result<Self, Error> {
pub fn from_vec(bytes: &[u8]) -> Result<Self, Error> {
match vec_to_byte_array::<{ Self::SIZE_BYTES }>(bytes) {
Ok(result) => Self::from_bytes(&result),
Err(e) => Err(e),
Expand Down Expand Up @@ -195,7 +195,7 @@ macro_rules! bbs_bls_key_pair_impl {

/// Convert a vector of bytes of big-endian representation of the
/// public key.
pub fn from_vec(bytes: &Vec<u8>) -> Result<Self, Error> {
pub fn from_vec(bytes: &[u8]) -> Result<Self, Error> {
match vec_to_byte_array::<{ Self::SIZE_BYTES }>(bytes) {
Ok(result) => Self::from_octets(&result),
Err(e) => Err(e),
Expand Down
6 changes: 2 additions & 4 deletions src/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ macro_rules! print_byte_array {

pub(crate) use print_byte_array;

pub fn vec_to_byte_array<const N: usize>(
vec: &Vec<u8>,
) -> Result<[u8; N], Error> {
pub fn vec_to_byte_array<const N: usize>(vec: &[u8]) -> Result<[u8; N], Error> {
let data_len = vec.len();
match <[u8; N]>::try_from(vec.clone()) {
match <[u8; N]>::try_from(vec.to_owned()) {
Ok(result) => Ok(result),
Err(_) => Err(Error::Conversion {
cause: format!(
Expand Down
2 changes: 1 addition & 1 deletion src/curves/bls12_381.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub use blstrs::{Bls12 as pairing_engine, *};
pub use blstrs::*;

/// Number of bytes to store a scalar.
pub(crate) const OCTET_SCALAR_LENGTH: usize = 32;
Expand Down
16 changes: 8 additions & 8 deletions src/schemes/bbs/core/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,14 @@ impl Proof {
/// Get the proof `Proof` from a sequence of bytes in big endian format.
/// This method implements `OctetsToProof` API as defined in BBS specification <https://identity.foundation/bbs-signature/draft-bbs-signatures.html#name-octetstoproof>.
/// Each member of `Proof` is deserialized from big-endian bytes.
/// Expected input size is `OCTET_POINT_G1_LENGTH * 3 + OCTET_SCALAR_LENGTH
/// * (5 + U)` where `OCTET_POINT_G1_LENGTH`, size of a point in `G1` in
/// ompressed form, `OCTET_SCALAR_LENGTH`, size of a `Scalar`, and `U` is
/// the number of hidden messages.
/// For BLS12-381 based implementation, OCTET_POINT_G1_LENGTH is 48 byes,
/// and OCTET_SCALAR_LENGTH is 32 bytes, then bytes sequence will be
/// treated as [48, 48, 32, 32, 32, 32*U ] to represent
/// proof = (Abar, Bbar, c, r2^, z^, (m^_1, ..., m^_U)).
/// Expected input size is
/// `OCTET_POINT_G1_LENGTH * 3 + OCTET_SCALAR_LENGTH * (5 + U)`
/// where `OCTET_POINT_G1_LENGTH`, size of a point in `G1` in
/// compressed form, `OCTET_SCALAR_LENGTH`, size of a `Scalar`, and `U` is
/// the number of hidden messages. For BLS12-381 based implementation,
/// OCTET_POINT_G1_LENGTH is 48 byes, and OCTET_SCALAR_LENGTH is 32 bytes,
/// then bytes sequence will be treated as [48, 48, 32, 32, 32, 32*U ] to
/// represent proof = (Abar, Bbar, c, r2^, z^, (m^_1, ..., m^_U)).
pub fn from_octets<B: AsRef<[u8]>>(bytes: B) -> Result<Self, Error> {
const PROOF_LEN_FLOOR: usize =
OCTET_POINT_G1_LENGTH * 2 + OCTET_SCALAR_LENGTH * 3;
Expand Down
7 changes: 1 addition & 6 deletions src/schemes/bls/ciphersuites.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
common::hash_param::h2c::HashToCurveParameter,
curves::bls12_381::{G1Projective, G2Projective},
curves::bls12_381::G1Projective,
};
use group::Group;

Expand All @@ -20,11 +20,6 @@ pub(crate) trait BlsCiphersuiteParameters: HashToCurveParameter {
fn p1() -> G1Projective {
G1Projective::generator()
}

/// Point on G2 to be used during signature and proof verification.
fn p2() -> G2Projective {
G2Projective::generator()
}
}

pub(crate) trait BlsSigAugCiphersuiteParameters:
Expand Down
4 changes: 2 additions & 2 deletions tools/bbs-fixtures-generator/src/generators/h2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use blstrs::{
use rand::RngCore;
use sha2::Sha256;
use sha3::Shake256;
use std::path::PathBuf;
use std::path::Path;

macro_rules! generate_hash_fixtures {
($hash_to_scalar_fn:ident,
Expand Down Expand Up @@ -131,7 +131,7 @@ macro_rules! generate_mocked_rnd_scalars_fixtures {
}};
}

pub fn generate(fixture_gen_input: &FixtureGenInput, output_dir: &PathBuf) {
pub fn generate(fixture_gen_input: &FixtureGenInput, output_dir: &Path) {
generate_hash_fixtures!(
bls12_381_shake_256_h2s,
bls12_381_shake_256_default_hash_to_scalar_dst,
Expand Down
4 changes: 2 additions & 2 deletions tools/bbs-fixtures-generator/src/generators/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::PathBuf;
use std::path::Path;

use crate::model::FixtureGenInput;

Expand All @@ -12,7 +12,7 @@ pub const PROOF_FIXTURES_SUBDIR: &str = "proof";

pub fn generate_fixtures(
fixture_gen_input: &FixtureGenInput,
fixture_output_dir: &PathBuf,
fixture_output_dir: &Path,
) {
signature::generate(fixture_gen_input, fixture_output_dir);

Expand Down
17 changes: 11 additions & 6 deletions wrappers/c/scripts/build-platform-targets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,23 @@ case $PLATFORM in
mkdir -p $OUTPUT_LOCATION/ios

# Create the directories at the output location for the release binaries
mkdir -p $OUTPUT_LOCATION/ios/x86_64
mkdir -p $OUTPUT_LOCATION/ios/x86_64-sim
mkdir -p $OUTPUT_LOCATION/ios/aarch64
mkdir -p $OUTPUT_LOCATION/ios/universal
mkdir -p $OUTPUT_LOCATION/ios/aarch64-sim
mkdir -p $OUTPUT_LOCATION/ios/universal-sim

# Install cargo-lipo
# see https://github.com/TimNN/cargo-lipo
cargo install cargo-lipo
rustup target install x86_64-apple-ios aarch64-apple-ios
cargo lipo -p $PROJECT_NAME --release
cp "$ROOT_DIRECTORY/target/x86_64-apple-ios/release/$INPUT_FILE.a" "$OUTPUT_LOCATION/ios/x86_64/$OUTPUT_FILE.a"
rustup target install x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim
# Build for 64 bit arm ios devices
cargo build -p $PROJECT_NAME --release --target aarch64-apple-ios
# Build for intel and arm desktop simulators
cargo lipo -p $PROJECT_NAME --release --targets x86_64-apple-ios,aarch64-apple-ios-sim
cp "$ROOT_DIRECTORY/target/x86_64-apple-ios/release/$INPUT_FILE.a" "$OUTPUT_LOCATION/ios/x86_64-sim/$OUTPUT_FILE.a"
cp "$ROOT_DIRECTORY/target/aarch64-apple-ios/release/$INPUT_FILE.a" "$OUTPUT_LOCATION/ios/aarch64/$OUTPUT_FILE.a"
cp "$ROOT_DIRECTORY/target/universal/release/$INPUT_FILE.a" "$OUTPUT_LOCATION/ios/universal/$OUTPUT_FILE.a"
cp "$ROOT_DIRECTORY/target/aarch64-apple-ios-sim/release/$INPUT_FILE.a" "$OUTPUT_LOCATION/ios/aarch64-sim/$OUTPUT_FILE.a"
cp "$ROOT_DIRECTORY/target/universal/release/$INPUT_FILE.a" "$OUTPUT_LOCATION/ios/universal-sim/$OUTPUT_FILE.a"
;;
MACOS)
# Create the root directory for the macos release binaries
Expand Down
Loading