13
13
check_program_account,
14
14
extension:: confidential_transfer:: { ciphertext_extraction:: SourceDecryptHandles , * } ,
15
15
instruction:: { encode_instruction, TokenInstruction } ,
16
- proof:: ProofLocation ,
16
+ proof:: { ProofData , ProofLocation } ,
17
17
} ,
18
18
bytemuck:: Zeroable , // `Pod` comes from zk_token_proof_instruction
19
19
num_enum:: { IntoPrimitive , TryFromPrimitive } ,
@@ -90,7 +90,9 @@ pub enum ConfidentialTransferInstruction {
90
90
/// in the same transaction or context state account if
91
91
/// `VerifyPubkeyValidityProof` is pre-verified into a context state
92
92
/// account.
93
- /// 3. `[signer]` The single source account owner.
93
+ /// 3. `[]` (Optional) Record account if the accompanying proof is to be
94
+ /// read from a record account.
95
+ /// 4. `[signer]` The single source account owner.
94
96
///
95
97
/// * Multisignature owner/delegate
96
98
/// 0. `[writeable]` The SPL Token account.
@@ -99,8 +101,10 @@ pub enum ConfidentialTransferInstruction {
99
101
/// in the same transaction or context state account if
100
102
/// `VerifyPubkeyValidityProof` is pre-verified into a context state
101
103
/// account.
102
- /// 3. `[]` The multisig source account owner.
103
- /// 4.. `[signer]` Required M signer accounts for the SPL Token Multisig
104
+ /// 3. `[]` (Optional) Record account if the accompanying proof is to be
105
+ /// read from a record account.
106
+ /// 4. `[]` The multisig source account owner.
107
+ /// 5.. `[signer]` Required M signer accounts for the SPL Token Multisig
104
108
/// account.
105
109
///
106
110
/// Data expected by this instruction:
@@ -151,16 +155,20 @@ pub enum ConfidentialTransferInstruction {
151
155
/// the same transaction or context state account if
152
156
/// `VerifyZeroBalanceProof` is pre-verified into a context state
153
157
/// account.
154
- /// 2. `[signer]` The single account owner.
158
+ /// 2. `[]` (Optional) Record account if the accompanying proof is to be
159
+ /// read from a record account.
160
+ /// 3. `[signer]` The single account owner.
155
161
///
156
162
/// * Multisignature owner/delegate
157
163
/// 0. `[writable]` The SPL Token account.
158
164
/// 1. `[]` Instructions sysvar if `VerifyZeroBalanceProof` is included in
159
165
/// the same transaction or context state account if
160
166
/// `VerifyZeroBalanceProof` is pre-verified into a context state
161
167
/// account.
162
- /// 2. `[]` The multisig account owner.
163
- /// 3.. `[signer]` Required M signer accounts for the SPL Token Multisig
168
+ /// 2. `[]` (Optional) Record account if the accompanying proof is to be
169
+ /// read from a record account.
170
+ /// 3. `[]` The multisig account owner.
171
+ /// 4.. `[signer]` Required M signer accounts for the SPL Token Multisig
164
172
/// account.
165
173
///
166
174
/// Data expected by this instruction:
@@ -214,16 +222,20 @@ pub enum ConfidentialTransferInstruction {
214
222
/// 2. `[]` Instructions sysvar if `VerifyWithdraw` is included in the
215
223
/// same transaction or context state account if `VerifyWithdraw` is
216
224
/// pre-verified into a context state account.
217
- /// 3. `[signer]` The single source account owner.
225
+ /// 3. `[]` (Optional) Record account if the accompanying proof is to be
226
+ /// read from a record account.
227
+ /// 4. `[signer]` The single source account owner.
218
228
///
219
229
/// * Multisignature owner/delegate
220
230
/// 0. `[writable]` The SPL Token account.
221
231
/// 1. `[]` The token mint.
222
232
/// 2. `[]` Instructions sysvar if `VerifyWithdraw` is included in the
223
233
/// same transaction or context state account if `VerifyWithdraw` is
224
234
/// pre-verified into a context state account.
225
- /// 3. `[]` The multisig source account owner.
226
- /// 4.. `[signer]` Required M signer accounts for the SPL Token Multisig
235
+ /// 3. `[]` (Optional) Record account if the accompanying proof is to be
236
+ /// read from a record account.
237
+ /// 4. `[]` The multisig source account owner.
238
+ /// 5.. `[signer]` Required M signer accounts for the SPL Token Multisig
227
239
/// account.
228
240
///
229
241
/// Data expected by this instruction:
@@ -248,7 +260,9 @@ pub enum ConfidentialTransferInstruction {
248
260
/// `VerifyTransferWithFee` is included in the same transaction or
249
261
/// context state account if these proofs are pre-verified into a
250
262
/// context state account.
251
- /// 5. `[signer]` The single source account owner.
263
+ /// 5. `[]` (Optional) Record account if the accompanying proof is to be
264
+ /// read from a record account.
265
+ /// 6. `[signer]` The single source account owner.
252
266
///
253
267
/// * Multisignature owner/delegate
254
268
/// 1. `[writable]` The source SPL Token account.
@@ -258,8 +272,10 @@ pub enum ConfidentialTransferInstruction {
258
272
/// `VerifyTransferWithFee` is included in the same transaction or
259
273
/// context state account if these proofs are pre-verified into a
260
274
/// context state account.
261
- /// 5. `[]` The multisig source account owner.
262
- /// 6.. `[signer]` Required M signer accounts for the SPL Token Multisig
275
+ /// 5. `[]` (Optional) Record account if the accompanying proof is to be
276
+ /// read from a record account.
277
+ /// 6. `[]` The multisig source account owner.
278
+ /// 7.. `[signer]` Required M signer accounts for the SPL Token Multisig
263
279
/// account.
264
280
///
265
281
/// Data expected by this instruction:
@@ -715,8 +731,11 @@ pub fn inner_configure_account(
715
731
] ;
716
732
717
733
let proof_instruction_offset = match proof_data_location {
718
- ProofLocation :: InstructionOffset ( proof_instruction_offset, _ ) => {
734
+ ProofLocation :: InstructionOffset ( proof_instruction_offset, proof_data ) => {
719
735
accounts. push ( AccountMeta :: new_readonly ( sysvar:: instructions:: id ( ) , false ) ) ;
736
+ if let ProofData :: RecordAccount ( record_address, _) = proof_data {
737
+ accounts. push ( AccountMeta :: new_readonly ( * record_address, false ) ) ;
738
+ }
720
739
proof_instruction_offset. into ( )
721
740
}
722
741
ProofLocation :: ContextStateAccount ( context_state_account) => {
@@ -781,8 +800,14 @@ pub fn configure_account(
781
800
if proof_instruction_offset != 1 {
782
801
return Err ( TokenError :: InvalidProofInstructionOffset . into ( ) ) ;
783
802
}
784
- instructions. push ( verify_pubkey_validity ( None , proof_data) ) ;
785
- } ;
803
+ match proof_data {
804
+ ProofData :: ProofData ( data) => instructions. push ( verify_pubkey_validity ( None , data) ) ,
805
+ ProofData :: RecordAccount ( address, offset) => instructions. push (
806
+ ProofInstruction :: VerifyPubkeyValidity
807
+ . encode_verify_proof_from_account ( None , address, offset) ,
808
+ ) ,
809
+ } ;
810
+ }
786
811
787
812
Ok ( instructions)
788
813
}
@@ -827,8 +852,11 @@ pub fn inner_empty_account(
827
852
let mut accounts = vec ! [ AccountMeta :: new( * token_account, false ) ] ;
828
853
829
854
let proof_instruction_offset = match proof_data_location {
830
- ProofLocation :: InstructionOffset ( proof_instruction_offset, _ ) => {
855
+ ProofLocation :: InstructionOffset ( proof_instruction_offset, proof_data ) => {
831
856
accounts. push ( AccountMeta :: new_readonly ( sysvar:: instructions:: id ( ) , false ) ) ;
857
+ if let ProofData :: RecordAccount ( record_address, _) = proof_data {
858
+ accounts. push ( AccountMeta :: new_readonly ( * record_address, false ) ) ;
859
+ }
832
860
proof_instruction_offset. into ( )
833
861
}
834
862
ProofLocation :: ContextStateAccount ( context_state_account) => {
@@ -884,7 +912,13 @@ pub fn empty_account(
884
912
if proof_instruction_offset != 1 {
885
913
return Err ( TokenError :: InvalidProofInstructionOffset . into ( ) ) ;
886
914
}
887
- instructions. push ( verify_zero_balance ( None , proof_data) ) ;
915
+ match proof_data {
916
+ ProofData :: ProofData ( data) => instructions. push ( verify_zero_balance ( None , data) ) ,
917
+ ProofData :: RecordAccount ( address, offset) => instructions. push (
918
+ ProofInstruction :: VerifyZeroBalance
919
+ . encode_verify_proof_from_account ( None , address, offset) ,
920
+ ) ,
921
+ } ;
888
922
} ;
889
923
890
924
Ok ( instructions)
@@ -946,8 +980,11 @@ pub fn inner_withdraw(
946
980
] ;
947
981
948
982
let proof_instruction_offset = match proof_data_location {
949
- ProofLocation :: InstructionOffset ( proof_instruction_offset, _ ) => {
983
+ ProofLocation :: InstructionOffset ( proof_instruction_offset, proof_data ) => {
950
984
accounts. push ( AccountMeta :: new_readonly ( sysvar:: instructions:: id ( ) , false ) ) ;
985
+ if let ProofData :: RecordAccount ( record_address, _) = proof_data {
986
+ accounts. push ( AccountMeta :: new_readonly ( * record_address, false ) ) ;
987
+ }
951
988
proof_instruction_offset. into ( )
952
989
}
953
990
ProofLocation :: ContextStateAccount ( context_state_account) => {
@@ -1015,7 +1052,13 @@ pub fn withdraw(
1015
1052
if proof_instruction_offset != 1 {
1016
1053
return Err ( TokenError :: InvalidProofInstructionOffset . into ( ) ) ;
1017
1054
}
1018
- instructions. push ( verify_withdraw ( None , proof_data) ) ;
1055
+ match proof_data {
1056
+ ProofData :: ProofData ( data) => instructions. push ( verify_withdraw ( None , data) ) ,
1057
+ ProofData :: RecordAccount ( address, offset) => instructions. push (
1058
+ ProofInstruction :: VerifyWithdraw
1059
+ . encode_verify_proof_from_account ( None , address, offset) ,
1060
+ ) ,
1061
+ } ;
1019
1062
} ;
1020
1063
1021
1064
Ok ( instructions)
@@ -1043,8 +1086,11 @@ pub fn inner_transfer(
1043
1086
] ;
1044
1087
1045
1088
let proof_instruction_offset = match proof_data_location {
1046
- ProofLocation :: InstructionOffset ( proof_instruction_offset, _ ) => {
1089
+ ProofLocation :: InstructionOffset ( proof_instruction_offset, proof_data ) => {
1047
1090
accounts. push ( AccountMeta :: new_readonly ( sysvar:: instructions:: id ( ) , false ) ) ;
1091
+ if let ProofData :: RecordAccount ( record_address, _) = proof_data {
1092
+ accounts. push ( AccountMeta :: new_readonly ( * record_address, false ) ) ;
1093
+ }
1048
1094
proof_instruction_offset. into ( )
1049
1095
}
1050
1096
ProofLocation :: ContextStateAccount ( context_state_account) => {
@@ -1108,7 +1154,13 @@ pub fn transfer(
1108
1154
if proof_instruction_offset != 1 {
1109
1155
return Err ( TokenError :: InvalidProofInstructionOffset . into ( ) ) ;
1110
1156
}
1111
- instructions. push ( verify_transfer ( None , proof_data) ) ;
1157
+ match proof_data {
1158
+ ProofData :: ProofData ( data) => instructions. push ( verify_transfer ( None , data) ) ,
1159
+ ProofData :: RecordAccount ( address, offset) => instructions. push (
1160
+ ProofInstruction :: VerifyTransfer
1161
+ . encode_verify_proof_from_account ( None , address, offset) ,
1162
+ ) ,
1163
+ } ;
1112
1164
} ;
1113
1165
1114
1166
Ok ( instructions)
@@ -1136,8 +1188,11 @@ pub fn inner_transfer_with_fee(
1136
1188
] ;
1137
1189
1138
1190
let proof_instruction_offset = match proof_data_location {
1139
- ProofLocation :: InstructionOffset ( proof_instruction_offset, _ ) => {
1191
+ ProofLocation :: InstructionOffset ( proof_instruction_offset, proof_data ) => {
1140
1192
accounts. push ( AccountMeta :: new_readonly ( sysvar:: instructions:: id ( ) , false ) ) ;
1193
+ if let ProofData :: RecordAccount ( record_address, _) = proof_data {
1194
+ accounts. push ( AccountMeta :: new_readonly ( * record_address, false ) ) ;
1195
+ }
1141
1196
proof_instruction_offset. into ( )
1142
1197
}
1143
1198
ProofLocation :: ContextStateAccount ( context_state_account) => {
@@ -1201,7 +1256,13 @@ pub fn transfer_with_fee(
1201
1256
if proof_instruction_offset != 1 {
1202
1257
return Err ( TokenError :: InvalidProofInstructionOffset . into ( ) ) ;
1203
1258
}
1204
- instructions. push ( verify_transfer_with_fee ( None , proof_data) ) ;
1259
+ match proof_data {
1260
+ ProofData :: ProofData ( data) => instructions. push ( verify_transfer_with_fee ( None , data) ) ,
1261
+ ProofData :: RecordAccount ( address, offset) => instructions. push (
1262
+ ProofInstruction :: VerifyTransferWithFee
1263
+ . encode_verify_proof_from_account ( None , address, offset) ,
1264
+ ) ,
1265
+ } ;
1205
1266
} ;
1206
1267
1207
1268
Ok ( instructions)
0 commit comments