public static SplitSecret Split(SecretShareType shareType, byte[] secret, int threshold, Diffuser diffuser) { var irreduciblePolynomial = IrreduciblePolynomial.CreateOfByteSize(secret.Length); var rawSecret = secret.ToBigIntegerFromBigEndianUnsignedBytes(); var diffusedSecret = diffuser.Scramble(rawSecret, secret.Length); var secretCoefficient = new FiniteFieldPolynomial(irreduciblePolynomial, diffusedSecret); var allCoefficients = new[] { secretCoefficient } .Concat( GetRandomPolynomials( irreduciblePolynomial, threshold - 1) ) .ToArray(); var passPhrase = new SecureString(); try { foreach (var currentChar in secret.ToHexString()) { passPhrase.AppendChar(currentChar); } } catch { passPhrase = null; } if ((passPhrase == null) || (passPhrase.Length == 0)) { passPhrase = null; } return(new SplitSecret(shareType, threshold, irreduciblePolynomial, allCoefficients, passPhrase)); }
public static SplitSecret Split(SecretShareType shareType, byte[] secret, int threshold, Diffuser diffuser) { var irreduciblePolynomial = IrreduciblePolynomial.CreateOfByteSize(secret.Length); var rawSecret = secret.ToBigIntegerFromBigEndianUnsignedBytes(); var diffusedSecret = diffuser.Scramble(rawSecret, secret.Length); var secretCoefficient = new FiniteFieldPolynomial(irreduciblePolynomial, diffusedSecret); var allCoefficients = new[] { secretCoefficient } .Concat( GetRandomPolynomials( irreduciblePolynomial, threshold - 1) ) .ToArray(); var passPhrase = new SecureString(); try { foreach (var currentChar in secret.ToHexString()) { passPhrase.AppendChar(currentChar); } } catch { passPhrase = null; } if((passPhrase == null) || (passPhrase.Length == 0)) { passPhrase = null; } return new SplitSecret(shareType, threshold, irreduciblePolynomial, allCoefficients, passPhrase); }
public SplitSecret(SecretShareType shareType, int threshold, IrreduciblePolynomial irreduciblePolynomial, FiniteFieldPolynomial[] allCoefficients, SecureString passPhrase = null) { _ShareType = shareType; Threshold = threshold; _IrreduciblePolynomial = irreduciblePolynomial; _AllCoefficients = allCoefficients; _PassPhrase = passPhrase; }
public CombinedSecret(SecretShareType shareType, byte[] recoveredBytes) { ShareType = shareType; // TODO: Use ProtectedData.Protect, but that'd pull in another DLL RecoveredBytes = recoveredBytes; }
private static SplitSecret Split(SecretShareType shareType, byte[] secret, int threshold) { return(Split(shareType, secret, threshold, DefaultDiffuser)); }
private static SplitSecret Split(SecretShareType shareType, byte[] secret, int threshold) { return Split(shareType, secret, threshold, DefaultDiffuser); }
public SecretShare(SecretShareType shareType, FiniteFieldPoint point, string checksum = null) { ShareType = shareType; Point = point; Checksum = checksum; }