Skip to content

Commit

Permalink
Remove use of sha256d in signature algorithm (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jun 24, 2022
1 parent 2561655 commit 8a96932
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use {
blockdata::constants::COIN_VALUE, consensus::Decodable, consensus::Encodable,
util::key::PrivateKey, Address, Block, BlockHash, Network, OutPoint, Transaction, Txid,
},
bitcoin_hashes::{sha256, sha256d, Hash, HashEngine},
bitcoin_hashes::{sha256, Hash, HashEngine},
chrono::{DateTime, NaiveDateTime, Utc},
clap::Parser,
derive_more::{Display, FromStr},
Expand Down
8 changes: 4 additions & 4 deletions src/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ impl Nft {
public_key,
};

let mut engine = sha256d::Hash::engine();
let mut engine = sha256::Hash::engine();
engine.input(ORDINAL_MESSAGE_PREFIX);
engine.input(&serde_cbor::to_vec(&metadata)?);

let message_hash = secp256k1::Message::from_slice(&sha256d::Hash::from_engine(engine))?;
let message_hash = secp256k1::Message::from_slice(&sha256::Hash::from_engine(engine))?;

let signature = signing_key_pair.sign_schnorr(message_hash);

Expand Down Expand Up @@ -72,11 +72,11 @@ impl Nft {
return Err(anyhow!("NFT data hash does not match actual data_hash"));
}

let mut engine = sha256d::Hash::engine();
let mut engine = sha256::Hash::engine();
engine.input(ORDINAL_MESSAGE_PREFIX);
engine.input(&serde_cbor::to_vec(&nft.metadata)?);

let message_hash = secp256k1::Message::from_slice(&sha256d::Hash::from_engine(engine))?;
let message_hash = secp256k1::Message::from_slice(&sha256::Hash::from_engine(engine))?;

Secp256k1::new()
.verify_schnorr(&nft.signature, &message_hash, &nft.metadata.public_key)
Expand Down

0 comments on commit 8a96932

Please sign in to comment.