public Lmots(LmotsType type, EntropyProviderTypes entropyType = EntropyProviderTypes.Random) { var(n, w, p, ls, siglen, typecode) = LmotsModeMapping.GetValsFromType(type); _n = n; _w = w; _p = p; _ls = ls; _siglen = siglen; _typecode = typecode; _entropyProvider = _entropyFactory.GetEntropyProvider(entropyType); _isRandom = entropyType == EntropyProviderTypes.Random; _sha256 = new NativeFastSha2_256(); }
private const int H25_PIECE_SIZE = 32768; // creates 1024 threads #endregion Fields #region Constructors // From an email from Scott Fluhrer: // To generate the I value for the LMS tree, we will adapt algorithm A, // by setting the I value input to be the all-zeros value, the q value // to be 0 and the i value to be 65535; we will use the first 16 bytes of the hash output. // Algorithm A: // x_q[i] = H(I || u32str(q) || u16str(i) || u8str(0xff) || SEED). // UPDATE: I value is now generated separate from SEED. Child I values still computed the same public Lms(LmsType lmsType, LmotsType lmotsType, EntropyProviderTypes entropyType = EntropyProviderTypes.Random, BitString seed = null, BitString I = null) { var(m, h, typecode) = LmsModeMapping.GetValsFromType(lmsType); _m = m; _h = h; _typecode = typecode; var param = LmotsModeMapping.GetValsFromType(lmotsType); _lmotsTypecode = param.typecode; _entropyProvider = _entropyFactory.GetEntropyProvider(entropyType); _entropyProvider.AddEntropy(seed); SEED = _entropyProvider.GetEntropy(_m * 8); _entropyProvider.AddEntropy(I); _I = _entropyProvider.GetEntropy(128); _lmots = new Lmots(lmotsType, entropyType); _isRandom = entropyType == EntropyProviderTypes.Random; _sha256 = new NativeFastSha2_256(); // For optimization the balance between interop calls and asynchronization if (_h == 5) { _pieceSize = H5_PIECE_SIZE; } else if (_h == 10) { _pieceSize = H10_PIECE_SIZE; } else if (_h == 15) { _pieceSize = H15_PIECE_SIZE; } else if (_h == 20) { _pieceSize = H20_PIECE_SIZE; } else { _pieceSize = H25_PIECE_SIZE; } }
public static (int n, int w, int p, int ls, int siglen, BitString typecode) GetValsFromType(LmotsType type) { if (type == LmotsType.LMOTS_SHA256_N32_W1) { return(32, 1, 265, 7, 8516, new BitString(1, 32)); } else if (type == LmotsType.LMOTS_SHA256_N32_W2) { return(32, 2, 133, 6, 4292, new BitString(2, 32)); } else if (type == LmotsType.LMOTS_SHA256_N32_W4) { return(32, 4, 67, 4, 2180, new BitString(3, 32)); } else { return(32, 8, 34, 0, 1124, new BitString(4, 32)); } }