-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
1. Description
Double verification of Schnorr signatures causes a ReachedPrunedBranch error.
/// Verify Schnorr signature for dual oracle price attestation
/// Message format: SHA256(timestamp || price)
fn checksig_price_attestation(pk: Pubkey, timestamp: u32, price: u64, sig: Signature) {
let hasher: Ctx8 = jet::sha_256_ctx_8_init();
let hasher: Ctx8 = jet::sha_256_ctx_8_add_4(hasher, timestamp);
let hasher: Ctx8 = jet::sha_256_ctx_8_add_8(hasher, price);
let msg: u256 = jet::sha_256_ctx_8_finalize(hasher);
jet::bip_0340_verify((pk, msg), sig);
}
fn settlement_positive_path(
current_price: u64,
new_price: u64,
timestamp: u32,
amount: u64,
oracle_sig: Signature,
secondary_sig: Signature
) {
assert!(jet::eq_64(current_price, current_price));
assert!(jet::eq_64(new_price, new_price));
assert!(jet::eq_32(timestamp, timestamp));
assert!(jet::eq_64(amount, amount));
checksig_price_attestation(param::ORACLE_PK, timestamp, new_price, oracle_sig);
checksig_price_attestation(param::USER_PK, timestamp, new_price, secondary_sig);
}However, if comment out current_price and/or amount assertions, bug disappears.
The reproduction code includes both cases.
2. Steps to Reproduce
cargo test test_settlement_positive_dual_sig_bug Metadata
Metadata
Assignees
Labels
No labels