File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -96,15 +96,14 @@ impl Commitment {
96
96
}
97
97
98
98
/// 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
+ }
108
107
}
109
108
}
110
109
You can’t perform that action at this time.
0 commit comments