5
5
using System . Runtime . CompilerServices ;
6
6
using System . Text ;
7
7
using System . Text . RegularExpressions ;
8
+ using AElf . Cryptography . Bn254 ;
9
+ using AElf . Cryptography . EdDSA ;
10
+ using AElf . Cryptography . Keccak ;
8
11
using AElf . Cryptography . SecretSharing ;
9
12
using AElf . CSharp . Core ;
10
13
using AElf . Kernel . SmartContract ;
@@ -50,7 +53,6 @@ private void WhitelistAssemblies(Whitelist whitelist)
50
53
. Assembly ( typeof ( SecretSharingHelper ) . Assembly , Trust . Partial ) // AElf.Cryptography
51
54
. Assembly ( typeof ( ISmartContractBridgeContext ) . Assembly , Trust . Full ) // AElf.Kernel.SmartContract.Shared
52
55
. Assembly ( typeof ( Groth16 . Net . Verifier ) . Assembly , Trust . Full ) // AElf.Cryptography.ECDSA
53
- . Assembly ( typeof ( Poseidon . Net . Poseidon ) . Assembly , Trust . Full )
54
56
;
55
57
}
56
58
@@ -64,6 +66,15 @@ private void WhitelistSystemTypes(Whitelist whitelist)
64
66
. Type ( "Func`1" , Permission . Allowed ) // Required for protobuf generated code
65
67
. Type ( "Func`2" , Permission . Allowed ) // Required for protobuf generated code
66
68
. Type ( "Func`3" , Permission . Allowed ) // Required for protobuf generated code
69
+ . Type ( "Func`4" , Permission . Allowed )
70
+ . Type ( "ValueTuple`1" , Permission . Allowed )
71
+ . Type ( "ValueTuple`2" , Permission . Allowed )
72
+ . Type ( "ValueTuple`3" , Permission . Allowed )
73
+ . Type ( "ValueTuple`4" , Permission . Allowed )
74
+ . Type ( "ValueTuple`5" , Permission . Allowed )
75
+ . Type ( "ValueTuple`6" , Permission . Allowed )
76
+ . Type ( "ValueTuple`7" , Permission . Allowed )
77
+ . Type ( "ValueTuple`8" , Permission . Allowed )
67
78
. Type ( "Nullable`1" , Permission . Allowed ) // Required for protobuf generated code
68
79
. Type ( typeof ( BitConverter ) , Permission . Denied , member => member
69
80
. Member ( nameof ( BitConverter . GetBytes ) , Permission . Allowed ) )
@@ -160,6 +171,27 @@ private void WhitelistOthers(Whitelist whitelist)
160
171
)
161
172
;
162
173
}
174
+
175
+ private void WhitelistCryptographyHelpers ( Whitelist whitelist )
176
+ {
177
+ whitelist
178
+ // Selectively allowed types and members
179
+ . Namespace ( "AElf.Cryptography.Bn254" , Permission . Denied , type => type
180
+ . Type ( typeof ( Bn254Helper ) , Permission . Denied , member => member
181
+ . Member ( nameof ( Bn254Helper . Bn254Pairing ) , Permission . Allowed )
182
+ . Member ( nameof ( Bn254Helper . Bn254G1Add ) , Permission . Allowed )
183
+ . Member ( nameof ( Bn254Helper . Bn254G1Mul ) , Permission . Allowed )
184
+ ) )
185
+ . Namespace ( "AElf.Cryptography.EdDSA" , Permission . Denied , type => type
186
+ . Type ( typeof ( EdDsaHelper ) , Permission . Denied , member => member
187
+ . Member ( nameof ( EdDsaHelper . Ed25519Verify ) , Permission . Allowed )
188
+ ) )
189
+ . Namespace ( "AElf.Cryptography.Keccak" , Permission . Denied , type => type
190
+ . Type ( typeof ( KeccakHelper ) , Permission . Denied , member => member
191
+ . Member ( nameof ( KeccakHelper . Keccak256 ) , Permission . Allowed )
192
+ ) )
193
+ ;
194
+ }
163
195
164
196
private Whitelist CreateWhitelist ( )
165
197
{
@@ -169,6 +201,7 @@ private Whitelist CreateWhitelist()
169
201
WhitelistReflectionTypes ( whitelist ) ;
170
202
WhitelistLinqAndCollections ( whitelist ) ;
171
203
WhitelistOthers ( whitelist ) ;
204
+ WhitelistCryptographyHelpers ( whitelist ) ;
172
205
return whitelist ;
173
206
}
174
207
}
0 commit comments