Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/dart-bp-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ jobs:

- name: Run tests with ignore_prover_input_sanitation feature
run: cargo test --package polymesh-dart-bp --features ignore_prover_input_sanitation input_sanitation_disabled

- name: Check formatting for polymesh-dart crate
run: cargo fmt --package polymesh-dart -- --check

- name: Run tests for polymesh-dart crate
run: cargo test --release --package polymesh-dart

test-wasm:
name: Build dart-bp for WASM target
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ target
*.dat
*.bin
*.db
!tests/serialized_objects/v1/*.bin

# Documentation builds
dart-bp/docs/combined.md
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ The library provides several feature flags:
- `parallel` - Enable parallel computation for improved performance
- `async_tree` - Enable asynchronous curve tree operations

## Testing

Tests that check against serialized data to detect breaking changes are run as
```
cargo test -r --test serialized_objects_test
```

To create the serialized data, run
```
cargo test -r --test serialized_objects_test generate_v1_serialized_objects -- --ignored
```

## Code coverage

Run code coverage as
```
cargo llvm-cov -p polymesh-dart -p polymesh-dart-bp --release --lcov --output-path target/coverage/lcov.info --no-clean
```

To get report in HTML, install `lcov` and run run
```
genhtml -o target/coverage/html target/coverage/lcov.info
Comment thread
Neopallium marked this conversation as resolved.
```

This will generate a `target/coverage/html/index.html` file.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
Expand Down
27 changes: 4 additions & 23 deletions dart-bp/src/account/common/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ use crate::account::{
AccountCommitmentKeyTrait, AccountStateCommitment, AmountCiphertext, CommonStateChangeProof,
};
use crate::util::{
add_verification_tuples_to_rmc, bp_gens_vec_for_randomness_relations,
enforce_balance_change_verifier,
bp_gens_vec_for_randomness_relations, enforce_balance_change_verifier,
enforce_constraints_and_take_challenge_contrib_of_sigma_t_values_for_common_state_change,
enforce_constraints_for_randomness_relations, get_verification_tuples_with_rng,
take_challenge_contrib_of_sigma_t_values_for_balance_change, verify_given_verification_tuples,
handle_verification_tuples, take_challenge_contrib_of_sigma_t_values_for_balance_change,
verify_sigma_for_balance_change, verify_sigma_for_common_state_change,
};
use crate::{
Expand Down Expand Up @@ -163,16 +162,7 @@ impl<
rmc_0,
)?;

match rmc {
Some((rmc_0, rmc_1)) => add_verification_tuples_to_rmc(
even_tuple,
odd_tuple,
account_tree_params,
rmc_0,
rmc_1,
),
None => verify_given_verification_tuples(even_tuple, odd_tuple, account_tree_params),
}
handle_verification_tuples(even_tuple, odd_tuple, account_tree_params, rmc)
}

/// Verifies the proof except for final Bulletproof verification
Expand Down Expand Up @@ -1305,16 +1295,7 @@ impl<
rng,
rmc_0,
)?;
match rmc {
Some((rmc_0, rmc_1)) => add_verification_tuples_to_rmc(
even_tuple,
odd_tuple,
account_tree_params,
rmc_0,
rmc_1,
),
None => verify_given_verification_tuples(even_tuple, odd_tuple, account_tree_params),
}
handle_verification_tuples(even_tuple, odd_tuple, account_tree_params, rmc)
}
}

Expand Down
1 change: 0 additions & 1 deletion dart-bp/src/account/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ pub struct MintTxnProof<
> {
pub partial: MintTxnProofPartial<F0, F1, G0, G1, { L }>,
/// Commitment to randomness and response for proving knowledge of issuer secret key using Schnorr protocol (step 1 and 3 of Schnorr)
// pub resp_pk_aff: PokDiscreteLog<Affine<G0>>,
pub auth_proof: AuthProofOnlySks<Affine<G0>>,
}

Expand Down
34 changes: 0 additions & 34 deletions src/bp/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,39 +489,6 @@ impl<
ctx: &[u8],
tree_lookup: &impl CurveTreeLookup<FEE_ACCOUNT_TREE_L, FEE_ACCOUNT_TREE_M, C>,
) -> Result<Self, Error> {
/*
let state_change = account_state.topup(amount)?;
let updated_account_state_commitment = state_change.commitment()?;
let current_account_path = state_change.get_path(tree_lookup)?;

let root = tree_lookup.root()?;
let root = root.root_node()?;

let (proof, nullifier) = bp_fee_account::FeeAccountTopupTxnProof::new::<_, _, _>(
rng,
key.secret.0.0,
amount,
&state_change.current_state,
&state_change.new_state,
state_change.new_commitment,
current_account_path,
&root,
ctx,
tree_lookup.params(),
dart_gens().account_comm_key(),
)?;
Ok(Self {
account: key.public,
asset_id: state_change.new_state.asset_id,
amount,
updated_account_state_commitment,
nullifier: FeeAccountStateNullifier::from_affine(nullifier)?,

inner: WrappedCanonical::wrap(&proof)?,
})
// */

//*
let (protocol, device_request) = FeeTopupHostProtocol::<C>::init(
rng,
&key.public,
Expand All @@ -541,7 +508,6 @@ impl<
let proof = protocol.finish(rng, &device_response, tree_lookup.params())?;

Ok(proof)
// */
}

/// Verifies the topup proof against the provided public key, asset ID, amount, and account state commitment.
Expand Down
7 changes: 7 additions & 0 deletions src/bp/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ impl AccountPublicKey {
)]
pub struct AccountSecretKey(pub(crate) bp_keys::SigKey<PallasA>);

impl AccountSecretKey {
/// Gets the inner signing key.
pub fn inner(&self) -> &bp_keys::SigKey<PallasA> {
&self.0
}
}

/// The account key pair, consisting of the public and secret keys.
#[derive(
Clone, Debug, Encode, Decode, DecodeWithMemTracking, PartialEq, Eq, Zeroize, ZeroizeOnDrop,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tests/serialized_objects/v1/account_key_pair.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1yæñè•õ9Òº6‹Z7ÎaÌý†Ì~~نù‘ ·¥½­è§÷Ñl›©Êy˜,ß×4OÍ8«U œ5Èé%
Binary file added tests/serialized_objects/v1/account_keys.bin
Binary file not shown.
Binary file added tests/serialized_objects/v1/account_public_keys.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/serialized_objects/v1/account_reg_split_response.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
&à·¸åÅEc3"&š×Ú(‚z{Ò»ÚNç°¹Ês´'šÍ~Ë þ(DT²/‘ë¬äZhLm& >¬|Ò=òg1} iGÀÇô]ð†¦DKÓnçç›ᒛ9Q/qŸ=ÓbÅîX9™»ßyDÔ©Z
··,¡VÔ¯;vû7
Expand Down
Binary file not shown.
Binary file added tests/serialized_objects/v1/account_state.bin
Binary file not shown.
1 change: 1 addition & 0 deletions tests/serialized_objects/v1/account_state_commitment.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
þf•n²Ë›u± $çßìóèìåÍlOu7¿‡à5¤
1 change: 1 addition & 0 deletions tests/serialized_objects/v1/account_state_nullifier.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
¾¢”#cæn¬˜pn½ùöŒêç*ä%(¡P0f¹
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/serialized_objects/v1/dart_bp_generators.bin
Binary file not shown.
Binary file added tests/serialized_objects/v1/encryption_key_pair.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tests/serialized_objects/v1/fee_payment_split_response.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
í5…jï*®%xA¿þœƒ†tªgëzвîÏ.ê—y¼å¶[JY°ñø5‘ÇËf¼Oñ‚¹‡E.Ð"›´VbhU€4löi_ísÿą:žv) ð4Fz7¯5.j8ã›Ò¹l:;nÒü`Óêæñ{óŽ|UÌ4›ZcG¾Wª‚”eb¿59N „Ùò핤]–ˆ×ëkÞ&DÙchOaû±An=ù>…㘺ƒ2Ìc=œâ¦Eë&ôÝ ¾ñäÙ2ÿ- ¿¨°
Expand Down
Binary file added tests/serialized_objects/v1/fee_reg_split_proof.bin
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions tests/serialized_objects/v1/fee_reg_split_response.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
¦Ky—£›¶Îv:LCÎS°äœg—'pMĸiËÙ.GÅQÎsoÖ(`©Á‰7³ƒXÈy»´?Y–<
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions tests/serialized_objects/v1/fee_topup_split_request.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
€K­âßÈÞ"zxçÒç•eÈ$ŠxJpæ¯ss §þ/@test-identity-v11yæñè•õ9Òº6‹Z7ÎaÌý†Ì~~نù‘ ·
1 change: 1 addition & 0 deletions tests/serialized_objects/v1/fee_topup_split_response.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lö¦„…ëÔ¿XŽ0ͧ•Ò•oˆ\–[7î”ߏ°œŒÑ¢4b„ šë7 ðßQ-’0}Qö¯õ 
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
¥ K”æœþ•×Ç[zjʞ!/­ãåß"Š,™¡u
ƒ@ª-™ ëä}²f)ôååvü'µv¹ÌÌö>;UöòîݟÐòyEö±ú\7 &×oãÙÚµÄ:î15]ϰpßyF7u¦iI•¿8Î ¡t‚Ð0K³¾”—óOÈ äM†;Ö6:#Vº#²[µ'†Óløùý"SxŠëÜ:£ŽrUtàk.X‘ã2æËö—ܯyžw ,ÙÖ±1û·1 ùã-èC–œ–ÿѝŠ[zO£ÎC.XÏÒ£íFȓ$$rÜ׸¦ó,³![==)+Ž;â¯ÀÞ¾ðúwÑó†áÚâ*Å< ÿǔ9/©¸ÃýpØ|eAz^©ýXSˆBw~ÀDlTðJ·§
ŸvXÖ_fø”èráÆ*,¸»ÎOõ’Ör¾”ÍNôô–utgZ,² ¼»GvÏÁ윢K”U›^A2,&;³R
+z­e³ãò|8>(„-Ù ¥ùòÒ>7V-g""“C¡ÛS»²øíåüZIÈ× ¾œg+Ԍ¢¦]ƒÈÙfJĉœõ y@°X€#é<‡ñ¾ó«¥Nù"&zQH¥=•Wjœèá`«¦þ›¼ ç~W?mœM/$%ÉUvä|â›jeª€ëd¿\ÔéMýqøA…M;!‘¼°z`‘–€°¢Ôüþæižá>xB4$瞬›éú­'" ),¼éW(ãtl ÷¾ Dóˉ‡îD æj}_±" ¯"YªŽf°h
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/serialized_objects/v1/leg_encrypted.bin
Binary file not shown.
Binary file added tests/serialized_objects/v1/mediator_encryption.bin
Binary file not shown.
Binary file added tests/serialized_objects/v1/mint_split_proof.bin
Binary file not shown.
Binary file added tests/serialized_objects/v1/mint_split_request.bin
Binary file not shown.
Binary file added tests/serialized_objects/v1/mint_split_response.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/serialized_objects/v1/sender_affirm_split_response.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
¥ K”æœþ•×Ç[zjʞ!/­ãåß"Š,™¡u
ƒ@ª-™ &ÍѱÈHàdF…s¦æú#º§ç؉#Ó*¿ªÔdô.Ë ÚB?F)s!Ùx«”u¤mÉÐ@IBaVlûtD0 ½tÛ(‡—©ƒ™ùLF9úÈÚ°u ñœÆfmå‘‚1Ö6:#Vº#²[µ'†Óløùý"SxŠëÜ:£ŽrUätÊ¿"ΦEt?±È¿H‹§³UH–`®[ÆíˆËJuX% ùã-èC–œ–ÿѝŠ[zO£ÎC.XÏÒ£íFȓ$$rÜ׸¦ó,³![==)+Ž;â¯ÀÞ¾ðúwÑó†áÚâ*Å< ÿǔ9/©¸ÃýpØ|eAz^©ýXSˆBw~ÀDlTðJ·§
ŸvXÖ_fø”èráÆ*,¸»ÎOõ’Ör¾”ÍNôô–utgZ,² ¼»GvÏÁ윢K”U›^A2,&;³R
+z­e³ãò|8>(„-Ù ªŒõøõP#ˆ¸7ñ£}„P1U©ÒóÖf5¡?C«,§ehhC½Súg4kf…’
2,ÆmY@³ïeDÓ#4é<‡ñ¾ó«¥Nù"&zQH¥=•Wjœèá`«¦þ›¼ ç~W?mœM/$%ÉUvä|â›jeª€ëd¾ÕPÖXjhv…ÊâÚ±“`
•äuµOvªši4©?6xB4$瞬›éú­'" ),¼éW(ãtl ÷J3Ù>P—¯E¦ŠL‚×¢ÒÑ9qXh Эû”³>PdBD$
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/serialized_objects/v1/settlement_proof.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading