mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-05 23:03:06 +00:00
fix
This commit is contained in:
parent
5bc1c9c688
commit
a5d0c27d6b
@ -37,9 +37,12 @@ impl AddressKeyHolder {
|
|||||||
let nullifer_public_key = utxo_secret_key_holder.generate_nullifier_public_key();
|
let nullifer_public_key = utxo_secret_key_holder.generate_nullifier_public_key();
|
||||||
let viewing_public_key = utxo_secret_key_holder.generate_viewing_public_key();
|
let viewing_public_key = utxo_secret_key_holder.generate_viewing_public_key();
|
||||||
|
|
||||||
let pub_account_signing_key = {
|
let mut rng = OsRng;
|
||||||
let mut rng = OsRng;
|
let pub_account_signing_key = loop {
|
||||||
nssa::PrivateKey::new(rng.gen())
|
match nssa::PrivateKey::try_new(rng.gen()) {
|
||||||
|
Ok(key) => break key,
|
||||||
|
Err(_) => continue,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@ -330,9 +333,12 @@ mod tests {
|
|||||||
let nullifer_public_key = utxo_secret_key_holder.generate_nullifier_public_key();
|
let nullifer_public_key = utxo_secret_key_holder.generate_nullifier_public_key();
|
||||||
let viewing_public_key = utxo_secret_key_holder.generate_viewing_public_key();
|
let viewing_public_key = utxo_secret_key_holder.generate_viewing_public_key();
|
||||||
|
|
||||||
let pub_account_signing_key = {
|
let mut rng = OsRng;
|
||||||
let mut rng = OsRng;
|
let pub_account_signing_key = loop {
|
||||||
nssa::PrivateKey::new(rng.gen())
|
match nssa::PrivateKey::try_new(rng.gen()) {
|
||||||
|
Ok(key) => break key,
|
||||||
|
Err(_) => continue,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let public_key = nssa::PublicKey::new(&pub_account_signing_key);
|
let public_key = nssa::PublicKey::new(&pub_account_signing_key);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ pub fn produce_dummy_empty_transaction() -> nssa::PublicTransaction {
|
|||||||
let instruction_data = 0;
|
let instruction_data = 0;
|
||||||
let message =
|
let message =
|
||||||
nssa::public_transaction::Message::try_new(program_id, addresses, nonces, instruction_data).unwrap();
|
nssa::public_transaction::Message::try_new(program_id, addresses, nonces, instruction_data).unwrap();
|
||||||
let private_key = nssa::PrivateKey::new(1);
|
let private_key = nssa::PrivateKey::try_new([1; 32]).unwrap();
|
||||||
let witness_set = nssa::public_transaction::WitnessSet::for_message(&message, &[&private_key]);
|
let witness_set = nssa::public_transaction::WitnessSet::for_message(&message, &[&private_key]);
|
||||||
nssa::PublicTransaction::new(message, witness_set)
|
nssa::PublicTransaction::new(message, witness_set)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ impl WitnessSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_valid_for(&self, message: &Message) -> bool {
|
pub fn is_valid_for(&self, message: &Message) -> bool {
|
||||||
let message_bytes = message.message_to_bytes();
|
let message_bytes = message.message_to_bytes();
|
||||||
for (signature, public_key) in self.iter_signatures() {
|
for (signature, public_key) in self.iter_signatures() {
|
||||||
if !signature.is_valid_for(&message_bytes, &public_key) {
|
if !signature.is_valid_for(&message_bytes, &public_key) {
|
||||||
|
|||||||
@ -62,11 +62,7 @@ impl SequencerCore {
|
|||||||
tx: nssa::PublicTransaction,
|
tx: nssa::PublicTransaction,
|
||||||
) -> Result<nssa::PublicTransaction, TransactionMalformationErrorKind> {
|
) -> Result<nssa::PublicTransaction, TransactionMalformationErrorKind> {
|
||||||
// Stateless checks here
|
// Stateless checks here
|
||||||
if tx
|
if tx.witness_set().is_valid_for(tx.message()) {
|
||||||
.witness_set()
|
|
||||||
.iter_signatures()
|
|
||||||
.all(|(signature, public_key)| signature.is_valid_for(tx.message(), public_key))
|
|
||||||
{
|
|
||||||
Ok(tx)
|
Ok(tx)
|
||||||
} else {
|
} else {
|
||||||
Err(TransactionMalformationErrorKind::InvalidSignature)
|
Err(TransactionMalformationErrorKind::InvalidSignature)
|
||||||
@ -188,11 +184,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_signing_key_for_account1() -> nssa::PrivateKey {
|
fn create_signing_key_for_account1() -> nssa::PrivateKey {
|
||||||
nssa::PrivateKey::new(1)
|
nssa::PrivateKey::try_new([1; 32]).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_signing_key_for_account2() -> nssa::PrivateKey {
|
fn create_signing_key_for_account2() -> nssa::PrivateKey {
|
||||||
nssa::PrivateKey::new(2)
|
nssa::PrivateKey::try_new([2; 32]).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn common_setup(sequencer: &mut SequencerCore) {
|
fn common_setup(sequencer: &mut SequencerCore) {
|
||||||
|
|||||||
@ -261,7 +261,7 @@ mod tests {
|
|||||||
let mut sequencer_core = SequencerCore::start_from_config(config);
|
let mut sequencer_core = SequencerCore::start_from_config(config);
|
||||||
let initial_accounts = sequencer_core.sequencer_config.initial_accounts.clone();
|
let initial_accounts = sequencer_core.sequencer_config.initial_accounts.clone();
|
||||||
|
|
||||||
let signing_key = nssa::PrivateKey::new(1);
|
let signing_key = nssa::PrivateKey::try_new([1; 32]).unwrap();
|
||||||
let balance_to_move = 10;
|
let balance_to_move = 10;
|
||||||
let tx = common::test_utils::create_transaction_native_token_transfer(
|
let tx = common::test_utils::create_transaction_native_token_transfer(
|
||||||
[1; 32],
|
[1; 32],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user