Skip to content

Commit

Permalink
Add WhitelistCryptographyHelpers whitelist method
Browse files Browse the repository at this point in the history
  • Loading branch information
chopin-fan committed Dec 27, 2024
1 parent c124761 commit a2ef9a6
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions src/AElf.CSharp.CodeOps/Validators/Whitelist/IWhitelistProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,31 @@ private void WhitelistOthers(Whitelist whitelist)
)
;
}

private void WhitelistCryptographyHelpers(Whitelist whitelist)
{
whitelist
// Selectively allowed types and members
.Namespace("AElf.Cryptography.SecretSharing", Permission.Denied, type => type
.Type(typeof(SecretSharingHelper), Permission.Denied, member => member
.Member(nameof(SecretSharingHelper.DecodeSecret), Permission.Allowed)
))
.Namespace("AElf.Cryptography.Bn254", Permission.Denied, type => type
.Type(typeof(Bn254Helper), Permission.Denied, member => member
.Member(nameof(Bn254Helper.Bn254Pairing), Permission.Allowed)
.Member(nameof(Bn254Helper.Bn254G1Add), Permission.Allowed)
.Member(nameof(Bn254Helper.Bn254G1Mul), Permission.Allowed)
))
.Namespace("AElf.Cryptography.EdDSA", Permission.Denied, type => type
.Type(typeof(EdDsaHelper), Permission.Denied, member => member
.Member(nameof(EdDsaHelper.Ed25519Verify), Permission.Allowed)
))
.Namespace("AElf.Cryptography.Keccak", Permission.Denied, type => type
.Type(typeof(KeccakHelper), Permission.Denied, member => member
.Member(nameof(KeccakHelper.Keccak256), Permission.Allowed)
))
;
}

private Whitelist CreateWhitelist()
{
Expand All @@ -180,6 +205,7 @@ private Whitelist CreateWhitelist()
WhitelistReflectionTypes(whitelist);
WhitelistLinqAndCollections(whitelist);
WhitelistOthers(whitelist);
WhitelistCryptographyHelpers(whitelist);
return whitelist;
}
}
Expand All @@ -204,22 +230,6 @@ private void WhitelistAElfTypes(Whitelist whitelist)
.Namespace("AElf.Cryptography.SecretSharing", Permission.Denied, type => type
.Type(typeof(SecretSharingHelper), Permission.Denied, member => member
.Member(nameof(SecretSharingHelper.DecodeSecret), Permission.Allowed)
))
.Namespace("AElf.Cryptography.Bn254", Permission.Denied, type => type
.Type(typeof(Bn254Helper), Permission.Denied, member => member
.Member(nameof(Bn254Helper.Bn254Pairing), Permission.Allowed)
.Member(nameof(Bn254Helper.Bn254G1Add), Permission.Allowed)
.Member(nameof(Bn254Helper.Bn254G1Mul), Permission.Allowed)
))
.Namespace("AElf.Cryptography.EdDSA", Permission.Denied, type => type
.Type(typeof(EdDsaHelper), Permission.Denied, member => member
.Member(nameof(EdDsaHelper.Ed25519Verify), Permission.Allowed)
))
.Namespace("AElf.Cryptography.Keccak", Permission.Denied, type => type
.Type(typeof(KeccakHelper), Permission.Denied, member => member
.Member(nameof(KeccakHelper.Keccak256), Permission.Allowed)
))
;

));
}
}

0 comments on commit a2ef9a6

Please sign in to comment.