static public byte[] FromLegacy(byte[] legacy) { if (legacy.Length == 65) { var result = new ECDSAPublicKey(); result.PublicKeyData = legacy; return(result.Serialize()); } return(legacy); }
public virtual Task <byte[]> SharedSecret(ECDSAPublicKey Pbk) { return(Task.Run(() => { lock (Cache) { var clipped = Pbk.FingerprintEncodedClipped; if (Cache.ContainsKey(clipped)) { return Cache[clipped]; } } var agree = new ECDHBasicAgreement(); agree.Init(PrivateKey); var result = agree.CalculateAgreement(Pbk.PublicKey).ToByteArrayUnsigned(); result = CryptoHelper.Sha256(result); lock (Cache) Cache[Pbk.FingerprintEncodedClipped] = result; return result; })); }