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
1 change: 1 addition & 0 deletions stellar/Cargo.lock

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

15 changes: 13 additions & 2 deletions stellar/bench-crossover/src/crossover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ use stealth_sender::{StealthSenderContract, StealthSenderContractClient};

pub const CROSSOVER_SIZES: [u32; 6] = [1, 2, 5, 10, 15, 20];

/// Fill bytes whose `[fill; 32]` encoding is a canonical, on-curve, torsion-free
/// ed25519 public key, so the announcer's validation accepts the generated
/// crossover inputs.
const VALID_EPK_FILLS: [u8; 14] = [
0x06, 0x19, 0x1a, 0x1d, 0x35, 0x4c, 0x7b, 0x81, 0x83, 0x8f, 0x97, 0xa7, 0xd6, 0xe2,
];

fn valid_epk_fill(seed: usize) -> u8 {
VALID_EPK_FILLS[seed % VALID_EPK_FILLS.len()]
}

#[derive(Clone, Debug)]
pub struct CrossoverRow {
pub n: u32,
Expand Down Expand Up @@ -86,7 +97,7 @@ fn measure_individual(n: u32) -> Measured {
&100,
&2,
&Address::generate(&env),
&BytesN::from_array(&env, &[(i as u8).wrapping_add(1); 32]),
&BytesN::from_array(&env, &[valid_epk_fill(i as usize); 32]),
&bytes(&env, 32, (i as u8).wrapping_add(1)),
);
total_wall_ns += start.elapsed().as_nanos();
Expand Down Expand Up @@ -116,7 +127,7 @@ fn measure_batch(n: u32) -> Measured {
for i in 0..n {
transfers.push_back(Transfer {
stealth_address: Address::generate(&env),
ephemeral_pub_key: bytes(&env, 32, 0x02u8.wrapping_add(i as u8)),
ephemeral_pub_key: bytes(&env, 32, valid_epk_fill(i as usize)),
amount: 100,
metadata: bytes(&env, 1, (i as u8).wrapping_add(1)),
});
Expand Down
29 changes: 20 additions & 9 deletions stellar/bench/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ use stealth_splitter::{Beneficiary, StealthSplitterContract, StealthSplitterCont
use stealth_vault::{StealthVaultContract, StealthVaultContractClient};
use wraith_names::{WraithNamesContract, WraithNamesContractClient};

/// Fill bytes whose `[fill; 32]` encoding is a canonical, on-curve, torsion-free
/// ed25519 public key, so the announcer's validation accepts the generated
/// harness inputs.
const VALID_EPK_FILLS: [u8; 14] = [
0x06, 0x19, 0x1a, 0x1d, 0x35, 0x4c, 0x7b, 0x81, 0x83, 0x8f, 0x97, 0xa7, 0xd6, 0xe2,
];

fn valid_epk_fill(seed: usize) -> u8 {
VALID_EPK_FILLS[seed % VALID_EPK_FILLS.len()]
}

#[derive(Clone, Debug)]
pub struct Row {
pub contract: &'static str,
Expand Down Expand Up @@ -52,7 +63,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
client.announce(
&STELLAR_V2_SCHEME_ID,
&Address::generate(env),
&BytesN::from_array(env, &[7u8; 32]),
&BytesN::from_array(env, &[0x06u8; 32]),
&bytes(env, metadata_len, 9),
);
},
Expand Down Expand Up @@ -104,7 +115,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
&100,
&STELLAR_V2_SCHEME_ID,
&Address::generate(env),
&BytesN::from_array(env, &[3u8; 32]),
&BytesN::from_array(env, &[0x19u8; 32]),
&bytes(env, 32, 4),
);
},
Expand All @@ -130,7 +141,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
let mut amounts: SorobanVec<i128> = vec![env];
for i in 0..batch_size {
addresses.push_back(Address::generate(env));
keys.push_back(BytesN::from_array(env, &[i as u8; 32]));
keys.push_back(BytesN::from_array(env, &[valid_epk_fill(i as usize); 32]));
metadatas.push_back(bytes(env, 32, i as u8));
amounts.push_back(100);
}
Expand Down Expand Up @@ -304,7 +315,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
let mut metadatas: SorobanVec<Bytes> = vec![env];
for i in 0..n {
addresses.push_back(Address::generate(env));
keys.push_back(BytesN::from_array(env, &[i as u8; 32]));
keys.push_back(BytesN::from_array(env, &[valid_epk_fill(i as usize); 32]));
metadatas.push_back(bytes(env, 32, i as u8));
}
client.fund_split(
Expand Down Expand Up @@ -335,7 +346,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
&token,
&VAULT_UNLOCK_LEDGER,
&VAULT_REFUND_AFTER,
&BytesN::from_array(env, &[11u8; 32]),
&BytesN::from_array(env, &[0x1au8; 32]),
);
},
));
Expand All @@ -355,7 +366,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
&token,
&VAULT_UNLOCK_LEDGER,
&VAULT_REFUND_AFTER,
&BytesN::from_array(env, &[12u8; 32]),
&BytesN::from_array(env, &[0x1du8; 32]),
);
env.ledger()
.with_mut(|li| li.sequence_number = VAULT_UNLOCK_LEDGER);
Expand All @@ -377,7 +388,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
&token,
&VAULT_UNLOCK_LEDGER,
&VAULT_REFUND_AFTER,
&BytesN::from_array(env, &[13u8; 32]),
&BytesN::from_array(env, &[0x35u8; 32]),
);
env.ledger()
.with_mut(|li| li.sequence_number = VAULT_REFUND_AFTER);
Expand All @@ -399,7 +410,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
&token,
&VAULT_UNLOCK_LEDGER,
&VAULT_REFUND_AFTER,
&BytesN::from_array(env, &[14u8; 32]),
&BytesN::from_array(env, &[0x4cu8; 32]),
);
env.ledger().with_mut(|li| {
li.sequence_number = VAULT_REFUND_AFTER + stealth_vault::DEFAULT_GRACE_PERIOD
Expand Down Expand Up @@ -482,7 +493,7 @@ pub fn collect_rows() -> std::vec::Vec<Row> {
for i in 0..count {
transfers.push_back(Transfer {
stealth_address: Address::generate(env),
ephemeral_pub_key: bytes(env, 32, i as u8),
ephemeral_pub_key: bytes(env, 32, valid_epk_fill(i as usize)),
amount: 100,
metadata: bytes(env, 32, i as u8),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4"
},
{
"bytes": "0101010101010101010101010101010101010101010101010101010101010101"
"bytes": "0606060606060606060606060606060606060606060606060606060606060606"
},
{
"bytes": "2a07"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4"
},
{
"bytes": "abababababababababababababababababababababababababababababababab"
"bytes": "1919191919191919191919191919191919191919191919191919191919191919"
},
{
"bytes": "02"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"symbol": "ephemeral_pub_key"
},
"val": {
"bytes": "0101010101010101010101010101010101010101010101010101010101010101"
"bytes": "0606060606060606060606060606060606060606060606060606060606060606"
}
},
{
Expand Down Expand Up @@ -122,7 +122,7 @@
"symbol": "ephemeral_pub_key"
},
"val": {
"bytes": "0202020202020202020202020202020202020202020202020202020202020202"
"bytes": "1919191919191919191919191919191919191919191919191919191919191919"
}
},
{
Expand Down Expand Up @@ -161,7 +161,7 @@
"symbol": "ephemeral_pub_key"
},
"val": {
"bytes": "0303030303030303030303030303030303030303030303030303030303030303"
"bytes": "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOLZM"
},
{
"bytes": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
"bytes": "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a"
},
{
"bytes": "07"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"bytes": "0101010101010101010101010101010101010101010101010101010101010101"
},
{
"bytes": "0202020202020202020202020202020202020202020202020202020202020202"
"bytes": "0303030303030303030303030303030303030303030303030303030303030303"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@
{
"vec": [
{
"bytes": "0101010101010101010101010101010101010101010101010101010101010101"
"bytes": "0606060606060606060606060606060606060606060606060606060606060606"
},
{
"bytes": "0202020202020202020202020202020202020202020202020202020202020202"
"bytes": "1919191919191919191919191919191919191919191919191919191919191919"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4"
},
{
"bytes": "0202020202020202020202020202020202020202020202020202020202020202"
"bytes": "0606060606060606060606060606060606060606060606060606060606060606"
},
{
"bytes": "0000000000000000000000000000000000000000000000000000000000000000"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@
{
"vec": [
{
"bytes": "2121212121212121212121212121212121212121212121212121212121212121"
"bytes": "1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a"
},
{
"bytes": "2222222222222222222222222222222222222222222222222222222222222222"
"bytes": "1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d"
}
]
},
Expand Down Expand Up @@ -270,7 +270,7 @@
"symbol": "ephemeral_pub_key"
},
"val": {
"bytes": "3131313131313131313131313131313131313131313131313131313131313131"
"bytes": "0606060606060606060606060606060606060606060606060606060606060606"
}
},
{
Expand Down Expand Up @@ -309,7 +309,7 @@
"symbol": "ephemeral_pub_key"
},
"val": {
"bytes": "3232323232323232323232323232323232323232323232323232323232323232"
"bytes": "1919191919191919191919191919191919191919191919191919191919191919"
}
},
{
Expand Down Expand Up @@ -1400,7 +1400,7 @@
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYRE5"
},
{
"bytes": "3131313131313131313131313131313131313131313131313131313131313131"
"bytes": "0606060606060606060606060606060606060606060606060606060606060606"
},
{
"bytes": "07"
Expand Down Expand Up @@ -1471,7 +1471,7 @@
"address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2ZMN"
},
{
"bytes": "3232323232323232323232323232323232323232323232323232323232323232"
"bytes": "1919191919191919191919191919191919191919191919191919191919191919"
},
{
"bytes": "c8"
Expand Down
18 changes: 9 additions & 9 deletions stellar/integration-tests/tests/chaos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn announcer_announce_through_chaos() {
let contract_id = env.register(StealthAnnouncerContract, ());
let client = StealthAnnouncerContractClient::new(&env, &contract_id);
let stealth_address = Address::generate(&env);
let epk = bytes32(&env, &[1u8; 32]);
let epk = bytes32(&env, &[0x06u8; 32]);
let metadata = bytes(&env, &[42u8, 7u8]);
client.announce(&STELLAR_V2_SCHEME_ID, &stealth_address, &epk, &metadata);
Ok::<_, harness::ChaosError>(())
Expand All @@ -133,7 +133,7 @@ fn announcer_multiple_schemes_through_chaos() {
let contract_id = env.register(StealthAnnouncerContract, ());
let client = StealthAnnouncerContractClient::new(&env, &contract_id);
let addr = Address::generate(&env);
let epk = bytes32(&env, &[0xab; 32]);
let epk = bytes32(&env, &[0x19u8; 32]);
let meta = bytes(&env, &[0x01]);
client.announce(&STELLAR_V2_SCHEME_ID, &addr, &epk, &meta);
client.announce(&STELLAR_V2_SCHEME_ID, &addr, &epk, &bytes(&env, &[0x02]));
Expand Down Expand Up @@ -244,7 +244,7 @@ fn sender_batch_send_through_chaos() {
let stealth1 = Address::generate(&env);
let stealth2 = Address::generate(&env);
let epk1 = bytes32(&env, &[1u8; 32]);
let epk2 = bytes32(&env, &[2u8; 32]);
let epk2 = bytes32(&env, &[3u8; 32]);
let meta1 = bytes(&env, &[10u8]);
let meta2 = bytes(&env, &[20u8]);
let addresses = soroban_sdk::vec![&env, stealth1.clone(), stealth2.clone()];
Expand Down Expand Up @@ -416,7 +416,7 @@ fn sender_announcer_lifecycle_through_chaos() {
client.init(&announcer_id, &None, &None, &0, &admin);
let (token, sender_addr) = funded_token(&env);
let stealth = Address::generate(&env);
let epk = bytes32(&env, &[0xff; 32]);
let epk = bytes32(&env, &[0x1au8; 32]);
let meta = bytes(&env, &[0x07]);
client.send(
&sender_addr,
Expand Down Expand Up @@ -646,8 +646,8 @@ fn splitter_create_and_fund_through_chaos() {
let stealth_addrs = soroban_sdk::vec![&env, stealth1.clone(), stealth2.clone()];
let epks = soroban_sdk::vec![
&env,
bytes32(&env, &[0x01u8; 32]),
bytes32(&env, &[0x02u8; 32])
bytes32(&env, &[0x06u8; 32]),
bytes32(&env, &[0x19u8; 32])
];
let metadatas = soroban_sdk::vec![&env, bytes(&env, &[0x01]), bytes(&env, &[0x02])];

Expand Down Expand Up @@ -722,19 +722,19 @@ fn batch_sender_batch_send_through_chaos() {
let mut transfers = soroban_sdk::vec![&env];
transfers.push_back(Transfer {
stealth_address: stealth1.clone(),
ephemeral_pub_key: bytes(&env, &[0x01u8; 32]),
ephemeral_pub_key: bytes(&env, &[0x06u8; 32]),
amount: 100,
metadata: bytes(&env, &[0x01]),
});
transfers.push_back(Transfer {
stealth_address: stealth2.clone(),
ephemeral_pub_key: bytes(&env, &[0x02u8; 32]),
ephemeral_pub_key: bytes(&env, &[0x19u8; 32]),
amount: 200,
metadata: bytes(&env, &[0x02]),
});
transfers.push_back(Transfer {
stealth_address: stealth3.clone(),
ephemeral_pub_key: bytes(&env, &[0x03u8; 32]),
ephemeral_pub_key: bytes(&env, &[0x1au8; 32]),
amount: 300,
metadata: bytes(&env, &[0x03]),
});
Expand Down
Loading
Loading