-
Notifications
You must be signed in to change notification settings - Fork 497
/
AlgorithmRegistry.cs
97 lines (86 loc) · 4.64 KB
/
AlgorithmRegistry.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#region License
//
// CoiniumServ - Crypto Currency Mining Pool Server Software
// Copyright (C) 2013 - 2014, CoiniumServ Project - http://www.coinium.org
// http://www.coiniumserv.com - https://github.com/CoiniumServ/CoiniumServ
//
// This software is dual-licensed: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// For the terms of this license, see licenses/gpl_v3.txt.
//
// Alternatively, you can license this software under a commercial
// license or white-label it as set out in licenses/commercial.txt.
//
#endregion
using CoiniumServ.Algorithms.Implementations;
using CoiniumServ.Container.Context;
using CoiniumServ.Container.Registries;
namespace CoiniumServ.Algorithms
{
public class AlgorithmRegistry : IRegistry
{
// algorithm names
public const string Blake = "blake";
public const string Fresh = "fresh";
public const string Fugue = "fugue";
public const string Groestl = "groestl";
public const string Keccak = "keccak";
public const string Nist5 = "nist5";
public const string Qubit = "qubit";
public const string Scrypt = "scrypt";
public const string ScryptOg = "scrypt-og";
public const string ScryptN = "scrypt-n";
public const string Sha1 = "sha1";
public const string Sha256 = "sha256";
public const string Shavite3 = "shavite3";
public const string Skein = "skein";
public const string X11 = "x11";
public const string X13 = "x13";
public const string X14 = "x14";
public const string X15 = "x15";
public const string X17 = "x17";
// todo: add hefty1, qubit support
private readonly IApplicationContext _applicationContext;
public AlgorithmRegistry(IApplicationContext applicationContext)
{
_applicationContext = applicationContext;
}
public void RegisterInstances()
{
// available cryptographic hash functions: http://en.wikipedia.org/wiki/List_of_hash_functions#Cryptographic_hash_functions
// algorithm manager
_applicationContext.Container.Register<IAlgorithmManager, AlgorithmManager>().AsMultiInstance();
// sha variants
_applicationContext.Container.Register<IHashAlgorithm, Sha256>(Sha256).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Sha1>(Sha1).AsMultiInstance();
// scrypt variants
_applicationContext.Container.Register<IHashAlgorithm, Scrypt>(Scrypt).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, ScryptOg>(ScryptOg).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, ScryptN>(ScryptN).AsMultiInstance();
// multi-hashers
_applicationContext.Container.Register<IHashAlgorithm, X11>(X11).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, X13>(X13).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, X14>(X14).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, X15>(X15).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, X17>(X17).AsMultiInstance();
// misc ones
_applicationContext.Container.Register<IHashAlgorithm, Blake>(Blake).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Fresh>(Fresh).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Fugue>(Fugue).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Groestl>(Groestl).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Keccak>(Keccak).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Nist5>(Nist5).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Qubit>(Qubit).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Shavite3>(Shavite3).AsMultiInstance();
_applicationContext.Container.Register<IHashAlgorithm, Skein>(Skein).AsMultiInstance();
}
}
}