diff --git a/container/Dockerfile-wallet_mobile-lib_android b/container/Dockerfile-wallet_mobile-lib_android index e7fa4466e..0b926d0d8 100644 --- a/container/Dockerfile-wallet_mobile-lib_android +++ b/container/Dockerfile-wallet_mobile-lib_android @@ -3,9 +3,9 @@ FROM rust:1.66.0-slim RUN apt update -y && apt upgrade -y && apt install -y unzip wget make pkg-config RUN wget -nc -P /opt/ https://www.openssl.org/source/openssl-1.1.1s.tar.gz RUN wget -nc -P /opt/ https://dl.google.com/android/repository/android-ndk-r25c-linux.zip && unzip /opt/android-ndk-r25c-linux.zip -d /opt/ -ENV PATH="/opt/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATHTMP" ENV PATHTMP="$PATH" +ENV PATH="/opt/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATHTMP" ENV WORK_DIR /platform ENV ANDROID_NDK_HOME /opt/android-ndk-r25c/ diff --git a/src/components/abciapp/Cargo.toml b/src/components/abciapp/Cargo.toml index 30a63c8f2..b5a7f3e1b 100644 --- a/src/components/abciapp/Cargo.toml +++ b/src/components/abciapp/Cargo.toml @@ -41,16 +41,14 @@ percent-encoding = "2.1.0" nix = "0.22.1" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } ruc = { version = "1.0.5", default-features = false, features = ["compact"] } abci = { git = "https://github.com/FindoraNetwork/tendermint-abci", tag = "0.7.6" } config = { path = "../config"} ledger = { path = "../../ledger" } -zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "main" } +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } -globutils = { git = "https://github.com/shaorongqiang/platform-lib-utils", branch = "main" } -cryptohash = { git = "https://github.com/shaorongqiang/platform-lib-cryptohash", branch = "main" } +globutils = { git = "https://github.com/FindoraNetwork/platform-lib-utils", branch = "develop" } +cryptohash = { git = "https://github.com/FindoraNetwork/platform-lib-cryptohash", branch = "develop" } finutils = { path = "../finutils" } diff --git a/src/components/abciapp/src/abci/server/callback/utils.rs b/src/components/abciapp/src/abci/server/callback/utils.rs index 513b10dd5..7f3e11946 100644 --- a/src/components/abciapp/src/abci/server/callback/utils.rs +++ b/src/components/abciapp/src/abci/server/callback/utils.rs @@ -3,10 +3,10 @@ use { abci::{Event, Pair}, ledger::data_model::{Operation, Transaction, TxnSID}, - noah::xfr::structs::{XfrAmount, XfrAssetType}, protobuf::RepeatedField, serde::Serialize, std::time::SystemTime, + zei::noah_api::xfr::structs::{XfrAmount, XfrAssetType}, }; /// generate attr(tags) for index-ops of tendermint diff --git a/src/components/abciapp/src/abci/staking/test.rs b/src/components/abciapp/src/abci/staking/test.rs index ad4742e3d..9d4f4f917 100644 --- a/src/components/abciapp/src/abci/staking/test.rs +++ b/src/components/abciapp/src/abci/staking/test.rs @@ -11,14 +11,14 @@ use { store::LedgerState, utils::fra_gen_initial_tx, }, - noah::xfr::{ - asset_record::{open_blind_asset_record, AssetRecordType}, - structs::{AssetRecordTemplate, XfrAmount}, - }, rand::random, rand_chacha::ChaChaRng, rand_core::SeedableRng, ruc::*, + zei::noah_api::xfr::{ + asset_record::{open_blind_asset_record, AssetRecordType}, + structs::{AssetRecordTemplate, XfrAmount}, + }, zei::{XfrKeyPair, XfrPublicKey}, }; diff --git a/src/components/abciapp/src/api/query_server/query_api/mod.rs b/src/components/abciapp/src/api/query_server/query_api/mod.rs index a3c2d4af5..0527b0de0 100644 --- a/src/components/abciapp/src/api/query_server/query_api/mod.rs +++ b/src/components/abciapp/src/api/query_server/query_api/mod.rs @@ -24,8 +24,6 @@ use { }, }, ledger_api::*, - noah::anon_xfr::structs::{AxfrOwnerMemo, Commitment, MTLeafInfo}, - noah_algebra::serialization::NoahFromToBytes, parking_lot::RwLock, ruc::*, serde::{Deserialize, Serialize}, @@ -35,6 +33,8 @@ use { sync::Arc, }, tracing::info, + zei::noah_algebra::serialization::NoahFromToBytes, + zei::noah_api::anon_xfr::structs::{AxfrOwnerMemo, Commitment, MTLeafInfo}, zei::{OwnerMemo, XfrPublicKey}, }; diff --git a/src/components/abciapp/src/api/query_server/query_api/server.rs b/src/components/abciapp/src/api/query_server/query_api/server.rs index 8a4d3da2b..8b7c181f3 100644 --- a/src/components/abciapp/src/api/query_server/query_api/server.rs +++ b/src/components/abciapp/src/api/query_server/query_api/server.rs @@ -13,10 +13,10 @@ use { staking::{ops::mint_fra::MintEntry, BlockHeight}, store::LedgerState, }, - noah::anon_xfr::structs::{AxfrOwnerMemo, Commitment, MTLeafInfo}, parking_lot::{Condvar, Mutex, RwLock}, ruc::*, std::{collections::HashSet, sync::Arc}, + zei::noah_api::anon_xfr::structs::{AxfrOwnerMemo, Commitment, MTLeafInfo}, zei::OwnerMemo, }; diff --git a/src/components/config/Cargo.toml b/src/components/config/Cargo.toml index 7292a456b..fc41b5e6b 100644 --- a/src/components/config/Cargo.toml +++ b/src/components/config/Cargo.toml @@ -16,7 +16,7 @@ serde_json = "1.0" serde-strz = "1.1.1" toml = "0.5.8" -globutils = { git = "https://github.com/shaorongqiang/platform-lib-utils", branch = "main" } +globutils = { git = "https://github.com/FindoraNetwork/platform-lib-utils", branch = "develop" } [target.'cfg(target_os= "linux")'.dependencies] btm = "0.1.6" diff --git a/src/components/contracts/modules/account/Cargo.toml b/src/components/contracts/modules/account/Cargo.toml index 0335e633b..b636a0939 100644 --- a/src/components/contracts/modules/account/Cargo.toml +++ b/src/components/contracts/modules/account/Cargo.toml @@ -24,11 +24,10 @@ fp-traits = { path = "../../primitives/traits" } fp-types = { path = "../../primitives/types" } enterprise-web3 = { path = "../../primitives/enterprise-web3" } config = { path = "../../../config"} -zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "main" } +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } [dev-dependencies] rand_chacha = "0.3" parking_lot = "0.12" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } diff --git a/src/components/contracts/modules/evm/Cargo.toml b/src/components/contracts/modules/evm/Cargo.toml index e84a53b75..c56bc3b83 100644 --- a/src/components/contracts/modules/evm/Cargo.toml +++ b/src/components/contracts/modules/evm/Cargo.toml @@ -24,8 +24,6 @@ serde_json = "1.0.64" sha3 = { version = "0.10", default-features = false } hex = "0.4.2" ethabi = "17.1.0" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } # primitives, don't depend on any modules fp-core = { path = "../../primitives/core" } @@ -39,7 +37,7 @@ storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4 fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4" } ledger = { path = "../../../../ledger" } enterprise-web3 = { path = "../../primitives/enterprise-web3" } -zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "main" } +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } [dev-dependencies] baseapp = { path = "../../baseapp" } diff --git a/src/components/contracts/modules/evm/src/lib.rs b/src/components/contracts/modules/evm/src/lib.rs index 281d81704..d49da4e9c 100644 --- a/src/components/contracts/modules/evm/src/lib.rs +++ b/src/components/contracts/modules/evm/src/lib.rs @@ -36,13 +36,13 @@ use fp_types::{ actions::evm::Action, crypto::{Address, HA160}, }; -use noah_algebra::serialization::NoahFromToBytes; use precompile::PrecompileSet; use ruc::*; use runtime::runner::ActionRunner; use std::marker::PhantomData; use std::str::FromStr; use system_contracts::{SystemContracts, SYSTEM_ADDR}; +use zei::noah_algebra::serialization::NoahFromToBytes; use zei::XfrPublicKey; pub use runtime::*; diff --git a/src/components/contracts/modules/evm/src/utils.rs b/src/components/contracts/modules/evm/src/utils.rs index e66806546..5ff18b003 100644 --- a/src/components/contracts/modules/evm/src/utils.rs +++ b/src/components/contracts/modules/evm/src/utils.rs @@ -2,10 +2,10 @@ use ethabi::{Event, EventParam, ParamType, RawLog}; use fp_traits::evm::{DecimalsMapping, EthereumDecimalsMapping}; use fp_types::actions::xhub::NonConfidentialOutput; use ledger::data_model::ASSET_TYPE_FRA; -use noah::xfr::structs::AssetType; -use noah::xfr::structs::ASSET_TYPE_LENGTH; -use noah_algebra::serialization::NoahFromToBytes; use ruc::*; +use zei::noah_algebra::serialization::NoahFromToBytes; +use zei::noah_api::xfr::structs::AssetType; +use zei::noah_api::xfr::structs::ASSET_TYPE_LENGTH; use zei::XfrPublicKey; pub fn deposit_asset_event() -> Event { diff --git a/src/components/contracts/primitives/mocks/Cargo.toml b/src/components/contracts/primitives/mocks/Cargo.toml index 193ab5122..681dc54b4 100644 --- a/src/components/contracts/primitives/mocks/Cargo.toml +++ b/src/components/contracts/primitives/mocks/Cargo.toml @@ -18,8 +18,7 @@ rand_chacha = "0.3" rlp = "0.5" serde_json = "1.0" sha3 = "0.10" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "main" } +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } # primitives fp-traits = { path = "../traits" } diff --git a/src/components/contracts/primitives/types/Cargo.toml b/src/components/contracts/primitives/types/Cargo.toml index faf33bf29..53b24da47 100644 --- a/src/components/contracts/primitives/types/Cargo.toml +++ b/src/components/contracts/primitives/types/Cargo.toml @@ -13,7 +13,7 @@ bech32 = "0.7.2" ethereum = { version = "0.12.0", default-features = false, features = ["with-serde"] } fixed-hash = "0.8.0" hex = "0.4.2" -globutils = { git = "https://github.com/shaorongqiang/platform-lib-utils", branch = "main" } +globutils = { git = "https://github.com/FindoraNetwork/platform-lib-utils", branch = "develop" } libsecp256k1 = { version = "0.7", features = ["static-context", "hmac"] } primitive-types = { version = "0.11.1", default-features = false, features = ["rlp", "byteorder", "serde"] } ruc = "1.0" @@ -21,9 +21,7 @@ serde = { version = "1.0.124", features = ["derive"] } serde_json = "1.0" serde-big-array = "0.4" sha3 = "0.10" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "main" } +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } # primitives fp-utils = { path = "../utils" } diff --git a/src/components/contracts/primitives/types/src/actions/account.rs b/src/components/contracts/primitives/types/src/actions/account.rs index de0878271..eb504308f 100644 --- a/src/components/contracts/primitives/types/src/actions/account.rs +++ b/src/components/contracts/primitives/types/src/actions/account.rs @@ -1,4 +1,4 @@ -use noah::xfr::structs::AssetType; +use zei::noah_api::xfr::structs::AssetType; use serde::{Deserialize, Serialize}; use zei::XfrPublicKey; diff --git a/src/components/contracts/primitives/types/src/actions/xhub.rs b/src/components/contracts/primitives/types/src/actions/xhub.rs index 0d0903958..2d97b6b49 100644 --- a/src/components/contracts/primitives/types/src/actions/xhub.rs +++ b/src/components/contracts/primitives/types/src/actions/xhub.rs @@ -1,5 +1,5 @@ -use noah::xfr::structs::AssetType; use serde::{Deserialize, Serialize}; +use zei::noah_api::xfr::structs::AssetType; use zei::XfrPublicKey; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] diff --git a/src/components/contracts/primitives/types/src/crypto.rs b/src/components/contracts/primitives/types/src/crypto.rs index a9ec82fc7..0940e2bac 100644 --- a/src/components/contracts/primitives/types/src/crypto.rs +++ b/src/components/contracts/primitives/types/src/crypto.rs @@ -6,12 +6,12 @@ use { fp_utils::{ecdsa, hashing::keccak_256}, globutils::wallet, hex::FromHex, - noah_algebra::serialization::NoahFromToBytes, primitive_types::{H160, H256}, ruc::{d, eg, RucResult}, serde::{Deserialize, Serialize}, sha3::{Digest, Keccak256}, std::ops::{Deref, DerefMut}, + zei::noah_algebra::serialization::NoahFromToBytes, zei::{XfrPublicKey, XfrSignature}, }; diff --git a/src/components/finutils/Cargo.toml b/src/components/finutils/Cargo.toml index c23bc19aa..4a0d76116 100644 --- a/src/components/finutils/Cargo.toml +++ b/src/components/finutils/Cargo.toml @@ -26,18 +26,15 @@ parking_lot = "0.12" getrandom = "0.2" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "main" } +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } ruc = "1.0" rucv3 = { package = "ruc", version = "3.0" } nix = "0.25" ledger = { path = "../../ledger", default-features = false } -globutils = { git = "https://github.com/shaorongqiang/platform-lib-utils", branch = "main" } -credentials = { git = "https://github.com/shaorongqiang/platform-lib-credentials", branch = "main" } +globutils = { git = "https://github.com/FindoraNetwork/platform-lib-utils", branch = "develop" } +credentials = { git = "https://github.com/FindoraNetwork/platform-lib-credentials", branch = "develop" } eth_checksum = { version = "0.1.2", optional = true } fp-core = { path = "../contracts/primitives/core", default-features = false } diff --git a/src/components/finutils/src/bins/fn.rs b/src/components/finutils/src/bins/fn.rs index 6bd57cf62..c99499d97 100644 --- a/src/components/finutils/src/bins/fn.rs +++ b/src/components/finutils/src/bins/fn.rs @@ -34,9 +34,9 @@ use { data_model::{AssetTypeCode, ASSET_TYPE_FRA, FRA_DECIMALS}, staking::{StakerMemo, VALIDATORS_MIN}, }, - noah::anon_xfr::structs::OpenAnonAssetRecordBuilder, ruc::*, std::{fmt, fs}, + zei::noah_api::anon_xfr::structs::OpenAnonAssetRecordBuilder, zei::XfrSecretKey, }; diff --git a/src/components/finutils/src/bins/stt/stt.rs b/src/components/finutils/src/bins/stt/stt.rs index f0665ccbd..de4317630 100644 --- a/src/components/finutils/src/bins/stt/stt.rs +++ b/src/components/finutils/src/bins/stt/stt.rs @@ -208,13 +208,13 @@ mod issue { }, staking::FRA_PRE_ISSUE_AMOUNT, }, - noah::xfr::{ + rand_chacha::rand_core::SeedableRng, + rand_chacha::ChaChaRng, + zei::noah_algebra::ristretto::PedersenCommitmentRistretto, + zei::noah_api::xfr::{ asset_record::{build_blind_asset_record, AssetRecordType}, structs::AssetRecordTemplate, }, - noah_algebra::ristretto::PedersenCommitmentRistretto, - rand_chacha::rand_core::SeedableRng, - rand_chacha::ChaChaRng, }; pub fn issue() -> Result<()> { @@ -271,7 +271,7 @@ mod issue { } mod delegate { - use {super::*, noah::xfr::asset_record::AssetRecordType}; + use {super::*, zei::noah_api::xfr::asset_record::AssetRecordType}; pub fn gen_tx( user: NameRef, diff --git a/src/components/finutils/src/common/ddev/init.rs b/src/components/finutils/src/common/ddev/init.rs index b8986fa40..a12571c5d 100644 --- a/src/components/finutils/src/common/ddev/init.rs +++ b/src/components/finutils/src/common/ddev/init.rs @@ -15,9 +15,9 @@ use ledger::{ staking::{td_addr_to_bytes, Validator as StakingValidator, ValidatorKind, FRA}, utils::fra_gen_initial_tx, }; -use noah::xfr::asset_record::AssetRecordType; use ruc::*; use serde::{Deserialize, Serialize}; +use zei::noah_api::xfr::asset_record::AssetRecordType; use zei::{XfrKeyPair, XfrPublicKey, XfrSecretKey}; #[derive(Deserialize)] diff --git a/src/components/finutils/src/common/evm.rs b/src/components/finutils/src/common/evm.rs index 1b47a93a3..a3cd0430d 100644 --- a/src/components/finutils/src/common/evm.rs +++ b/src/components/finutils/src/common/evm.rs @@ -23,13 +23,13 @@ use fp_utils::tx::EvmRawTxWrapper; use ledger::data_model::AssetTypeCode; use ledger::data_model::ASSET_TYPE_FRA; use ledger::data_model::BLACK_HOLE_PUBKEY_STAKING; -use noah::xfr::asset_record::AssetRecordType; use ruc::*; use std::str::FromStr; use tendermint::block::Height; use tendermint_rpc::endpoint::abci_query::AbciQuery; use tendermint_rpc::{Client, HttpClient}; use tokio::runtime::Runtime; +use zei::noah_api::xfr::asset_record::AssetRecordType; use zei::XfrKeyPair; use zei::XfrPublicKey; diff --git a/src/components/finutils/src/common/mod.rs b/src/components/finutils/src/common/mod.rs index 758e64b71..b74088525 100644 --- a/src/components/finutils/src/common/mod.rs +++ b/src/components/finutils/src/common/mod.rs @@ -35,7 +35,16 @@ use { TendermintAddrRef, }, }, - noah::{ + rand_chacha::ChaChaRng, + rand_core::SeedableRng, + ruc::*, + std::{env, fs}, + tendermint::PrivateKey, + utils::{ + get_block_height, get_local_block_height, get_validator_detail, + parse_td_validator_keys, + }, + zei::noah_api::{ anon_xfr::{ nullify, structs::{ @@ -50,15 +59,6 @@ use { structs::{XfrAmount, XfrAssetType}, }, }, - rand_chacha::ChaChaRng, - rand_core::SeedableRng, - ruc::*, - std::{env, fs}, - tendermint::PrivateKey, - utils::{ - get_block_height, get_local_block_height, get_validator_detail, - parse_td_validator_keys, - }, zei::{XfrKeyPair, XfrPublicKey, XfrSecretKey}, }; diff --git a/src/components/finutils/src/common/utils.rs b/src/components/finutils/src/common/utils.rs index 86bb2e2ac..8efed8cf6 100644 --- a/src/components/finutils/src/common/utils.rs +++ b/src/components/finutils/src/common/utils.rs @@ -19,7 +19,12 @@ use { }, staking::{init::get_inital_validators, TendermintAddrRef, FRA_TOTAL_AMOUNT}, }, - noah::{ + ruc::*, + serde::{self, Deserialize, Serialize}, + sha2::Digest, + std::collections::HashMap, + tendermint::{PrivateKey, PublicKey}, + zei::noah_api::{ anon_xfr::structs::{ AnonAssetRecord, AxfrOwnerMemo, Commitment, MTLeafInfo, OpenAnonAssetRecord, }, @@ -28,11 +33,6 @@ use { structs::{AssetRecordTemplate, OpenAssetRecord, OwnerMemo}, }, }, - ruc::*, - serde::{self, Deserialize, Serialize}, - sha2::Digest, - std::collections::HashMap, - tendermint::{PrivateKey, PublicKey}, zei::{BlindAssetRecord, XfrKeyPair, XfrPublicKey}, }; @@ -584,7 +584,11 @@ pub fn get_asset_all(kp: &XfrKeyPair) -> Result> { let mut set = BTreeMap::new(); for (_k, v) in info { - let res = open_blind_asset_record(&v.0 .0.record, &v.1, kp)?; + let res = open_blind_asset_record( + &v.0 .0.record.into_noah()?, + &v.1, + &kp.into_noah()?, + )?; let code = AssetTypeCode { val: res.asset_type, @@ -601,7 +605,7 @@ pub fn get_asset_all(kp: &XfrKeyPair) -> Result> { } #[allow(missing_docs)] -fn get_owned_utxos( +pub fn get_owned_utxos( addr: &XfrPublicKey, ) -> Result)>> { get_owned_utxos_x(None, addr).c(d!()) diff --git a/src/components/finutils/src/txn_builder/mod.rs b/src/components/finutils/src/txn_builder/mod.rs index 3acb39049..1e91c16e5 100644 --- a/src/components/finutils/src/txn_builder/mod.rs +++ b/src/components/finutils/src/txn_builder/mod.rs @@ -7,7 +7,6 @@ use { credentials::CredUserSecretKey, - curve25519_dalek::scalar::Scalar, digest::Digest, fp_types::crypto::MultiSigner, globutils::{wallet, Serialized, SignatureOf}, @@ -38,11 +37,19 @@ use { TendermintAddr, Validator, }, }, - noah::{ - anon_creds::{ - ac_confidential_open_commitment, ACCommitment, ACCommitmentKey, - ConfidentialAC, Credential, - }, + rand_chacha::ChaChaRng, + rand_core::SeedableRng, + serde::{Deserialize, Serialize}, + sha2::Sha512, + std::{ + cmp::Ordering, + collections::{BTreeMap, HashMap, HashSet}, + }, + tendermint::PrivateKey, + zei::noah_algebra::prelude::*, + zei::noah_algebra::ristretto::PedersenCommitmentRistretto, + zei::noah_api::{ + anon_creds::{ACCommitment, ACCommitmentKey, Credential}, anon_xfr::{ abar_to_abar::{finish_anon_xfr_note, init_anon_xfr_note, AXfrPreNote}, abar_to_ar::{ @@ -59,8 +66,7 @@ use { setup::ProverParams, xfr::{ asset_record::{ - build_blind_asset_record, build_open_asset_record, - open_blind_asset_record, AssetRecordType, + build_blind_asset_record, open_blind_asset_record, AssetRecordType, }, structs::{ AssetRecord, AssetRecordTemplate, AssetType, OpenAssetRecord, @@ -69,17 +75,6 @@ use { XfrNotePolicies, }, }, - noah_algebra::prelude::*, - noah_algebra::ristretto::PedersenCommitmentRistretto, - rand_chacha::ChaChaRng, - rand_core::{CryptoRng, RngCore, SeedableRng}, - serde::{Deserialize, Serialize}, - sha2::Sha512, - std::{ - cmp::Ordering, - collections::{BTreeMap, HashMap, HashSet}, - }, - tendermint::PrivateKey, zei::{BlindAssetRecord, OwnerMemo, XfrKeyPair, XfrPublicKey}, }; @@ -1065,79 +1060,6 @@ impl TransactionBuilder { } } -/// Generates an asset record from an asset record template using optional identity proof. -/// Returns the asset record, amount blinds, and type blind. -pub(crate) fn build_record_and_get_blinds( - prng: &mut R, - template: &AssetRecordTemplate, - identity_proof: Option, -) -> Result<(AssetRecord, (Scalar, Scalar), Scalar)> { - // Check input consistency: - // - if no policy, then no identity proof needed - // - if policy and identity tracing, then identity proof is needed - // - if policy but no identity tracing, then no identity proof is needed - let asset_tracing = !template.asset_tracing_policies.is_empty(); - if !asset_tracing && identity_proof.is_some() - || asset_tracing - && (template - .asset_tracing_policies - .get_policy(0) - .as_ref() - .c(d!())? - .identity_tracing - .is_some() - && identity_proof.is_none() - || template - .asset_tracing_policies - .get_policy(0) - .as_ref() - .unwrap() - .identity_tracing - .is_none() - && identity_proof.is_some()) - { - return Err(eg!()); - } - // 1. get ciphertext and proofs from identity proof structure - let (attr_ctext, reveal_proof) = match identity_proof { - None => (None, None), - Some(conf_ac) => { - let (c, p) = conf_ac.get_fields(); - (Some(c.into_iter().map(|i| (0u32, i)).collect()), Some(p)) - } - }; - // 2. Use record template and ciphertexts to build open asset record - let pc_gens = PedersenCommitmentRistretto::default(); - let (open_asset_record, asset_tracing_memos, owner_memo) = build_open_asset_record( - prng, - &pc_gens, - template, - vec![attr_ctext.unwrap_or_default()], - ); - // 3. Return record input containing open asset record, tracing policy, identity reveal proof, - // asset_tracer_memo, and owner_memo - - let mut identity_proofs = vec![]; - if reveal_proof.is_some() { - identity_proofs.push(reveal_proof); - } - - Ok(( - AssetRecord { - open_asset_record: open_asset_record.clone(), - tracing_policies: template.asset_tracing_policies.clone(), - identity_proofs, - owner_memo, - asset_tracers_memos: asset_tracing_memos, - }, - ( - open_asset_record.amount_blinds.0 .0, - open_asset_record.amount_blinds.1 .0, - ), - open_asset_record.type_blind.0, - )) -} - fn gen_bar_conv_note( seed: [u8; 32], input_record: &OpenAssetRecord, @@ -1281,76 +1203,7 @@ impl TransferOperationBuilder { Ok(self) } - /// Adds output to the records, and stores the asset amount blinds and type blind in the blinds parameter passed in. - pub fn add_output_and_store_blinds( - &mut self, - asset_record_template: &AssetRecordTemplate, - credential_record: Option<(&CredUserSecretKey, &Credential, &ACCommitmentKey)>, - prng: &mut R, - blinds: &mut ((Scalar, Scalar), Scalar), - ) -> Result<&mut Self> { - if self.transfer.is_some() { - return Err(eg!( - ("Cannot mutate a transfer that has been signed".to_string()) - )); - } - let (ar, amount_blinds, type_blind) = - if let Some((user_secret_key, credential, commitment_key)) = - credential_record - { - match asset_record_template.asset_tracing_policies.get_policy(0) { - None => { - // identity tracing must have asset_tracing policy - return Err(eg!()); - } - Some(policy) => { - match &policy.identity_tracing { - // policy must have a identity tracing policy - None => { - return Err(eg!()); - } - Some(reveal_policy) => { - let conf_ac = ac_confidential_open_commitment( - prng, - user_secret_key.get_ref(), - credential, - commitment_key, - &policy.enc_keys.attrs_enc_key, - &reveal_policy.reveal_map, - &[], - ) - .c(d!())?; - build_record_and_get_blinds( - prng, - &asset_record_template, - Some(conf_ac), - ) - .c(d!())? - } - } - } - } - } else { - if let Some(policy) = - asset_record_template.asset_tracing_policies.get_policy(0) - { - if policy.identity_tracing.is_some() { - return Err(eg!()); - } - } - build_record_and_get_blinds(prng, &asset_record_template, None)? - }; - blinds.0 = amount_blinds; - blinds.1 = type_blind; - self.output_records.push(ar); - self.outputs_tracing_policies - .push(asset_record_template.asset_tracing_policies.clone()); - self.output_identity_commitments.push(None); - Ok(self) - } - // Check if outputs and inputs are balanced - fn check_balance(&self) -> Result<()> { let input_total: u64 = self .input_records @@ -1970,7 +1823,10 @@ mod tests { store::LedgerState, utils::fra_gen_initial_tx, }, - noah::{ + rand_chacha::ChaChaRng, + rand_core::SeedableRng, + zei::noah_algebra::ristretto::PedersenCommitmentRistretto, + zei::noah_api::{ anon_xfr::structs::{AnonAssetRecord, OpenAnonAssetRecordBuilder}, xfr::{ asset_record::{ @@ -1980,9 +1836,6 @@ mod tests { structs::AssetType as AT, }, }, - noah_algebra::ristretto::PedersenCommitmentRistretto, - rand_chacha::ChaChaRng, - rand_core::SeedableRng, }; // Defines an asset type diff --git a/src/components/wallet_mobile/Cargo.toml b/src/components/wallet_mobile/Cargo.toml index faa437f48..b86060dc6 100644 --- a/src/components/wallet_mobile/Cargo.toml +++ b/src/components/wallet_mobile/Cargo.toml @@ -16,30 +16,30 @@ crate-type = ["cdylib", "staticlib", "rlib"] wasm-opt = false [dependencies] -aes-gcm = "0.9.0" +aes-gcm = '0.10.1' base64 = "0.13" bech32 = "0.7.2" ffi-support = "0.4" -futures = "0.3.16" +futures = "0.1.20" getrandom = { version = "0.2", features = ["js"] } -hex = "0.4.2" +hex = "0.4.3" js-sys = "0.3.27" -rand = { version = "0.7", features = ["wasm-bindgen"] } -rand_chacha = "0.2.0" -rand_core = { version = "0.5", default-features = false, features = ["alloc"] } +rand_chacha = "0.3" +rand_core = { version = "0.6", default-features = false, features = ["alloc"] } ring = "0.16.19" ruc = "1.0" serde = { version = "1.0.124", features = ["derive"] } -serde_derive = "1.0" +serde_derive = "^1.0.59" serde_json = "1.0" -zei = { git = "https://github.com/FindoraNetwork/zei", branch = "stable-main" } + +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } finutils = { path = "../finutils", default-features = false, features = []} fp-types = { path = "../contracts/primitives/types" } fp-utils = { path = "../contracts/primitives/utils" } -globutils = { git = "https://github.com/FindoraNetwork/platform-lib-utils", branch = "main" } -credentials = { git = "https://github.com/FindoraNetwork/platform-lib-credentials", branch = "main" } -cryptohash = { git = "https://github.com/FindoraNetwork/platform-lib-cryptohash", branch = "main" } +globutils = { git = "https://github.com/FindoraNetwork/platform-lib-utils", branch = "develop" } +credentials = { git = "https://github.com/FindoraNetwork/platform-lib-credentials", branch = "develop" } +cryptohash = { git = "https://github.com/FindoraNetwork/platform-lib-cryptohash", branch = "develop" } ledger = { path = "../../ledger" } @@ -66,5 +66,4 @@ safer-ffi = "0.0.10" [build-dependencies] cbindgen = "0.24" -vergen = "3.1.0" - +vergen = "3.1.0" \ No newline at end of file diff --git a/src/components/wallet_mobile/src/android/constructor.rs b/src/components/wallet_mobile/src/android/constructor.rs index 4303b99c2..6a0f4192c 100644 --- a/src/components/wallet_mobile/src/android/constructor.rs +++ b/src/components/wallet_mobile/src/android/constructor.rs @@ -4,8 +4,8 @@ use jni::sys::{jbyteArray, jlong}; use jni::JNIEnv; use rand_chacha::ChaChaRng; use rand_core::SeedableRng; -use zei::xfr::sig::XfrKeyPair as RawXfrKeyPair; -use zei::xfr::structs::ASSET_TYPE_LENGTH; +use zei::noah_api::keys::KeyPair as RawXfrKeyPair; +use zei::noah_api::xfr::structs::ASSET_TYPE_LENGTH; #[no_mangle] pub unsafe extern "system" fn Java_com_findora_JniApi_xfrKeyPairNew( @@ -17,7 +17,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_xfrKeyPairNew( let mut buf = [0u8; ASSET_TYPE_LENGTH]; buf.copy_from_slice(input.as_ref()); let mut prng = ChaChaRng::from_seed(buf); - let val = types::XfrKeyPair::from(RawXfrKeyPair::generate(&mut prng)); + let val = types::XfrKeyPair::from(RawXfrKeyPair::generate_ed25519(&mut prng)); Box::into_raw(Box::new(val)) as jlong } diff --git a/src/components/wallet_mobile/src/android/evm.rs b/src/components/wallet_mobile/src/android/evm.rs index 0271a4903..441b72651 100644 --- a/src/components/wallet_mobile/src/android/evm.rs +++ b/src/components/wallet_mobile/src/android/evm.rs @@ -1,10 +1,10 @@ +use super::{jStringToString, parseU64}; use crate::rust::account::{get_serialized_address, EVMTransactionBuilder}; use jni::objects::{JClass, JString}; use jni::sys::{jlong, jstring}; use jni::JNIEnv; -use zei::xfr::sig::XfrPublicKey; - -use super::{jStringToString, parseU64}; +use zei::noah_api::keys::PublicKey; +use zei::XfrPublicKey; #[no_mangle] /// # Safety @@ -27,10 +27,13 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferToUtxoFromAccount( let sk = jStringToString(env, sk); - let recipient = *(recipient as *mut XfrPublicKey); + let recipient = *(recipient as *mut PublicKey); let ser_tx = EVMTransactionBuilder::new_transfer_to_utxo_from_account( - recipient, amount, sk, nonce, + XfrPublicKey::from_noah(&recipient).unwrap(), + amount, + sk, + nonce, ) .unwrap(); diff --git a/src/components/wallet_mobile/src/android/mod.rs b/src/components/wallet_mobile/src/android/mod.rs index d395914ab..725b40e8a 100644 --- a/src/components/wallet_mobile/src/android/mod.rs +++ b/src/components/wallet_mobile/src/android/mod.rs @@ -9,7 +9,8 @@ use jni::objects::{JClass, JString}; use jni::sys::{jboolean, jbyteArray, jint, jlong, jstring}; use jni::JNIEnv; use ledger::data_model::AssetTypeCode; -use zei::xfr::structs::ASSET_TYPE_LENGTH; +use zei::noah_api::xfr::structs::ASSET_TYPE_LENGTH; +use zei::{XfrKeyPair, XfrPublicKey}; #[no_mangle] /// Returns the git commit hash and commit date of the commit this library was built against. @@ -147,7 +148,7 @@ pub extern "system" fn Java_com_findora_JniApi_keypairFromStr( .get_string(text) .expect("Couldn't get java string!") .into(); - let val = types::XfrKeyPair::from(keypair_from_str(text)); + let val = types::XfrKeyPair::from(keypair_from_str(text).into_noah().unwrap()); Box::into_raw(Box::new(val)) as jlong } @@ -161,7 +162,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_publicKeyToBech32( xfr_public_key_ptr: jlong, ) -> jstring { let key = &*(xfr_public_key_ptr as *mut types::XfrPublicKey); - let res = public_key_to_bech32(key); + let res = public_key_to_bech32(&XfrPublicKey::from_noah(key).unwrap()); let output = env.new_string(res).expect("Couldn't create java string!"); **output } @@ -176,7 +177,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_getPubKeyStr( xfr_keypair_ptr: jlong, ) -> jstring { let key = &*(xfr_keypair_ptr as *mut types::XfrKeyPair); - let pubkey = get_pub_key_str(key); + let pubkey = get_pub_key_str(&XfrKeyPair::from_noah(key).unwrap()); let output = env .new_string(pubkey) .expect("Couldn't create java string!"); @@ -193,7 +194,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_getPrivKeyStr( xfr_keypair_ptr: jlong, ) -> jstring { let key = &*(xfr_keypair_ptr as *mut types::XfrKeyPair); - let prikey = get_priv_key_str(key); + let prikey = get_priv_key_str(&XfrKeyPair::from_noah(key).unwrap()); let output = env .new_string(prikey) .expect("Couldn't create java string!"); @@ -215,7 +216,9 @@ pub extern "system" fn Java_com_findora_JniApi_restoreKeypairFromMnemonicDefault .expect("Couldn't get java string!") .into(); if let Ok(keypair) = rs_restore_keypair_from_mnemonic_default(phrase.as_str()) { - Box::into_raw(Box::new(types::XfrKeyPair::from(keypair))) as jlong + Box::into_raw(Box::new(types::XfrKeyPair::from( + keypair.into_noah().unwrap(), + ))) as jlong } else { ::std::ptr::null_mut::<()>() as jlong } @@ -232,7 +235,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_keypairToStr( xfr_keypair_ptr: jlong, ) -> jstring { let key = &*(xfr_keypair_ptr as *mut types::XfrKeyPair); - let res = keypair_to_str(key); + let res = keypair_to_str(&XfrKeyPair::from_noah(key).unwrap()); let output = env.new_string(res).expect("Couldn't create java string!"); **output } @@ -248,7 +251,9 @@ pub extern "system" fn Java_com_findora_JniApi_createKeypairFromSecret( .expect("Couldn't get java string!") .into(); if let Some(keypair) = create_keypair_from_secret(sk) { - Box::into_raw(Box::new(types::XfrKeyPair::from(keypair))) as jlong + Box::into_raw(Box::new(types::XfrKeyPair::from( + keypair.into_noah().unwrap(), + ))) as jlong } else { ::std::ptr::null_mut::<()>() as jlong } @@ -263,8 +268,8 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_getPkFromKeypair( xfr_keypair_ptr: jlong, ) -> jlong { let kp = &*(xfr_keypair_ptr as *mut types::XfrKeyPair); - let pk = get_pk_from_keypair(kp); - Box::into_raw(Box::new(types::XfrPublicKey::from(pk))) as jlong + let pk = get_pk_from_keypair(&XfrKeyPair::from_noah(kp).unwrap()); + Box::into_raw(Box::new(types::XfrPublicKey::from(pk.into_noah().unwrap()))) as jlong } #[no_mangle] @@ -274,7 +279,9 @@ pub extern "system" fn Java_com_findora_JniApi_newKeypair( _: JClass, ) -> jlong { let keypair = new_keypair(); - Box::into_raw(Box::new(types::XfrKeyPair::from(keypair))) as jlong + Box::into_raw(Box::new(types::XfrKeyPair::from( + keypair.into_noah().unwrap(), + ))) as jlong } #[no_mangle] @@ -335,7 +342,12 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_openClientAssetRecord( Some(memo.clone()) }; let keypair = &*(keypair_ptr as *mut types::XfrKeyPair); - let oar = rs_open_client_asset_record(record, owner_memo, keypair).unwrap(); + let oar = rs_open_client_asset_record( + record, + owner_memo, + &XfrKeyPair::from_noah(keypair).unwrap(), + ) + .unwrap(); Box::into_raw(Box::new(types::OpenAssetRecord::from(oar))) as jlong } diff --git a/src/components/wallet_mobile/src/android/transfer.rs b/src/components/wallet_mobile/src/android/transfer.rs index 05ddd9da9..3d07b26eb 100644 --- a/src/components/wallet_mobile/src/android/transfer.rs +++ b/src/components/wallet_mobile/src/android/transfer.rs @@ -1,12 +1,12 @@ +use super::{jStringToString, parseU64}; use crate::rust::*; use jni::objects::{JClass, JString}; use jni::sys::{jboolean, jint, jlong, jstring, jvalue, JNI_TRUE}; use jni::JNIEnv; use ledger::data_model::AssetType as PlatformAssetType; -use zei::xfr::sig::{XfrKeyPair, XfrPublicKey}; -use zei::xfr::structs::OwnerMemo as ZeiOwnerMemo; - -use super::{jStringToString, parseU64}; +use zei::noah_api::keys::{KeyPair, PublicKey}; +use zei::noah_api::xfr::structs::OwnerMemo as NoahOwnerMemo; +use zei::{XfrKeyPair, XfrPublicKey}; #[no_mangle] /// # Safety @@ -189,8 +189,8 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_ownerMemoFromJson( .expect("Couldn't get java string!") .into(); - let zei_owner_memo: ZeiOwnerMemo = serde_json::from_str(val.as_str()).unwrap(); - Box::into_raw(Box::new(OwnerMemo::from_json(zei_owner_memo).unwrap())) as jlong + let noah_owner_memo: NoahOwnerMemo = serde_json::from_str(val.as_str()).unwrap(); + Box::into_raw(Box::new(OwnerMemo::from_json(noah_owner_memo).unwrap())) as jlong } #[no_mangle] @@ -273,7 +273,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd Some(memo.clone()) }; let tracing_policies = &*(tracing_policies_ptr as *mut TracingPolicies); - let key = &*(key_ptr as *mut XfrKeyPair); + let key = &*(key_ptr as *mut KeyPair); let amount = parseU64(env, amount); let builder = builder @@ -283,7 +283,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd asset_record.clone(), owner_memo, tracing_policies, - key, + &XfrKeyPair::from_noah(key).unwrap(), amount, ) .unwrap(); @@ -328,12 +328,18 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd let memo = &*(owner_memo_ptr as *mut OwnerMemo); Some(memo.clone()) }; - let key = &*(key_ptr as *mut XfrKeyPair); + let key = &*(key_ptr as *mut KeyPair); let amount = parseU64(env, amount); let builder = builder .clone() - .add_input_no_tracing(txo_ref, asset_record, owner_memo, key, amount) + .add_input_no_tracing( + txo_ref, + asset_record, + owner_memo, + &XfrKeyPair::from_noah(key).unwrap(), + amount, + ) .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -369,7 +375,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd ) -> jlong { let builder = &*(builder as *mut TransferOperationBuilder); let tracing_policies = &*(tracing_policies_ptr as *mut TracingPolicies); - let recipient = &*(recipient as *mut XfrPublicKey); + let recipient = &*(recipient as *mut PublicKey); let amount = parseU64(env, amount); let code = jStringToString(env, code); @@ -377,7 +383,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd .clone() .add_output_with_tracing( amount, - recipient, + &XfrPublicKey::from_noah(recipient).unwrap(), tracing_policies, code, conf_amount == JNI_TRUE, @@ -413,7 +419,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd conf_type: jboolean, ) -> jlong { let builder = &*(builder as *mut TransferOperationBuilder); - let recipient = &*(recipient as *mut XfrPublicKey); + let recipient = &*(recipient as *mut PublicKey); let amount = parseU64(env, amount); let code = jStringToString(env, code); @@ -421,7 +427,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd .clone() .add_output_no_tracing( amount, - recipient, + &XfrPublicKey::from_noah(recipient).unwrap(), code, conf_amount == JNI_TRUE, conf_type == JNI_TRUE, @@ -459,7 +465,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd let policies = &*(tracing_policies_ptr as *mut TracingPolicies); Some(policies) }; - let key = &*(key_ptr as *mut XfrKeyPair); + let key = &*(key_ptr as *mut KeyPair); let builder = builder .clone() @@ -468,7 +474,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd asset_record, owner_memo, tracing_policies, - key, + &XfrKeyPair::from_noah(key).unwrap(), parseU64(env, amount), ) .unwrap(); @@ -496,7 +502,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd let policies = &*(tracing_policies_ptr as *mut TracingPolicies); Some(policies) }; - let recipient = &*(recipient as *mut XfrPublicKey); + let recipient = &*(recipient as *mut PublicKey); let code: String = env .get_string(code) .expect("Couldn't get java string!") @@ -506,7 +512,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderAd .clone() .add_output( parseU64(env, amount), - recipient, + &XfrPublicKey::from_noah(&recipient).unwrap(), tracing_policies, code, conf_amount == JNI_TRUE, @@ -562,9 +568,14 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transferOperationBuilderSi key_ptr: jlong, ) -> jlong { let builder = &*(builder as *mut TransferOperationBuilder); - let key = &*(key_ptr as *mut XfrKeyPair); + let key = &*(key_ptr as *mut KeyPair); - Box::into_raw(Box::new(builder.clone().sign(key).unwrap())) as jlong + Box::into_raw(Box::new( + builder + .clone() + .sign(&XfrKeyPair::from_noah(&key).unwrap()) + .unwrap(), + )) as jlong } #[no_mangle] diff --git a/src/components/wallet_mobile/src/android/tx_builder.rs b/src/components/wallet_mobile/src/android/tx_builder.rs index f59f1d78e..7d9016381 100644 --- a/src/components/wallet_mobile/src/android/tx_builder.rs +++ b/src/components/wallet_mobile/src/android/tx_builder.rs @@ -1,14 +1,14 @@ +use super::parseU64; use crate::rust::*; use jni::objects::{JClass, JString}; use jni::sys::{jboolean, jint, jlong, jstring, JNI_TRUE}; use jni::JNIEnv; -use zei::xfr::sig::XfrKeyPair; - -use super::parseU64; +use zei::noah_api::keys::KeyPair; +use zei::XfrKeyPair; #[no_mangle] /// # Safety -/// @param kp: owner's XfrKeyPair +/// @param kp: owner's KeyPair pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddFeeRelativeAuto( _env: JNIEnv, _: JClass, @@ -16,8 +16,11 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddFeeRe kp: jlong, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let kp = &*(kp as *mut XfrKeyPair); - let builder = builder.clone().add_fee_relative_auto(kp.clone()).unwrap(); + let kp = &*(kp as *mut KeyPair); + let builder = builder + .clone() + .add_fee_relative_auto(XfrKeyPair::from_noah(kp).unwrap()) + .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -92,7 +95,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderNew( /// console.log(err) /// } /// -/// @param {XfrKeyPair} key_pair - Issuer XfrKeyPair. +/// @param {KeyPair} key_pair - Issuer KeyPair. /// @param {string} memo - Text field for asset definition. /// @param {string} token_code - Optional Base64 string representing the token code of the asset to be issued. /// If empty, a token code will be chosen at random. @@ -108,7 +111,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera asset_rules: jlong, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let key_pair = &*(key_pair as *mut XfrKeyPair); + let key_pair = &*(key_pair as *mut KeyPair); let memo: String = env .get_string(memo) .expect("Couldn't get java string!") @@ -120,7 +123,12 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera let asset_rules = &*(asset_rules as *mut AssetRules); let builder = builder .clone() - .add_operation_create_asset(key_pair, memo, token_code, asset_rules.clone()) + .add_operation_create_asset( + &XfrKeyPair::from_noah(key_pair).unwrap(), + memo, + token_code, + asset_rules.clone(), + ) .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -131,13 +139,12 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera /// /// Use this function for simple one-shot issuances. /// -/// @param {XfrKeyPair} key_pair - Issuer XfrKeyPair. +/// @param {KeyPair} key_pair - Issuer KeyPair. /// and types of traced assets. /// @param {string} code - base64 string representing the token code of the asset to be issued. /// @param {BigInt} seq_num - Issuance sequence number. Every subsequent issuance of a given asset type must have a higher sequence number than before. /// @param {BigInt} amount - Amount to be issued. /// @param {boolean} conf_amount - `true` means the asset amount is confidential, and `false` means it's nonconfidential. -/// @param {PublicParams} zei_params - Public parameters necessary to generate asset records. pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddBasicIssueAsset( env: JNIEnv, _: JClass, @@ -147,24 +154,21 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddBasic seq_num: jlong, amount: JString, conf_amount: jboolean, - zei_params: jlong, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let key_pair = &*(key_pair as *mut XfrKeyPair); + let key_pair = &*(key_pair as *mut KeyPair); let code: String = env .get_string(code) .expect("Couldn't get java string!") .into(); - let zei_params = &*(zei_params as *mut PublicParams); let builder = builder .clone() .add_basic_issue_asset( - key_pair, + &XfrKeyPair::from_noah(key_pair).unwrap(), code, seq_num as u64, parseU64(env, amount), conf_amount == JNI_TRUE, - zei_params, ) .unwrap(); Box::into_raw(Box::new(builder)) as jlong @@ -174,7 +178,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddBasic /// # Safety /// Adds an operation to the transaction builder that adds a hash to the ledger's custom data /// store. -/// @param {XfrKeyPair} auth_key_pair - Asset creator key pair. +/// @param {KeyPair} auth_key_pair - Asset creator key pair. /// @param {String} code - base64 string representing token code of the asset whose memo will be updated. /// transaction validates. /// @param {String} new_memo - The new asset memo. @@ -189,7 +193,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera new_memo: JString, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let auth_key_pair = &*(auth_key_pair as *mut XfrKeyPair); + let auth_key_pair = &*(auth_key_pair as *mut KeyPair); let code: String = env .get_string(code) .expect("Couldn't get java string!") @@ -200,7 +204,11 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera .into(); let builder = builder .clone() - .add_operation_update_memo(auth_key_pair, code, new_memo) + .add_operation_update_memo( + &XfrKeyPair::from_noah(auth_key_pair).unwrap(), + code, + new_memo, + ) .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -217,7 +225,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera validator: JString, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let keypair = &*(keypair as *mut XfrKeyPair); + let keypair = &*(keypair as *mut KeyPair); let validator: String = env .get_string(validator) .expect("Couldn't get java string!") @@ -225,7 +233,11 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera let builder = builder .clone() - .add_operation_delegate(keypair, parseU64(env, amount), validator) + .add_operation_delegate( + &XfrKeyPair::from_noah(keypair).unwrap(), + parseU64(env, amount), + validator, + ) .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -240,8 +252,11 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera keypair: jlong, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let keypair = &*(keypair as *mut XfrKeyPair); - let builder = builder.clone().add_operation_undelegate(keypair).unwrap(); + let keypair = &*(keypair as *mut KeyPair); + let builder = builder + .clone() + .add_operation_undelegate(&XfrKeyPair::from_noah(keypair).unwrap()) + .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -257,7 +272,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera validator: JString, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let keypair = &*(keypair as *mut XfrKeyPair); + let keypair = &*(keypair as *mut KeyPair); let validator: String = env .get_string(validator) @@ -265,7 +280,11 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera .into(); let builder = builder .clone() - .add_operation_undelegate_partially(keypair, parseU64(env, am), validator) + .add_operation_undelegate_partially( + &XfrKeyPair::from_noah(keypair).unwrap(), + parseU64(env, am), + validator, + ) .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -280,8 +299,11 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera keypair: jlong, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let keypair = &*(keypair as *mut XfrKeyPair); - let builder = builder.clone().add_operation_claim(keypair).unwrap(); + let keypair = &*(keypair as *mut KeyPair); + let builder = builder + .clone() + .add_operation_claim(&XfrKeyPair::from_noah(keypair).unwrap()) + .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -296,10 +318,13 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera am: JString, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let keypair = &*(keypair as *mut XfrKeyPair); + let keypair = &*(keypair as *mut KeyPair); let builder = builder .clone() - .add_operation_claim_custom(keypair, parseU64(env, am)) + .add_operation_claim_custom( + &XfrKeyPair::from_noah(keypair).unwrap(), + parseU64(env, am), + ) .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -331,7 +356,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddTrans /// /// Adds a serialized transfer-account operation to transaction builder instance. /// @param {string} amount - amount to transfer. -/// @param {XfrKeyPair} keypair - FRA account key pair. +/// @param {KeyPair} keypair - FRA account key pair. /// @param {String} address - FRA account key pair. /// @throws Will throw an error if `address` is invalid. pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOperationConvertAccount( @@ -348,11 +373,15 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderAddOpera .expect("Couldn't get java string!") .into(); - let fra_kp = &*(keypair as *mut XfrKeyPair); + let fra_kp = &*(keypair as *mut KeyPair); builder .clone() - .add_transfer_to_account_operation(parseU64(env, amount), Some(addr), fra_kp) + .add_transfer_to_account_operation( + parseU64(env, amount), + Some(addr), + &XfrKeyPair::from_noah(fra_kp).unwrap(), + ) .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -367,8 +396,11 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderSign( kp: jlong, ) -> jlong { let builder = &*(builder as *mut TransactionBuilder); - let kp = &*(kp as *mut XfrKeyPair); - let builder = builder.clone().sign(kp).unwrap(); + let kp = &*(kp as *mut KeyPair); + let builder = builder + .clone() + .sign(&XfrKeyPair::from_noah(kp).unwrap()) + .unwrap(); Box::into_raw(Box::new(builder)) as jlong } @@ -381,7 +413,7 @@ pub unsafe extern "system" fn Java_com_findora_JniApi_transactionBuilderTransact _: JClass, builder: jlong, ) -> jstring { - let builder = &*(builder as *mut TransactionBuilder); + let builder = &mut *(builder as *mut TransactionBuilder); let output = env .new_string(builder.transaction()) .expect("Couldn't create java string!"); diff --git a/src/components/wallet_mobile/src/ios/evm.rs b/src/components/wallet_mobile/src/ios/evm.rs index 527c5e11b..16708851c 100644 --- a/src/components/wallet_mobile/src/ios/evm.rs +++ b/src/components/wallet_mobile/src/ios/evm.rs @@ -1,5 +1,5 @@ use std::os::raw::c_char; -use zei::xfr::sig::XfrPublicKey; +use zei::noah_api::keys::PublicKey; use crate::rust::{ self, account::EVMTransactionBuilder, c_char_to_string, string_to_c_char, diff --git a/src/components/wallet_mobile/src/ios/mod.rs b/src/components/wallet_mobile/src/ios/mod.rs index b7dceceb0..185e01009 100644 --- a/src/components/wallet_mobile/src/ios/mod.rs +++ b/src/components/wallet_mobile/src/ios/mod.rs @@ -13,7 +13,7 @@ use rand_core::SeedableRng; use std::ffi::{CStr, CString}; use std::os::raw::c_char; use std::ptr; -use zei::xfr::structs::ASSET_TYPE_LENGTH; +use zei::noah_api::xfr::structs::ASSET_TYPE_LENGTH; #[no_mangle] /// Returns the git commit hash and commit date of the commit this library was built against. diff --git a/src/components/wallet_mobile/src/ios/tx_builder.rs b/src/components/wallet_mobile/src/ios/tx_builder.rs index 3ac3e187e..40b41bffb 100644 --- a/src/components/wallet_mobile/src/ios/tx_builder.rs +++ b/src/components/wallet_mobile/src/ios/tx_builder.rs @@ -1,11 +1,10 @@ -use std::os::raw::c_char; -use zei::xfr::sig::XfrKeyPair; - use super::parse_u64; use crate::rust::{ c_char_to_string, string_to_c_char, AssetRules, ClientAssetRecord, FeeInputs, - OwnerMemo, PublicParams, TransactionBuilder, + OwnerMemo, TransactionBuilder, }; +use std::os::raw::c_char; +use zei::noah_api::keys::KeyPair; #[no_mangle] /// @param kp: owner's XfrKeyPair @@ -108,7 +107,6 @@ pub extern "C" fn findora_ffi_transaction_builder_add_operation_create_asset( /// @param {BigInt} seq_num - Issuance sequence number. Every subsequent issuance of a given asset type must have a higher sequence number than before. /// @param {BigInt} amount - Amount to be issued. /// @param {boolean} conf_amount - `true` means the asset amount is confidential, and `false` means it's nonconfidential. -/// @param {PublicParams} zei_params - Public parameters necessary to generate asset records. #[no_mangle] pub extern "C" fn findora_ffi_transaction_builder_add_basic_issue_asset( builder: &TransactionBuilder, @@ -117,7 +115,6 @@ pub extern "C" fn findora_ffi_transaction_builder_add_basic_issue_asset( seq_num: u64, amount: *const c_char, conf_amount: bool, - zei_params: &PublicParams, ) -> *mut TransactionBuilder { let amount = parse_u64(amount); if let Ok(info) = builder.clone().add_basic_issue_asset( @@ -126,7 +123,6 @@ pub extern "C" fn findora_ffi_transaction_builder_add_basic_issue_asset( seq_num, amount, conf_amount, - zei_params, ) { Box::into_raw(Box::new(info)) } else { diff --git a/src/components/wallet_mobile/src/ios/tx_op_builder.rs b/src/components/wallet_mobile/src/ios/tx_op_builder.rs index 24a6fa28b..c5d2178ac 100644 --- a/src/components/wallet_mobile/src/ios/tx_op_builder.rs +++ b/src/components/wallet_mobile/src/ios/tx_op_builder.rs @@ -1,5 +1,5 @@ use std::os::raw::c_char; -use zei::xfr::sig::{XfrKeyPair, XfrPublicKey}; +use zei::noah_api::keys::{KeyPair, PublicKey}; use super::parse_u64; use crate::rust::TransferOperationBuilder; diff --git a/src/components/wallet_mobile/src/rust/account.rs b/src/components/wallet_mobile/src/rust/account.rs index 130ae2ad3..bd8bb935c 100644 --- a/src/components/wallet_mobile/src/rust/account.rs +++ b/src/components/wallet_mobile/src/rust/account.rs @@ -1,7 +1,7 @@ use core::str::FromStr; use ledger::data_model::ASSET_TYPE_FRA; use ruc::{d, Result, RucResult}; -use zei::xfr::sig::{XfrKeyPair, XfrPublicKey}; +use zei::{XfrKeyPair, XfrPublicKey}; use super::transaction::TransactionBuilder; @@ -29,7 +29,7 @@ impl Keypair { match self { Keypair::Ecdsa(kp) => MultiSignature::from(kp.sign(data)), Keypair::Ed25519(kp) => { - MultiSignature::from(kp.get_sk_ref().sign(data, kp.get_pk_ref())) + MultiSignature::from(kp.get_sk_ref().sign(data).unwrap()) } } } diff --git a/src/components/wallet_mobile/src/rust/crypto.rs b/src/components/wallet_mobile/src/rust/crypto.rs index 86059b624..b6e606091 100644 --- a/src/components/wallet_mobile/src/rust/crypto.rs +++ b/src/components/wallet_mobile/src/rust/crypto.rs @@ -2,7 +2,7 @@ use wasm_bindgen::prelude::*; use super::data_model::*; -use aes_gcm::aead::{generic_array::GenericArray, Aead, NewAead}; +use aes_gcm::aead::{generic_array::GenericArray, Aead, KeyInit}; use aes_gcm::Aes256Gcm; use credentials::{ credential_commit, credential_issuer_key_gen, credential_open_commitment, @@ -11,27 +11,28 @@ use credentials::{ CredUserPublicKey, CredUserSecretKey, Credential as PlatformCredential, }; use cryptohash::sha256; +use getrandom::getrandom; use globutils::wallet; use ledger::{ - data_model::{ - AssetTypeCode, ASSET_TYPE_FRA, BLACK_HOLE_PUBKEY, BLACK_HOLE_PUBKEY_STAKING, - TX_FEE_MIN, - }, + data_model::{AssetTypeCode, ASSET_TYPE_FRA, BLACK_HOLE_PUBKEY_STAKING, TX_FEE_MIN}, staking::{MAX_DELEGATION_AMOUNT, MIN_DELEGATION_AMOUNT}, }; -use rand::{thread_rng, Rng}; use rand_chacha::ChaChaRng; use rand_core::SeedableRng; use ring::pbkdf2; use ruc::Result; use std::num::NonZeroU32; use std::str; -use zei::serialization::ZeiFromToBytes; -use zei::xfr::asset_record::open_blind_asset_record as open_bar; -use zei::xfr::lib::trace_assets as zei_trace_assets; -use zei::xfr::sig::{XfrKeyPair, XfrPublicKey, XfrSecretKey}; -use zei::xfr::structs::{ - AssetType as ZeiAssetType, OpenAssetRecord, XfrBody, ASSET_TYPE_LENGTH, +use zei::{ + noah_algebra::serialization::NoahFromToBytes, + noah_api::xfr::{ + asset_record::open_blind_asset_record as open_bar, + structs::{ + AssetType as NoahAssetType, OpenAssetRecord, XfrBody, ASSET_TYPE_LENGTH, + }, + trace_assets as noah_trace_assets, + }, + XfrKeyPair, XfrPublicKey, XfrSecretKey, }; #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] @@ -47,7 +48,7 @@ pub fn random_asset_type() -> String { /// Generates asset type as a Base64 string from given code. pub fn rs_asset_type_from_value(code: [u8; ASSET_TYPE_LENGTH]) -> String { AssetTypeCode { - val: ZeiAssetType(code), + val: NoahAssetType(code), } .to_base64() } @@ -57,7 +58,7 @@ pub fn rs_trace_assets( xfr_body: XfrBody, tracer_keypair: &AssetTracerKeyPair, ) -> Result> { - Ok(zei_trace_assets(&xfr_body, tracer_keypair.get_keys())? + Ok(noah_trace_assets(&xfr_body, tracer_keypair.get_keys())? .iter() .map(|(amt, asset_type, _, _)| { let asset_type_code = AssetTypeCode { val: *asset_type }; @@ -71,7 +72,7 @@ pub fn rs_trace_assets( /// Returns an address to use for cancelling debt tokens in a debt swap. /// @ignore pub fn get_null_pk() -> XfrPublicKey { - XfrPublicKey::zei_from_bytes(&[0; 32]).unwrap() + XfrPublicKey::noah_from_bytes(&[0; 32]).unwrap() } /// Returns a JavaScript object containing decrypted owner record information, @@ -82,9 +83,9 @@ pub fn rs_open_client_asset_record( keypair: &XfrKeyPair, ) -> Result { open_bar( - record.get_bar_ref(), + &record.get_bar_ref().into_noah()?, &owner_memo.map(|memo| memo.get_memo_ref().clone()), - keypair, + &keypair.into_noah()?, ) } @@ -103,8 +104,8 @@ pub fn get_priv_key_str(key_pair: &XfrKeyPair) -> String { #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] /// Creates a new transfer key pair. pub fn new_keypair() -> XfrKeyPair { - let mut small_rng = rand::thread_rng(); - XfrKeyPair::generate(&mut small_rng) + let mut prng = ChaChaRng::from_entropy(); + XfrKeyPair::generate(&mut prng) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] @@ -131,14 +132,14 @@ pub fn rs_public_key_from_base64(pk: &str) -> Result { /// Expresses a transfer key pair as a hex-encoded string. /// To decode the string, use `keypair_from_str` function. pub fn keypair_to_str(key_pair: &XfrKeyPair) -> String { - hex::encode(key_pair.zei_to_bytes()) + hex::encode(key_pair.noah_to_bytes()) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] /// Constructs a transfer key pair from a hex-encoded string. /// The encode a key pair, use `keypair_to_str` function. pub fn keypair_from_str(str: String) -> XfrKeyPair { - XfrKeyPair::zei_from_bytes(&hex::decode(str).unwrap()).unwrap() + XfrKeyPair::noah_from_bytes(&hex::decode(str).unwrap()).unwrap() } /// Generates a new credential issuer key. @@ -167,7 +168,7 @@ pub fn rs_wasm_credential_verify_commitment( issuer_pub_key, commitment.get_ref(), pok.get_ref(), - xfr_pk.as_bytes(), + &xfr_pk.noah_to_bytes(), ) } @@ -248,7 +249,7 @@ pub fn rs_wasm_credential_commit( &mut prng, user_secret_key, credential.get_cred_ref(), - user_public_key.as_bytes(), + &user_public_key.noah_to_bytes(), )?; Ok(CredentialCommitmentData { commitment: CredentialCommitment { commitment }, @@ -319,10 +320,9 @@ pub fn encryption_pbkdf2_aes256gcm(key_pair: String, password: String) -> Vec Vec u64 { /// The destination for fee to be transfered to. #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] pub fn fra_get_dest_pubkey() -> XfrPublicKey { - *BLACK_HOLE_PUBKEY + XfrPublicKey::from_noah(&BLACK_HOLE_PUBKEY_STAKING).unwrap() } /// The system address used to reveive delegation principals. @@ -486,13 +486,17 @@ pub fn get_delegation_target_address() -> String { #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] #[allow(missing_docs)] pub fn get_coinbase_address() -> String { - wallet::public_key_to_base64(&BLACK_HOLE_PUBKEY_STAKING) + wallet::public_key_to_base64( + &XfrPublicKey::from_noah(&BLACK_HOLE_PUBKEY_STAKING).unwrap(), + ) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] #[allow(missing_docs)] pub fn get_coinbase_principal_address() -> String { - wallet::public_key_to_base64(&BLACK_HOLE_PUBKEY_STAKING) + wallet::public_key_to_base64( + &XfrPublicKey::from_noah(&BLACK_HOLE_PUBKEY_STAKING).unwrap(), + ) } #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] diff --git a/src/components/wallet_mobile/src/rust/data_model.rs b/src/components/wallet_mobile/src/rust/data_model.rs index 12733a3f3..eced37cf6 100644 --- a/src/components/wallet_mobile/src/rust/data_model.rs +++ b/src/components/wallet_mobile/src/rust/data_model.rs @@ -20,39 +20,13 @@ use rand_core::SeedableRng; use ruc::Result as RUCResult; use ruc::{d, err::RucResult}; use serde::{Deserialize, Serialize}; -use zei::setup::PublicParams as ZeiPublicParams; -use zei::xfr::sig::XfrPublicKey; -use zei::xfr::structs::{ - AssetTracerDecKeys, AssetTracerEncKeys, AssetTracerKeyPair as ZeiAssetTracerKeyPair, - BlindAssetRecord, IdentityRevealPolicy, OwnerMemo as ZeiOwnerMemo, - TracingPolicies as ZeiTracingPolicies, TracingPolicy as ZeiTracingPolicy, +use zei::noah_api::xfr::structs::{ + AssetTracerDecKeys, AssetTracerEncKeys, + AssetTracerKeyPair as NoahAssetTracerKeyPair, IdentityRevealPolicy, + OwnerMemo as NoahOwnerMemo, TracingPolicies as NoahTracingPolicies, + TracingPolicy as NoahTracingPolicy, }; - -#[cfg_attr(target_arch = "wasm32", wasm_bindgen)] -/// Public parameters necessary for generating asset records. Generating this is expensive and -/// should be done as infrequently as possible. -/// @see {@link module:Findora-Wasm~TransactionBuilder#add_basic_issue_asset|add_basic_issue_asset} -/// for information using public parameters to create issuance asset records. -pub struct PublicParams { - pub(crate) params: ZeiPublicParams, -} - -#[allow(clippy::new_without_default)] -#[cfg_attr(target_arch = "wasm32", wasm_bindgen)] -impl PublicParams { - /// Generates a new set of parameters. - pub fn new() -> PublicParams { - PublicParams { - params: ZeiPublicParams::default(), - } - } -} - -impl PublicParams { - pub fn get_ref(&self) -> &ZeiPublicParams { - &self.params - } -} +use zei::{BlindAssetRecord, XfrPublicKey}; #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] /// Indicates whether the TXO ref is an absolute or relative value. @@ -238,7 +212,7 @@ impl ClientAssetRecord { /// @see {@link module:Findora-Wasm~AssetRules#add_tracing_policy|add_tracing_policy} for information about how to add a tracing policy to /// an asset definition. pub struct AssetTracerKeyPair { - pub(crate) keypair: ZeiAssetTracerKeyPair, + pub(crate) keypair: NoahAssetTracerKeyPair, } #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] @@ -247,7 +221,7 @@ impl AssetTracerKeyPair { pub fn new() -> Self { let mut small_rng = ChaChaRng::from_entropy(); AssetTracerKeyPair { - keypair: ZeiAssetTracerKeyPair::generate(&mut small_rng), + keypair: NoahAssetTracerKeyPair::generate(&mut small_rng), } } } @@ -266,7 +240,7 @@ impl AssetTracerKeyPair { &self.keypair.dec_key } - pub fn get_keys(&self) -> &ZeiAssetTracerKeyPair { + pub fn get_keys(&self) -> &NoahAssetTracerKeyPair { &self.keypair } } @@ -276,7 +250,7 @@ impl AssetTracerKeyPair { /// Asset owner memo. Contains information needed to decrypt an asset record. /// @see {@link module:Findora-Wasm.ClientAssetRecord|ClientAssetRecord} for more details about asset records. pub struct OwnerMemo { - pub(crate) memo: ZeiOwnerMemo, + pub(crate) memo: NoahOwnerMemo, } #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] @@ -293,29 +267,30 @@ impl OwnerMemo { /// "lock":{"ciphertext":[119,54,117,136,125,133,112,193],"encoded_rand":"8KDql2JphPB5WLd7-aYE1bxTQAcweFSmrqymLvPDntM="} /// } pub fn from_json(val: &JsValue) -> Result { - let zei_owner_memo: ZeiOwnerMemo = + let noah_owner_memo: NoahOwnerMemo = val.into_serde().c(d!()).map_err(error_to_jsvalue)?; Ok(OwnerMemo { - memo: ZeiOwnerMemo { - blind_share: zei_owner_memo.blind_share, - lock: zei_owner_memo.lock, + memo: NoahOwnerMemo { + blind_share: noah_owner_memo.blind_share, + lock: noah_owner_memo.lock, }, }) } #[cfg(not(target_arch = "wasm32"))] - pub fn from_json(zei_owner_memo: ZeiOwnerMemo) -> RUCResult { + pub fn from_json(noah_owner_memo: NoahOwnerMemo) -> RUCResult { Ok(OwnerMemo { - memo: ZeiOwnerMemo { - blind_share: zei_owner_memo.blind_share, - lock: zei_owner_memo.lock, + memo: NoahOwnerMemo { + key_type: noah_owner_memo.key_type, + blind_share_bytes: noah_owner_memo.blind_share_bytes, + lock_bytes: noah_owner_memo.lock_bytes, }, }) } } impl OwnerMemo { - pub fn get_memo_ref(&self) -> &ZeiOwnerMemo { + pub fn get_memo_ref(&self) -> &NoahOwnerMemo { &self.memo } } @@ -369,7 +344,7 @@ impl CredentialRevealSig { /// credential commitment. pub fn get_commitment(&self) -> CredentialCommitment { CredentialCommitment { - commitment: self.sig.sig_commitment.clone(), + commitment: self.sig.cm.clone(), } } /// Returns the underlying proof of knowledge that the credential is valid. @@ -377,7 +352,7 @@ impl CredentialRevealSig { /// credential commitment. pub fn get_pok(&self) -> CredentialPoK { CredentialPoK { - pok: self.sig.pok.clone(), + pok: self.sig.proof_open.clone(), } } } @@ -669,11 +644,11 @@ impl SignatureRules { /// A collection of tracing policies. Use this object when constructing asset transfers to generate /// the correct tracing proofs for traceable assets. pub struct TracingPolicies { - pub(crate) policies: ZeiTracingPolicies, + pub(crate) policies: NoahTracingPolicies, } impl TracingPolicies { - pub fn get_policies_ref(&self) -> &ZeiTracingPolicies { + pub fn get_policies_ref(&self) -> &NoahTracingPolicies { &self.policies } } @@ -682,13 +657,13 @@ impl TracingPolicies { /// Tracing policy for asset transfers. Can be configured to track credentials, the asset type and /// amount, or both. pub struct TracingPolicy { - pub(crate) policy: ZeiTracingPolicy, + pub(crate) policy: NoahTracingPolicy, } #[cfg_attr(target_arch = "wasm32", wasm_bindgen)] impl TracingPolicy { pub fn new_with_tracing(tracing_key: &AssetTracerKeyPair) -> Self { - let policy = ZeiTracingPolicy { + let policy = NoahTracingPolicy { enc_keys: tracing_key.get_enc_key().clone(), asset_tracing: true, identity_tracing: None, @@ -710,7 +685,7 @@ impl TracingPolicy { cred_issuer_pub_key: cred_issuer_key.get_ref().clone(), reveal_map, }; - let policy = ZeiTracingPolicy { + let policy = NoahTracingPolicy { enc_keys: tracing_key.get_enc_key().clone(), asset_tracing: tracing, identity_tracing: Some(identity_policy), @@ -729,7 +704,7 @@ impl TracingPolicy { cred_issuer_pub_key: cred_issuer_key.get_ref().clone(), reveal_map, }; - let policy = ZeiTracingPolicy { + let policy = NoahTracingPolicy { enc_keys: tracing_key.get_enc_key().clone(), asset_tracing: tracing, identity_tracing: Some(identity_policy), @@ -739,7 +714,7 @@ impl TracingPolicy { } impl TracingPolicy { - pub fn get_ref(&self) -> &ZeiTracingPolicy { + pub fn get_ref(&self) -> &NoahTracingPolicy { &self.policy } } diff --git a/src/components/wallet_mobile/src/rust/transaction.rs b/src/components/wallet_mobile/src/rust/transaction.rs index bc85c42aa..7e0ddc7f4 100644 --- a/src/components/wallet_mobile/src/rust/transaction.rs +++ b/src/components/wallet_mobile/src/rust/transaction.rs @@ -17,9 +17,11 @@ use ledger::{ }; use ruc::{eg, Result as RucResult}; use serde_json::Result; -use zei::xfr::asset_record::{open_blind_asset_record as open_bar, AssetRecordType}; -use zei::xfr::sig::{XfrKeyPair, XfrPublicKey}; -use zei::xfr::structs::AssetRecordTemplate; +use zei::noah_api::xfr::asset_record::{ + open_blind_asset_record as open_bar, AssetRecordType, +}; +use zei::noah_api::xfr::structs::AssetRecordTemplate; +use zei::{OwnerMemo as ZeiOwnerMemo, XfrKeyPair, XfrPublicKey}; /// Given a serialized state commitment and transaction, returns true if the transaction correctly /// hashes up to the state commitment and false otherwise. @@ -53,7 +55,7 @@ impl From for PlatformFeeInput { am: fi.am, tr: fi.tr.txo_ref, ar: fi.ar.txo, - om: fi.om.map(|om| om.memo), + om: fi.om.map(|om| ZeiOwnerMemo::from_noah(&om.memo).unwrap()), kp: fi.kp, } } @@ -225,7 +227,6 @@ impl TransactionBuilder { seq_num: u64, amount: u64, conf_amount: bool, - zei_params: &PublicParams, ) -> RucResult { let asset_token = AssetTypeCode::new_from_base64(&code)?; @@ -239,7 +240,6 @@ impl TransactionBuilder { seq_num, amount, confidentiality_flags, - zei_params.get_ref(), )?; Ok(self) } @@ -337,7 +337,8 @@ impl TransactionBuilder { } /// Extracts the serialized form of a transaction. - pub fn transaction(&self) -> String { + pub fn transaction(&mut self) -> String { + self.get_builder_mut().build().unwrap(); self.get_builder().serialize_str() } @@ -359,7 +360,9 @@ impl TransactionBuilder { pub fn get_owner_memo(&self, idx: usize) -> Option { self.get_builder() .get_owner_memo_ref(idx) - .map(|memo| OwnerMemo { memo: memo.clone() }) + .map(|memo| OwnerMemo { + memo: memo.into_noah(), + }) } } @@ -390,9 +393,9 @@ impl TransferOperationBuilder { amount: u64, ) -> RucResult { let oar = open_bar( - asset_record.get_bar_ref(), + &asset_record.get_bar_ref().into_noah()?, &owner_memo.map(|memo| memo.get_memo_ref().clone()), - key, + &key.into_noah()?, )?; self.get_builder_mut().add_input( *txo_ref.get_txo(), @@ -422,7 +425,7 @@ impl TransferOperationBuilder { amount, code.val, asset_record_type, - *recipient, + recipient.into_noah()?, policies.get_policies_ref().clone(), ) } else { @@ -430,7 +433,7 @@ impl TransferOperationBuilder { amount, code.val, asset_record_type, - *recipient, + recipient.into_noah()?, ) }; self.get_builder_mut().add_output( diff --git a/src/components/wallet_mobile/src/rust/types.rs b/src/components/wallet_mobile/src/rust/types.rs index 765072d30..d2f7e1b09 100644 --- a/src/components/wallet_mobile/src/rust/types.rs +++ b/src/components/wallet_mobile/src/rust/types.rs @@ -5,21 +5,21 @@ use credentials::{ CredUserSecretKey as PlatformCredUserSecretKey, }; use std::ops::{Deref, DerefMut}; -use zei::xfr::sig::{XfrKeyPair as ZeiXfrKeyPair, XfrPublicKey as ZeiXfrPublicKey}; -use zei::xfr::structs::OpenAssetRecord as ZeiOpenAssetRecord; +use zei::noah_api::keys::{KeyPair as NoahXfrKeyPair, PublicKey as NoahXfrPublicKey}; +use zei::noah_api::xfr::structs::OpenAssetRecord as NoahOpenAssetRecord; //////////////////////////////////////////////////////////////////////////////// -pub struct XfrPublicKey(ZeiXfrPublicKey); +pub struct XfrPublicKey(NoahXfrPublicKey); -impl From for XfrPublicKey { - fn from(v: ZeiXfrPublicKey) -> XfrPublicKey { +impl From for XfrPublicKey { + fn from(v: NoahXfrPublicKey) -> XfrPublicKey { XfrPublicKey(v) } } impl Deref for XfrPublicKey { - type Target = ZeiXfrPublicKey; + type Target = NoahXfrPublicKey; fn deref(&self) -> &Self::Target { &self.0 @@ -35,16 +35,16 @@ impl DerefMut for XfrPublicKey { //////////////////////////////////////////////////////////////////////////////// #[derive(Clone)] -pub struct XfrKeyPair(ZeiXfrKeyPair); +pub struct XfrKeyPair(NoahXfrKeyPair); -impl From for XfrKeyPair { - fn from(v: ZeiXfrKeyPair) -> XfrKeyPair { +impl From for XfrKeyPair { + fn from(v: NoahXfrKeyPair) -> XfrKeyPair { XfrKeyPair(v) } } impl Deref for XfrKeyPair { - type Target = ZeiXfrKeyPair; + type Target = NoahXfrKeyPair; fn deref(&self) -> &Self::Target { &self.0 @@ -60,16 +60,16 @@ impl DerefMut for XfrKeyPair { //////////////////////////////////////////////////////////////////////////////// #[derive(Clone)] -pub struct OpenAssetRecord(ZeiOpenAssetRecord); +pub struct OpenAssetRecord(NoahOpenAssetRecord); -impl From for OpenAssetRecord { - fn from(v: ZeiOpenAssetRecord) -> OpenAssetRecord { +impl From for OpenAssetRecord { + fn from(v: NoahOpenAssetRecord) -> OpenAssetRecord { OpenAssetRecord(v) } } impl Deref for OpenAssetRecord { - type Target = ZeiOpenAssetRecord; + type Target = NoahOpenAssetRecord; fn deref(&self) -> &Self::Target { &self.0 diff --git a/src/components/wallet_mobile/src/wasm/mod.rs b/src/components/wallet_mobile/src/wasm/mod.rs index 14a7fdf23..a3aeac013 100644 --- a/src/components/wallet_mobile/src/wasm/mod.rs +++ b/src/components/wallet_mobile/src/wasm/mod.rs @@ -6,8 +6,8 @@ use credentials::{ }; use ruc::{d, err::RucResult}; use wasm_bindgen::prelude::*; -use zei::xfr::sig::{XfrKeyPair, XfrPublicKey}; -use zei::xfr::structs::ASSET_TYPE_LENGTH; +use zei::noah_api::xfr::sig::{XfrKeyPair, XfrPublicKey}; +use zei::noah_api::xfr::structs::ASSET_TYPE_LENGTH; #[wasm_bindgen] /// Generates asset type as a Base64 string from a JSON-serialized JavaScript value. @@ -163,7 +163,6 @@ impl TransactionBuilder { /// @param {BigInt} seq_num - Issuance sequence number. Every subsequent issuance of a given asset type must have a higher sequence number than before. /// @param {BigInt} amount - Amount to be issued. /// @param {boolean} conf_amount - `true` means the asset amount is confidential, and `false` means it's nonconfidential. - /// @param {PublicParams} zei_params - Public parameters necessary to generate asset records. pub fn add_basic_issue_asset( self, key_pair: &XfrKeyPair, @@ -171,18 +170,10 @@ impl TransactionBuilder { seq_num: u64, amount: u64, conf_amount: bool, - zei_params: &PublicParams, ) -> Result { let builder = self .0 - .add_basic_issue_asset( - key_pair, - code, - seq_num, - amount, - conf_amount, - zei_params, - ) + .add_basic_issue_asset(key_pair, code, seq_num, amount, conf_amount) .c(d!()) .map_err(error_to_jsvalue)?; diff --git a/src/components/wasm/Cargo.toml b/src/components/wasm/Cargo.toml index 9bcd1f8d8..0727f6da8 100644 --- a/src/components/wasm/Cargo.toml +++ b/src/components/wasm/Cargo.toml @@ -34,20 +34,16 @@ bs58 = "0.4" # OR the compiling will fail. getrandom = { version = "0.2", features = ["js"] } -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } - finutils = { path = "../finutils", default-features = false } -globutils = { git = "https://github.com/shaorongqiang/platform-lib-utils", branch = "main" } -credentials = { git = "https://github.com/shaorongqiang/platform-lib-credentials", branch = "main" } -cryptohash = { git = "https://github.com/shaorongqiang/platform-lib-cryptohash", branch = "main" } +globutils = { git = "https://github.com/FindoraNetwork/platform-lib-utils", branch = "develop" } +credentials = { git = "https://github.com/FindoraNetwork/platform-lib-credentials", branch = "develop" } +cryptohash = { git = "https://github.com/FindoraNetwork/platform-lib-cryptohash", branch = "develop" } ledger = { path = "../../ledger" } fp-utils = { path = "../contracts/primitives/utils" } fp-types = { path = "../contracts/primitives/types" } -zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "main" } +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } [lib] crate-type = ["cdylib", "rlib"] @@ -69,7 +65,6 @@ features = [ serde = "1.0.124" serde_json = "1.0.41" vergen = "=3.1.0" -wasm-bindgen = { version = "=0.2.84", features = ["serde-serialize"] } [dev-dependencies] # Must enable the "js"-feature, @@ -78,4 +73,4 @@ getrandom = { version = "0.2", features = ["js"] } wasm-bindgen-test = "0.3.0" [features] -lightweight = ["noah/lightweight"] # Minimize size for only AR2ABAR and ABAR2AR. +lightweight = ["zei/lightweight"] # Minimize size for only AR2ABAR and ABAR2AR. diff --git a/src/components/wasm/src/wasm.rs b/src/components/wasm/src/wasm.rs index 9709e933f..b095b1660 100644 --- a/src/components/wasm/src/wasm.rs +++ b/src/components/wasm/src/wasm.rs @@ -60,7 +60,17 @@ use { MAX_DELEGATION_AMOUNT, MIN_DELEGATION_AMOUNT, }, }, - noah::{ + rand_chacha::ChaChaRng, + rand_core::SeedableRng, + ruc::{d, err::RucResult}, + serde::{Deserialize, Serialize}, + std::convert::From, + wasm_bindgen::prelude::*, + zei::noah_algebra::{ + bls12_381::BLSScalar, + prelude::{NoahFromToBytes, Scalar}, + }, + zei::noah_api::{ anon_xfr::{ decrypt_memo, nullify, parse_memo, structs::{ @@ -79,17 +89,7 @@ use { trace_assets as noah_trace_assets, }, }, - noah_algebra::{ - bls12_381::BLSScalar, - prelude::{NoahFromToBytes, Scalar}, - }, - noah_crypto::basic::hybrid_encryption::{XPublicKey, XSecretKey}, - rand_chacha::ChaChaRng, - rand_core::SeedableRng, - ruc::{d, err::RucResult}, - serde::{Deserialize, Serialize}, - std::convert::From, - wasm_bindgen::prelude::*, + zei::noah_crypto::basic::hybrid_encryption::{XPublicKey, XSecretKey}, zei::{OwnerMemo as ZeiOwnerMemo, XfrBody, XfrKeyPair, XfrPublicKey, XfrSecretKey}, }; diff --git a/src/components/wasm/src/wasm_data_model.rs b/src/components/wasm/src/wasm_data_model.rs index 1cfec7713..743a7f3f7 100644 --- a/src/components/wasm/src/wasm_data_model.rs +++ b/src/components/wasm/src/wasm_data_model.rs @@ -12,22 +12,22 @@ use { AuthenticatedUtxo, SignatureRules as PlatformSignatureRules, TxOutput, TxoRef as PlatformTxoRef, TxoSID, }, - noah::anon_xfr::structs::{ + rand_chacha::ChaChaRng, + rand_core::SeedableRng, + ruc::{d, err::RucResult}, + serde::{Deserialize, Serialize}, + wasm_bindgen::prelude::*, + zei::noah_algebra::bls12_381::BLSScalar, + zei::noah_api::anon_xfr::structs::{ AnonAssetRecord, AxfrOwnerMemo as NoahAxfrOwnerMemo, MTLeafInfo as NoahMTLeafInfo, }, - noah::xfr::structs::{ + zei::noah_api::xfr::structs::{ AssetTracerDecKeys, AssetTracerEncKeys, AssetTracerKeyPair as NoahAssetTracerKeyPair, IdentityRevealPolicy, OwnerMemo as NoahOwnerMemo, TracingPolicies as NoahTracingPolicies, TracingPolicy as NoahTracingPolicy, }, - noah_algebra::bls12_381::BLSScalar, - rand_chacha::ChaChaRng, - rand_core::SeedableRng, - ruc::{d, err::RucResult}, - serde::{Deserialize, Serialize}, - wasm_bindgen::prelude::*, zei::{BlindAssetRecord, XfrPublicKey}, }; diff --git a/src/ledger/Cargo.toml b/src/ledger/Cargo.toml index 3636dbf06..c856ddb97 100644 --- a/src/ledger/Cargo.toml +++ b/src/ledger/Cargo.toml @@ -33,23 +33,19 @@ fp-types = { path = "../components/contracts/primitives/types" } fp-utils = { path = "../components/contracts/primitives/utils" } ruc = "1.0" itertools = "0.10" -noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-crypto = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -noah-algebra = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } -bulletproofs = { package = "noah-bulletproofs", version = "4.0.0" } fbnc = { version = "0.2.9", default-features = false} num-bigint = "0.4.3" -globutils = { git = "https://github.com/shaorongqiang/platform-lib-utils", branch = "main" } -bitmap = { git = "https://github.com/shaorongqiang/platform-lib-bitmap", branch = "main" } -cryptohash = { git = "https://github.com/shaorongqiang/platform-lib-cryptohash", branch = "main" } -credentials = { git = "https://github.com/shaorongqiang/platform-lib-credentials", branch = "main" } -merkle_tree = { git = "https://github.com/shaorongqiang/platform-lib-merkle", branch = "main" } -sliding_set = { git = "https://github.com/shaorongqiang/platform-lib-slidingset", branch = "main" } +globutils = { git = "https://github.com/FindoraNetwork/platform-lib-utils", branch = "develop" } +bitmap = { git = "https://github.com/FindoraNetwork/platform-lib-bitmap", branch = "develop" } +cryptohash = { git = "https://github.com/FindoraNetwork/platform-lib-cryptohash", branch = "develop" } +credentials = { git = "https://github.com/FindoraNetwork/platform-lib-credentials", branch = "develop" } +merkle_tree = { git = "https://github.com/FindoraNetwork/platform-lib-merkle", branch = "develop" } +sliding_set = { git = "https://github.com/FindoraNetwork/platform-lib-slidingset", branch = "develop" } -zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "main" } +zei = { package="platform-lib-noah", git = "https://github.com/FindoraNetwork/platform-lib-noah", branch = "develop" } [features] default = ["fin_storage"] diskcache = ["fbnc/diskcache"] @@ -69,8 +65,7 @@ parking_lot = "0.12" fs2 = "0.4" storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4", optional = true } fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.4", optional = true } -sparse_merkle_tree = { git = "https://github.com/FindoraNetwork/platform-lib-sparse-merkle", branch = "main" } -noah-accumulators = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.4.3" } +sparse_merkle_tree = { git = "https://github.com/FindoraNetwork/platform-lib-sparse-merkle", branch = "develop" } [target.'cfg(target_arch = "wasm32")'.dependencies] parking_lot = { version = "0.11.1", features = ["wasm-bindgen"] } diff --git a/src/ledger/src/data_model/__trash__.rs b/src/ledger/src/data_model/__trash__.rs index d66c70f2a..ee27a584d 100644 --- a/src/ledger/src/data_model/__trash__.rs +++ b/src/ledger/src/data_model/__trash__.rs @@ -11,8 +11,8 @@ use { crate::data_model::AssetTypeCode, fixed::types::I20F12, - noah::xfr::structs::AssetType, serde::{Deserialize, Serialize}, + zei::noah_api::xfr::structs::AssetType, zei::XfrPublicKey, }; diff --git a/src/ledger/src/data_model/effects.rs b/src/ledger/src/data_model/effects.rs index 93440c44a..713002bf5 100644 --- a/src/ledger/src/data_model/effects.rs +++ b/src/ledger/src/data_model/effects.rs @@ -19,7 +19,17 @@ use { config::abci::global_cfg::CFG, globutils::HashOf, lazy_static::lazy_static, - noah::{ + parking_lot::Mutex, + rand_chacha::{ChaCha20Rng, ChaChaRng}, + rand_core::SeedableRng, + ruc::*, + serde::Serialize, + std::{ + collections::{HashMap, HashSet}, + sync::Arc, + }, + zei::noah_algebra::serialization::NoahFromToBytes, + zei::noah_api::{ anon_xfr::{ abar_to_abar::AXfrNote, structs::{AnonAssetRecord, Nullifier}, @@ -30,16 +40,6 @@ use { verify_xfr_body, }, }, - noah_algebra::serialization::NoahFromToBytes, - parking_lot::Mutex, - rand_chacha::{ChaCha20Rng, ChaChaRng}, - rand_core::SeedableRng, - ruc::*, - serde::Serialize, - std::{ - collections::{HashMap, HashSet}, - sync::Arc, - }, zei::XfrPublicKey, }; diff --git a/src/ledger/src/data_model/mod.rs b/src/ledger/src/data_model/mod.rs index 716fd281b..48c2d17b4 100644 --- a/src/ledger/src/data_model/mod.rs +++ b/src/ledger/src/data_model/mod.rs @@ -33,7 +33,25 @@ use { globutils::wallet::public_key_to_base64, globutils::{HashOf, ProofOf, Serialized, SignatureOf}, lazy_static::lazy_static, - noah::{ + rand::Rng, + rand_chacha::{rand_core, ChaChaRng}, + rand_core::{CryptoRng, RngCore, SeedableRng}, + ruc::*, + serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}, + std::{ + collections::{HashMap, HashSet}, + convert::TryFrom, + fmt, + hash::{Hash, Hasher}, + mem, + ops::Deref, + result::Result as StdResult, + }, + unicode_normalization::UnicodeNormalization, + zei::noah_algebra::{ + bls12_381::BLSScalar, serialization::NoahFromToBytes, traits::Scalar, + }, + zei::noah_api::{ anon_xfr::{ abar_to_abar::AXfrNote, abar_to_ar::{verify_abar_to_ar_note, AbarToArNote}, @@ -54,25 +72,7 @@ use { XfrNotePolicies, }, }, - noah_algebra::{ - bls12_381::BLSScalar, prelude::Scalar, serialization::NoahFromToBytes, - }, - noah_crypto::basic::anemoi_jive::{AnemoiJive, AnemoiJive381}, - rand::Rng, - rand_chacha::{rand_core, ChaChaRng}, - rand_core::{CryptoRng, RngCore, SeedableRng}, - ruc::*, - serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}, - std::{ - collections::{HashMap, HashSet}, - convert::TryFrom, - fmt, - hash::{Hash, Hasher}, - mem, - ops::Deref, - result::Result as StdResult, - }, - unicode_normalization::UnicodeNormalization, + zei::noah_crypto::basic::anemoi_jive::{AnemoiJive, AnemoiJive381}, zei::{BlindAssetRecord, OwnerMemo, XfrBody, XfrKeyPair, XfrPublicKey}, }; diff --git a/src/ledger/src/data_model/test.rs b/src/ledger/src/data_model/test.rs index a3c19ce7a..1ea36598c 100755 --- a/src/ledger/src/data_model/test.rs +++ b/src/ledger/src/data_model/test.rs @@ -3,13 +3,13 @@ use { super::*, curve25519_dalek::ristretto::CompressedRistretto, - noah::{ + rand_core::SeedableRng, + std::cmp::min, + zei::noah_algebra::prelude::msg_eq, + zei::noah_api::{ ristretto, xfr::structs::{AssetTypeAndAmountProof, XfrProofs}, }, - noah_algebra::prelude::msg_eq, - rand_core::SeedableRng, - std::cmp::min, zei::XfrBody, }; diff --git a/src/ledger/src/staking/mod.rs b/src/ledger/src/staking/mod.rs index 07f85b482..5fb10e0cf 100644 --- a/src/ledger/src/staking/mod.rs +++ b/src/ledger/src/staking/mod.rs @@ -33,7 +33,6 @@ use { globutils::wallet, indexmap::IndexMap, lazy_static::lazy_static, - noah::keys::PublicKey as NoahXfrPublicKey, ops::{ fra_distribution::FraDistributionOps, mint_fra::{MintKind, MINT_AMOUNT_LIMIT}, @@ -51,6 +50,7 @@ use { Arc, }, }, + zei::noah_api::keys::PublicKey as NoahXfrPublicKey, zei::{XfrKeyPair, XfrPublicKey}, }; diff --git a/src/ledger/src/staking/ops/delegation.rs b/src/ledger/src/staking/ops/delegation.rs index a91f6edf0..2f09da0f4 100644 --- a/src/ledger/src/staking/ops/delegation.rs +++ b/src/ledger/src/staking/ops/delegation.rs @@ -16,11 +16,11 @@ use { }, }, ed25519_dalek::Signer, - noah::xfr::structs::{XfrAmount, XfrAssetType}, ruc::*, serde::{Deserialize, Serialize}, std::collections::HashSet, tendermint::{signature::Ed25519Signature, PrivateKey, PublicKey, Signature}, + zei::noah_api::xfr::structs::{XfrAmount, XfrAssetType}, zei::{XfrKeyPair, XfrPublicKey, XfrSignature}, }; diff --git a/src/ledger/src/staking/ops/mint_fra.rs b/src/ledger/src/staking/ops/mint_fra.rs index 8dfeda1e8..cb38b7535 100644 --- a/src/ledger/src/staking/ops/mint_fra.rs +++ b/src/ledger/src/staking/ops/mint_fra.rs @@ -10,14 +10,14 @@ use { data_model::TxOutput, staking::{Amount, FRA}, }, - noah::xfr::{ - asset_record::{build_blind_asset_record, AssetRecordType}, - structs::{AssetRecordTemplate, AssetType}, - }, - noah_algebra::ristretto::PedersenCommitmentRistretto, rand_chacha::ChaChaRng, rand_core::SeedableRng, serde::{Deserialize, Serialize}, + zei::noah_algebra::ristretto::PedersenCommitmentRistretto, + zei::noah_api::xfr::{ + asset_record::{build_blind_asset_record, AssetRecordType}, + structs::{AssetRecordTemplate, AssetType}, + }, zei::{BlindAssetRecord, OwnerMemo, XfrPublicKey}, }; diff --git a/src/ledger/src/store/api_cache.rs b/src/ledger/src/store/api_cache.rs index dc566e169..610210185 100644 --- a/src/ledger/src/store/api_cache.rs +++ b/src/ledger/src/store/api_cache.rs @@ -17,10 +17,10 @@ use { config::abci::global_cfg::CFG, fbnc::{new_mapx, new_mapxnk, Mapx, Mapxnk}, globutils::{wallet, HashOf}, - noah::anon_xfr::structs::AxfrOwnerMemo, ruc::*, serde::{Deserialize, Serialize}, std::collections::HashSet, + zei::noah_api::anon_xfr::structs::AxfrOwnerMemo, zei::{OwnerMemo, XfrPublicKey}, }; diff --git a/src/ledger/src/store/helpers.rs b/src/ledger/src/store/helpers.rs index 8e9e9f1b9..550a66425 100644 --- a/src/ledger/src/store/helpers.rs +++ b/src/ledger/src/store/helpers.rs @@ -13,15 +13,15 @@ use { TxOutput, TxnEffect, TxnSID, TxoRef, TxoSID, }, globutils::SignatureOf, - noah::xfr::{ + rand_core::{CryptoRng, RngCore}, + ruc::*, + std::fmt::Debug, + zei::noah_algebra::ristretto::PedersenCommitmentRistretto, + zei::noah_api::xfr::{ asset_record::AssetRecordType, asset_record::{build_blind_asset_record, open_blind_asset_record}, structs::{AssetRecord, AssetRecordTemplate}, }, - noah_algebra::ristretto::PedersenCommitmentRistretto, - rand_core::{CryptoRng, RngCore}, - ruc::*, - std::fmt::Debug, zei::{BlindAssetRecord, XfrKeyPair, XfrPublicKey}, }; diff --git a/src/ledger/src/store/mod.rs b/src/ledger/src/store/mod.rs index 235a28179..41846c034 100644 --- a/src/ledger/src/store/mod.rs +++ b/src/ledger/src/store/mod.rs @@ -32,26 +32,6 @@ use { globutils::wallet, globutils::{HashOf, ProofOf}, merkle_tree::AppendOnlyMerkle, - noah::{ - anon_xfr::{ - abar_to_abar::verify_anon_xfr_note, - structs::{ - AnonAssetRecord, AxfrOwnerMemo, Commitment, MTLeafInfo, MTNode, MTPath, - Nullifier, - }, - TREE_DEPTH as MERKLE_TREE_DEPTH, - }, - setup::VerifierParams, - xfr::{ - structs::{TracingPolicies, TracingPolicy}, - XfrNotePolicies, - }, - }, - noah_accumulators::merkle_tree::{ - ImmutablePersistentMerkleTree, PersistentMerkleTree, Proof, TreePath, - }, - noah_algebra::{bls12_381::BLSScalar, prelude::*}, - noah_crypto::basic::anemoi_jive::{AnemoiJive, AnemoiJive381}, parking_lot::RwLock, rand_chacha::ChaChaRng, rand_core::SeedableRng, @@ -72,6 +52,26 @@ use { state::{ChainState, State}, store::{ImmutablePrefixedStore, PrefixedStore}, }, + zei::noah_accumulators::merkle_tree::{ + ImmutablePersistentMerkleTree, PersistentMerkleTree, Proof, TreePath, + }, + zei::noah_algebra::{bls12_381::BLSScalar, prelude::*}, + zei::noah_api::{ + anon_xfr::{ + abar_to_abar::verify_anon_xfr_note, + structs::{ + AnonAssetRecord, AxfrOwnerMemo, Commitment, MTLeafInfo, MTNode, MTPath, + Nullifier, + }, + TREE_DEPTH as MERKLE_TREE_DEPTH, + }, + setup::VerifierParams, + xfr::{ + structs::{TracingPolicies, TracingPolicy}, + XfrNotePolicies, + }, + }, + zei::noah_crypto::basic::anemoi_jive::{AnemoiJive, AnemoiJive381}, zei::{OwnerMemo, XfrPublicKey}, }; diff --git a/src/ledger/src/store/test.rs b/src/ledger/src/store/test.rs index 55ce7bc49..52e26a391 100755 --- a/src/ledger/src/store/test.rs +++ b/src/ledger/src/store/test.rs @@ -11,7 +11,10 @@ use { }, utils::{create_definition_transaction, fra_gen_initial_tx}, }, - noah::{ + rand_core::SeedableRng, + zei::noah_algebra::prelude::{One, Zero}, + zei::noah_algebra::ristretto::PedersenCommitmentRistretto, + zei::noah_api::{ anon_xfr::structs::OpenAnonAssetRecordBuilder, xfr::{ asset_record::{ @@ -20,9 +23,6 @@ use { structs::{AssetRecord, AssetRecordTemplate}, }, }, - noah_algebra::prelude::{One, Zero}, - noah_algebra::ristretto::PedersenCommitmentRistretto, - rand_core::SeedableRng, zei::{BlindAssetRecord, XfrKeyPair}, }; @@ -837,7 +837,7 @@ fn test_update_anon_stores() { .unwrap(); let oabar = OpenAnonAssetRecordBuilder::new() .amount(123) - .asset_type(noah::xfr::structs::AssetType([39u8; 32])) + .asset_type(zei::noah_api::xfr::structs::AssetType([39u8; 32])) .pub_key(&pub_key) .finalize(&mut prng) .unwrap() @@ -845,7 +845,7 @@ fn test_update_anon_stores() { .unwrap(); let oabar2 = OpenAnonAssetRecordBuilder::new() .amount(123) - .asset_type(noah::xfr::structs::AssetType([39u8; 32])) + .asset_type(zei::noah_api::xfr::structs::AssetType([39u8; 32])) .pub_key(&pub_key) .finalize(&mut prng) .unwrap() diff --git a/src/ledger/src/utils.rs b/src/ledger/src/utils.rs index a1d6d5546..98aa42761 100644 --- a/src/ledger/src/utils.rs +++ b/src/ledger/src/utils.rs @@ -2,7 +2,7 @@ //! # Test only //! -use noah::xfr::structs::AssetType; +use zei::noah_api::xfr::structs::AssetType; use { crate::{ @@ -15,14 +15,14 @@ use { }, fbnc::NumKey, fp_utils::hashing::keccak_256, - noah::xfr::{ - asset_record::{build_blind_asset_record, AssetRecordType}, - structs::AssetRecordTemplate, - }, - noah_algebra::ristretto::PedersenCommitmentRistretto, rand_chacha::ChaChaRng, rand_core::SeedableRng, ruc::*, + zei::noah_algebra::ristretto::PedersenCommitmentRistretto, + zei::noah_api::xfr::{ + asset_record::{build_blind_asset_record, AssetRecordType}, + structs::AssetRecordTemplate, + }, zei::{BlindAssetRecord, XfrKeyPair}, };