Skip to content

Commit 39b6a7e

Browse files
author
yeastplume
committed
Revert "fix from_pubkey function"
This reverts commit a5f08e3.
1 parent a5f08e3 commit 39b6a7e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/pedersen.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,14 @@ impl Commitment {
9696
}
9797

9898
/// Creates from a pubkey
99-
pub fn from_pubkey(secp: &Secp256k1, pk: &key::PublicKey) -> Result<Commitment, Error> {
100-
let mut commit_i = [0; constants::PEDERSEN_COMMITMENT_SIZE_INTERNAL];
101-
let res = unsafe {
102-
ffi::secp256k1_pubkey_to_pedersen_commitment(secp.ctx, commit_i.as_mut_ptr(), &pk.0 as *const _)
103-
};
104-
if res == 1 {
105-
Ok(secp.commit_ser(commit_i)?)
106-
} else {
107-
Err(InvalidCommit)
99+
pub fn from_pubkey(secp: &Secp256k1, pk: &key::PublicKey) -> Result<Self, Error> {
100+
unsafe {
101+
let mut commit = Self::blank();
102+
if ffi::secp256k1_pubkey_to_pedersen_commitment(secp.ctx, commit.as_mut_ptr(), &pk.0) == 1 {
103+
Ok(commit)
104+
} else {
105+
Err(InvalidCommit)
106+
}
108107
}
109108
}
110109

0 commit comments

Comments
 (0)