@@ -39,7 +39,7 @@ pub fn derive_private_key<T: secp256k1::Signing>(secp_ctx: &Secp256k1<T>, per_co
39
39
let res = Sha256 :: from_engine ( sha) . into_inner ( ) ;
40
40
41
41
let mut key = base_secret. clone ( ) ;
42
- key. add_assign ( & secp_ctx , & SecretKey :: from_slice ( & secp_ctx , & res) ? ) ?;
42
+ key. add_assign ( & res) ?;
43
43
Ok ( key)
44
44
}
45
45
@@ -49,8 +49,8 @@ pub fn derive_public_key<T: secp256k1::Signing>(secp_ctx: &Secp256k1<T>, per_com
49
49
sha. input ( & base_point. serialize ( ) ) ;
50
50
let res = Sha256 :: from_engine ( sha) . into_inner ( ) ;
51
51
52
- let hashkey = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & secp_ctx , & res) ?) ;
53
- base_point. combine ( & secp_ctx , & hashkey)
52
+ let hashkey = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & res) ?) ;
53
+ base_point. combine ( & hashkey)
54
54
}
55
55
56
56
/// Derives a revocation key from its constituent parts
@@ -63,21 +63,21 @@ pub fn derive_private_revocation_key<T: secp256k1::Signing>(secp_ctx: &Secp256k1
63
63
sha. input ( & revocation_base_point. serialize ( ) ) ;
64
64
sha. input ( & per_commitment_point. serialize ( ) ) ;
65
65
66
- SecretKey :: from_slice ( & secp_ctx , & Sha256 :: from_engine ( sha) . into_inner ( ) ) ?
66
+ Sha256 :: from_engine ( sha) . into_inner ( )
67
67
} ;
68
68
let commit_append_rev_hash_key = {
69
69
let mut sha = Sha256 :: engine ( ) ;
70
70
sha. input ( & per_commitment_point. serialize ( ) ) ;
71
71
sha. input ( & revocation_base_point. serialize ( ) ) ;
72
72
73
- SecretKey :: from_slice ( & secp_ctx , & Sha256 :: from_engine ( sha) . into_inner ( ) ) ?
73
+ Sha256 :: from_engine ( sha) . into_inner ( )
74
74
} ;
75
75
76
76
let mut part_a = revocation_base_secret. clone ( ) ;
77
- part_a. mul_assign ( & secp_ctx , & rev_append_commit_hash_key) ?;
77
+ part_a. mul_assign ( & rev_append_commit_hash_key) ?;
78
78
let mut part_b = per_commitment_secret. clone ( ) ;
79
- part_b. mul_assign ( & secp_ctx , & commit_append_rev_hash_key) ?;
80
- part_a. add_assign ( & secp_ctx , & part_b) ?;
79
+ part_b. mul_assign ( & commit_append_rev_hash_key) ?;
80
+ part_a. add_assign ( & part_b[ .. ] ) ?;
81
81
Ok ( part_a)
82
82
}
83
83
@@ -87,21 +87,21 @@ pub fn derive_public_revocation_key<T: secp256k1::Verification>(secp_ctx: &Secp2
87
87
sha. input ( & revocation_base_point. serialize ( ) ) ;
88
88
sha. input ( & per_commitment_point. serialize ( ) ) ;
89
89
90
- SecretKey :: from_slice ( & secp_ctx , & Sha256 :: from_engine ( sha) . into_inner ( ) ) ?
90
+ Sha256 :: from_engine ( sha) . into_inner ( )
91
91
} ;
92
92
let commit_append_rev_hash_key = {
93
93
let mut sha = Sha256 :: engine ( ) ;
94
94
sha. input ( & per_commitment_point. serialize ( ) ) ;
95
95
sha. input ( & revocation_base_point. serialize ( ) ) ;
96
96
97
- SecretKey :: from_slice ( & secp_ctx , & Sha256 :: from_engine ( sha) . into_inner ( ) ) ?
97
+ Sha256 :: from_engine ( sha) . into_inner ( )
98
98
} ;
99
99
100
100
let mut part_a = revocation_base_point. clone ( ) ;
101
101
part_a. mul_assign ( & secp_ctx, & rev_append_commit_hash_key) ?;
102
102
let mut part_b = per_commitment_point. clone ( ) ;
103
103
part_b. mul_assign ( & secp_ctx, & commit_append_rev_hash_key) ?;
104
- part_a. combine ( & secp_ctx , & part_b)
104
+ part_a. combine ( & part_b)
105
105
}
106
106
107
107
pub struct TxCreationKeys {
@@ -129,15 +129,15 @@ impl TxCreationKeys {
129
129
/// Gets the "to_local" output redeemscript, ie the script which is time-locked or spendable by
130
130
/// the revocation key
131
131
pub fn get_revokeable_redeemscript ( revocation_key : & PublicKey , to_self_delay : u16 , delayed_payment_key : & PublicKey ) -> Script {
132
- Builder :: new ( ) . push_opcode ( opcodes:: All :: OP_IF )
132
+ Builder :: new ( ) . push_opcode ( opcodes:: all :: OP_IF )
133
133
. push_slice ( & revocation_key. serialize ( ) )
134
- . push_opcode ( opcodes:: All :: OP_ELSE )
134
+ . push_opcode ( opcodes:: all :: OP_ELSE )
135
135
. push_int ( to_self_delay as i64 )
136
136
. push_opcode ( opcodes:: OP_CSV )
137
- . push_opcode ( opcodes:: All :: OP_DROP )
137
+ . push_opcode ( opcodes:: all :: OP_DROP )
138
138
. push_slice ( & delayed_payment_key. serialize ( ) )
139
- . push_opcode ( opcodes:: All :: OP_ENDIF )
140
- . push_opcode ( opcodes:: All :: OP_CHECKSIG )
139
+ . push_opcode ( opcodes:: all :: OP_ENDIF )
140
+ . push_opcode ( opcodes:: all :: OP_CHECKSIG )
141
141
. into_script ( )
142
142
}
143
143
@@ -154,63 +154,63 @@ pub struct HTLCOutputInCommitment {
154
154
pub fn get_htlc_redeemscript_with_explicit_keys ( htlc : & HTLCOutputInCommitment , a_htlc_key : & PublicKey , b_htlc_key : & PublicKey , revocation_key : & PublicKey ) -> Script {
155
155
let payment_hash160 = Ripemd160 :: hash ( & htlc. payment_hash . 0 [ ..] ) . into_inner ( ) ;
156
156
if htlc. offered {
157
- Builder :: new ( ) . push_opcode ( opcodes:: All :: OP_DUP )
158
- . push_opcode ( opcodes:: All :: OP_HASH160 )
157
+ Builder :: new ( ) . push_opcode ( opcodes:: all :: OP_DUP )
158
+ . push_opcode ( opcodes:: all :: OP_HASH160 )
159
159
. push_slice ( & Hash160 :: hash ( & revocation_key. serialize ( ) ) [ ..] )
160
- . push_opcode ( opcodes:: All :: OP_EQUAL )
161
- . push_opcode ( opcodes:: All :: OP_IF )
162
- . push_opcode ( opcodes:: All :: OP_CHECKSIG )
163
- . push_opcode ( opcodes:: All :: OP_ELSE )
160
+ . push_opcode ( opcodes:: all :: OP_EQUAL )
161
+ . push_opcode ( opcodes:: all :: OP_IF )
162
+ . push_opcode ( opcodes:: all :: OP_CHECKSIG )
163
+ . push_opcode ( opcodes:: all :: OP_ELSE )
164
164
. push_slice ( & b_htlc_key. serialize ( ) [ ..] )
165
- . push_opcode ( opcodes:: All :: OP_SWAP )
166
- . push_opcode ( opcodes:: All :: OP_SIZE )
165
+ . push_opcode ( opcodes:: all :: OP_SWAP )
166
+ . push_opcode ( opcodes:: all :: OP_SIZE )
167
167
. push_int ( 32 )
168
- . push_opcode ( opcodes:: All :: OP_EQUAL )
169
- . push_opcode ( opcodes:: All :: OP_NOTIF )
170
- . push_opcode ( opcodes:: All :: OP_DROP )
168
+ . push_opcode ( opcodes:: all :: OP_EQUAL )
169
+ . push_opcode ( opcodes:: all :: OP_NOTIF )
170
+ . push_opcode ( opcodes:: all :: OP_DROP )
171
171
. push_int ( 2 )
172
- . push_opcode ( opcodes:: All :: OP_SWAP )
172
+ . push_opcode ( opcodes:: all :: OP_SWAP )
173
173
. push_slice ( & a_htlc_key. serialize ( ) [ ..] )
174
174
. push_int ( 2 )
175
- . push_opcode ( opcodes:: All :: OP_CHECKMULTISIG )
176
- . push_opcode ( opcodes:: All :: OP_ELSE )
177
- . push_opcode ( opcodes:: All :: OP_HASH160 )
175
+ . push_opcode ( opcodes:: all :: OP_CHECKMULTISIG )
176
+ . push_opcode ( opcodes:: all :: OP_ELSE )
177
+ . push_opcode ( opcodes:: all :: OP_HASH160 )
178
178
. push_slice ( & payment_hash160)
179
- . push_opcode ( opcodes:: All :: OP_EQUALVERIFY )
180
- . push_opcode ( opcodes:: All :: OP_CHECKSIG )
181
- . push_opcode ( opcodes:: All :: OP_ENDIF )
182
- . push_opcode ( opcodes:: All :: OP_ENDIF )
179
+ . push_opcode ( opcodes:: all :: OP_EQUALVERIFY )
180
+ . push_opcode ( opcodes:: all :: OP_CHECKSIG )
181
+ . push_opcode ( opcodes:: all :: OP_ENDIF )
182
+ . push_opcode ( opcodes:: all :: OP_ENDIF )
183
183
. into_script ( )
184
184
} else {
185
- Builder :: new ( ) . push_opcode ( opcodes:: All :: OP_DUP )
186
- . push_opcode ( opcodes:: All :: OP_HASH160 )
185
+ Builder :: new ( ) . push_opcode ( opcodes:: all :: OP_DUP )
186
+ . push_opcode ( opcodes:: all :: OP_HASH160 )
187
187
. push_slice ( & Hash160 :: hash ( & revocation_key. serialize ( ) ) [ ..] )
188
- . push_opcode ( opcodes:: All :: OP_EQUAL )
189
- . push_opcode ( opcodes:: All :: OP_IF )
190
- . push_opcode ( opcodes:: All :: OP_CHECKSIG )
191
- . push_opcode ( opcodes:: All :: OP_ELSE )
188
+ . push_opcode ( opcodes:: all :: OP_EQUAL )
189
+ . push_opcode ( opcodes:: all :: OP_IF )
190
+ . push_opcode ( opcodes:: all :: OP_CHECKSIG )
191
+ . push_opcode ( opcodes:: all :: OP_ELSE )
192
192
. push_slice ( & b_htlc_key. serialize ( ) [ ..] )
193
- . push_opcode ( opcodes:: All :: OP_SWAP )
194
- . push_opcode ( opcodes:: All :: OP_SIZE )
193
+ . push_opcode ( opcodes:: all :: OP_SWAP )
194
+ . push_opcode ( opcodes:: all :: OP_SIZE )
195
195
. push_int ( 32 )
196
- . push_opcode ( opcodes:: All :: OP_EQUAL )
197
- . push_opcode ( opcodes:: All :: OP_IF )
198
- . push_opcode ( opcodes:: All :: OP_HASH160 )
196
+ . push_opcode ( opcodes:: all :: OP_EQUAL )
197
+ . push_opcode ( opcodes:: all :: OP_IF )
198
+ . push_opcode ( opcodes:: all :: OP_HASH160 )
199
199
. push_slice ( & payment_hash160)
200
- . push_opcode ( opcodes:: All :: OP_EQUALVERIFY )
200
+ . push_opcode ( opcodes:: all :: OP_EQUALVERIFY )
201
201
. push_int ( 2 )
202
- . push_opcode ( opcodes:: All :: OP_SWAP )
202
+ . push_opcode ( opcodes:: all :: OP_SWAP )
203
203
. push_slice ( & a_htlc_key. serialize ( ) [ ..] )
204
204
. push_int ( 2 )
205
- . push_opcode ( opcodes:: All :: OP_CHECKMULTISIG )
206
- . push_opcode ( opcodes:: All :: OP_ELSE )
207
- . push_opcode ( opcodes:: All :: OP_DROP )
205
+ . push_opcode ( opcodes:: all :: OP_CHECKMULTISIG )
206
+ . push_opcode ( opcodes:: all :: OP_ELSE )
207
+ . push_opcode ( opcodes:: all :: OP_DROP )
208
208
. push_int ( htlc. cltv_expiry as i64 )
209
209
. push_opcode ( opcodes:: OP_CLTV )
210
- . push_opcode ( opcodes:: All :: OP_DROP )
211
- . push_opcode ( opcodes:: All :: OP_CHECKSIG )
212
- . push_opcode ( opcodes:: All :: OP_ENDIF )
213
- . push_opcode ( opcodes:: All :: OP_ENDIF )
210
+ . push_opcode ( opcodes:: all :: OP_DROP )
211
+ . push_opcode ( opcodes:: all :: OP_CHECKSIG )
212
+ . push_opcode ( opcodes:: all :: OP_ENDIF )
213
+ . push_opcode ( opcodes:: all :: OP_ENDIF )
214
214
. into_script ( )
215
215
}
216
216
}
0 commit comments