Skip to content

Commit

Permalink
split RingMLSAG out of transaction core (mobilecoinfoundation#2026)
Browse files Browse the repository at this point in the history
* WIP split RingMLSAG out of transaction core

* Update crypto/ring-signature/src/domain_separators.rs

Co-authored-by: Remoun Metyas <[email protected]>

* Update crypto/ring-signature/signer/src/no_keys_ring_signer.rs

Co-authored-by: Remoun Metyas <[email protected]>

* Update crypto/ring-signature/signer/Cargo.toml

Co-authored-by: Remoun Metyas <[email protected]>

* Update crypto/ring-signature/Cargo.toml

Co-authored-by: Remoun Metyas <[email protected]>

* Update crypto/ring-signature/src/amount/commitment.rs

Co-authored-by: Remoun Metyas <[email protected]>

* Update crypto/ring-signature/src/lib.rs

Co-authored-by: Remoun Metyas <[email protected]>

* Update transaction/core/src/proptest_fixtures.rs

Co-authored-by: Remoun Metyas <[email protected]>

* Update crypto/ring-signature/signer/src/traits.rs

Co-authored-by: Remoun Metyas <[email protected]>

* Update crypto/ring-signature/src/amount/commitment.rs

Co-authored-by: Remoun Metyas <[email protected]>

* rename MLSAGError to RingSignatureError everywhere

* remove unnecesary dependencies in ring-signature crate

* fix a remoun nit

* fix previous, move `Amount` and `TokenId` to `mc-transaction-types`

* fix tests

* Update transaction/core/tests/validation.rs

Co-authored-by: Remoun Metyas <[email protected]>

* Update transaction/core/src/signed_contingent_input.rs

Co-authored-by: Remoun Metyas <[email protected]>

* remove some undesired re-exports

* small reorg

* review comments, fixups

* fix missing README

* fix unused imports, fix review comments

* add missing README

* add more text to crypto-ring-signature readme

Co-authored-by: Remoun Metyas <[email protected]>
  • Loading branch information
cbeck88 and Remoun Metyas authored May 26, 2022
1 parent 7d91cac commit 5a0be43
Show file tree
Hide file tree
Showing 81 changed files with 1,187 additions and 582 deletions.
77 changes: 75 additions & 2 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ members = [
"crypto/multisig",
"crypto/noise",
"crypto/rand",
"crypto/ring-signature",
"crypto/ring-signature/signer",
"crypto/x509/test-vectors",
"crypto/x509/utils",
"enclave-boundary",
Expand Down Expand Up @@ -121,6 +123,7 @@ members = [
"transaction/core",
"transaction/core/test-utils",
"transaction/std",
"transaction/types",
"util/b58-decoder",
"util/build/enclave",
"util/build/grpc",
Expand Down
1 change: 1 addition & 0 deletions android-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mc-crypto-box = { path = "../crypto/box" }
mc-crypto-keys = { path = "../crypto/keys" }
mc-crypto-noise = { path = "../crypto/noise" }
mc-crypto-rand = { path = "../crypto/rand", features = ["std"] }
mc-crypto-ring-signature-signer = { path = "../crypto/ring-signature/signer", default-features = false }
mc-fog-report-types = { path = "../fog/report/types" }
mc-fog-report-validation = { path = "../fog/report/validation" }
mc-transaction-core = { path = "../transaction/core" }
Expand Down
3 changes: 1 addition & 2 deletions android-bindings/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use mc_common::ResponderId;
use mc_crypto_box::{CryptoBox, VersionedCryptoBox};
use mc_crypto_keys::{CompressedRistrettoPublic, RistrettoPrivate, RistrettoPublic, X25519};
use mc_crypto_rand::McRng;
use mc_crypto_ring_signature_signer::NoKeysRingSigner;
use mc_fog_kex_rng::{BufferedRng, KexRngPubkey, NewFromKex, StoredRng, VersionedKexRng};
use mc_fog_report_types::{Report, ReportResponse};
use mc_fog_report_validation::{FogReportResponses, FogResolver};
Expand All @@ -46,12 +47,10 @@ use mc_transaction_core::{
create_shared_secret, recover_onetime_private_key, recover_public_subaddress_spend_key,
},
ring_signature::KeyImage,
signer::NoKeysRingSigner,
tokens::Mob,
tx::{Tx, TxOut, TxOutConfirmationNumber, TxOutMembershipProof},
Amount, BlockVersion, CompressedCommitment, MaskedAmount, Token,
};

use mc_transaction_std::{
AuthenticatedSenderMemo, AuthenticatedSenderWithPaymentRequestIdMemo, DestinationMemo,
InputCredentials, MemoBuilder, MemoPayload, RTHMemoBuilder, ReservedSubaddresses,
Expand Down
1 change: 1 addition & 0 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mc-util-build-script = { path = "../util/build/script" }
cargo-emit = "0.2.1"

[dev-dependencies]
mc-crypto-ring-signature-signer = { path = "../crypto/ring-signature/signer" }
mc-crypto-x509-test-vectors = { path = "../crypto/x509/test-vectors" }
mc-fog-report-validation-test-utils = { path = "../fog/report/validation/test-utils" }
mc-test-vectors-b58-encodings = { path = "../test-vectors/b58-encodings" }
Expand Down
5 changes: 3 additions & 2 deletions api/src/convert/signature_rct_bulletproofs.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation

//! Convert to/from external::SignatureRctBulletproofs
use crate::{convert::ConversionError, external};
use mc_transaction_core::{
ring_signature::{RingMLSAG, SignatureRctBulletproofs},
CompressedCommitment,
ring_ct::SignatureRctBulletproofs, ring_signature::RingMLSAG, CompressedCommitment,
};
use protobuf::RepeatedField;
use std::convert::TryFrom;
Expand Down
8 changes: 5 additions & 3 deletions api/src/convert/tx.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation

//! Convert to/from external::Tx.
use crate::{convert::ConversionError, external};
use mc_transaction_core::{ring_signature::SignatureRctBulletproofs, tx};
use mc_transaction_core::{ring_ct::SignatureRctBulletproofs, tx};
use std::convert::TryFrom;

/// Convert mc_transaction_core::tx::Tx --> external::Tx.
Expand Down Expand Up @@ -29,10 +31,10 @@ impl TryFrom<&external::Tx> for tx::Tx {
mod tests {
use super::*;
use mc_account_keys::AccountKey;
use mc_crypto_ring_signature_signer::NoKeysRingSigner;
use mc_fog_report_validation_test_utils::MockFogResolver;
use mc_transaction_core::{
constants::MILLIMOB_TO_PICOMOB, signer::NoKeysRingSigner, tokens::Mob, tx::Tx, Amount,
BlockVersion, Token, TokenId,
constants::MILLIMOB_TO_PICOMOB, tokens::Mob, tx::Tx, Amount, BlockVersion, Token, TokenId,
};
use mc_transaction_std::{
test_utils::get_input_credentials, EmptyMemoBuilder, ReservedSubaddresses,
Expand Down
5 changes: 4 additions & 1 deletion api/tests/prost.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Copyright (c) 2018-2022 The MobileCoin Foundation

//! Tests that prost-versions of structures round-trip with the versions
//! generated from external.proto
use maplit::btreemap;
use mc_account_keys::{AccountKey, PublicAddress, RootIdentity};
use mc_api::external;
use mc_crypto_ring_signature_signer::NoKeysRingSigner;
use mc_fog_report_validation_test_utils::{FullyValidatedFogPubkey, MockFogResolver};
use mc_transaction_core::{signer::NoKeysRingSigner, Amount, BlockVersion, SignedContingentInput};
use mc_transaction_core::{Amount, BlockVersion, SignedContingentInput};
use mc_transaction_std::{
test_utils::get_input_credentials, EmptyMemoBuilder, ReservedSubaddresses,
SignedContingentInputBuilder,
Expand Down
4 changes: 2 additions & 2 deletions consensus/api/src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
};
use mc_api::ConversionError;
use mc_transaction_core::{
mint::MintValidationError, ring_signature, ring_signature::MLSAGError,
mint::MintValidationError, ring_ct, ring_signature::Error as RingSignatureError,
validation::TransactionValidationError as Error, BlockVersion, InputRuleError, TokenId,
};
use std::convert::{From, TryFrom, TryInto};
Expand Down Expand Up @@ -84,7 +84,7 @@ impl TryInto<Error> for ProposeTxResult {
Self::InsufficientInputSignatures => Ok(Error::InsufficientInputSignatures),
Self::InvalidInputSignature => Ok(Error::InvalidInputSignature),
Self::InvalidTransactionSignature => Ok(Error::InvalidTransactionSignature(
ring_signature::Error::MLSAG(MLSAGError::InvalidSignature),
ring_ct::Error::RingSignature(RingSignatureError::InvalidSignature),
)),
Self::InvalidRangeProof => Ok(Error::InvalidRangeProof),
Self::InsufficientRingSize => Ok(Error::InsufficientRingSize),
Expand Down
55 changes: 55 additions & 0 deletions consensus/enclave/trusted/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 consensus/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ mc-sgx-build = { path = "../../sgx/build" }
mc-account-keys = { path = "../../account-keys" }
mc-common = { path = "../../common", features = ["loggers"] }
mc-consensus-enclave-mock = { path = "../../consensus/enclave/mock" }
mc-crypto-ring-signature-signer = { path = "../../crypto/ring-signature/signer" }
mc-ledger-db = { path = "../../ledger/db", features = ["test_utils"] }
mc-peers-test-utils = { path = "../../peers/test-utils" }
mc-transaction-core-test-utils = { path = "../../transaction/core/test-utils" }
Expand Down
2 changes: 1 addition & 1 deletion consensus/service/src/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,10 @@ mod is_valid_tests {
mod combine_tests {
use super::*;
use mc_crypto_keys::{RistrettoPrivate, RistrettoPublic};
use mc_crypto_ring_signature_signer::NoKeysRingSigner;
use mc_ledger_db::test_utils::get_mock_ledger;
use mc_transaction_core::{
onetime_keys::recover_onetime_private_key,
signer::NoKeysRingSigner,
tokens::Mob,
tx::{TxOut, TxOutMembershipProof},
Amount, BlockVersion, Token,
Expand Down
Loading

0 comments on commit 5a0be43

Please sign in to comment.