Skip to content

Commit

Permalink
Merge pull request #39 from BP-WG/fix/37
Browse files Browse the repository at this point in the history
Fix for tapret Baid58 decoding
  • Loading branch information
dr-orlovsky authored Apr 28, 2023
2 parents e27a4db + 0a6b766 commit a6b1baf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
28 changes: 20 additions & 8 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ edition = "2021"
license = "Apache-2.0"

[workspace.dependencies]
amplify = "4.0.0-beta.22"
strict_encoding = "2.0.0"
amplify = "4.0.0"
strict_encoding = "2.1.1"
commit_verify = "0.10.0"
single_use_seals = "0.10.0"

Expand Down
15 changes: 10 additions & 5 deletions dbc/src/tapret/tapscript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ impl StrictDeserialize for TapretCommitment {}

impl From<[u8; 33]> for TapretCommitment {
fn from(value: [u8; 33]) -> Self {
Self::from_strict_serialized::<33>(
Confined::try_from_iter(value).expect("exact size match"),
)
.expect("exact size match")
let buf = Confined::try_from_iter(value).expect("exact size match");
Self::from_strict_serialized::<33>(buf).expect("exact size match")
}
}

Expand Down Expand Up @@ -135,8 +133,15 @@ mod test {
pub fn commiment_serialization() {
let commitment = commitment();
let script = TapScript::commit(&commitment);
eprintln!("{script:x}");
assert_eq!(script[63], commitment.nonce);
assert_eq!(&script[31..63], commitment.mpc.as_slice());
}

#[test]
pub fn tapret_commitment_baid58() {
let commitment = commitment();
let encoded = commitment.to_baid58();
let decoded = TapretCommitment::from_baid58(encoded).unwrap();
assert_eq!(decoded, commitment);
}
}

0 comments on commit a6b1baf

Please sign in to comment.